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_tls.h>
25 : : #include <rte_udp.h>
26 : :
27 : : #ifdef RTE_CRYPTO_SCHEDULER
28 : : #include <rte_cryptodev_scheduler.h>
29 : : #include <rte_cryptodev_scheduler_operations.h>
30 : : #endif
31 : :
32 : : #include <rte_lcore.h>
33 : :
34 : : #include "test.h"
35 : : #include "test_cryptodev.h"
36 : :
37 : : #include "test_cryptodev_blockcipher.h"
38 : : #include "test_cryptodev_aes_test_vectors.h"
39 : : #include "test_cryptodev_des_test_vectors.h"
40 : : #include "test_cryptodev_hash_test_vectors.h"
41 : : #include "test_cryptodev_kasumi_test_vectors.h"
42 : : #include "test_cryptodev_kasumi_hash_test_vectors.h"
43 : : #include "test_cryptodev_snow3g_test_vectors.h"
44 : : #include "test_cryptodev_snow3g_hash_test_vectors.h"
45 : : #include "test_cryptodev_zuc_test_vectors.h"
46 : : #include "test_cryptodev_aead_test_vectors.h"
47 : : #include "test_cryptodev_hmac_test_vectors.h"
48 : : #include "test_cryptodev_mixed_test_vectors.h"
49 : : #include "test_cryptodev_sm4_test_vectors.h"
50 : : #ifdef RTE_LIB_SECURITY
51 : : #include "test_cryptodev_security_ipsec.h"
52 : : #include "test_cryptodev_security_ipsec_test_vectors.h"
53 : : #include "test_cryptodev_security_pdcp_test_vectors.h"
54 : : #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
55 : : #include "test_cryptodev_security_pdcp_test_func.h"
56 : : #include "test_cryptodev_security_docsis_test_vectors.h"
57 : : #include "test_cryptodev_security_tls_record.h"
58 : : #include "test_security_proto.h"
59 : :
60 : : #define SDAP_DISABLED 0
61 : : #define SDAP_ENABLED 1
62 : : #endif
63 : :
64 : : #define VDEV_ARGS_SIZE 100
65 : : #define MAX_NB_SESSIONS 4
66 : :
67 : : #define MAX_DRV_SERVICE_CTX_SIZE 256
68 : :
69 : : #define MAX_RAW_DEQUEUE_COUNT 65535
70 : :
71 : : #define IN_PLACE 0
72 : : #define OUT_OF_PLACE 1
73 : :
74 : : static int gbl_driver_id;
75 : :
76 : : static enum rte_security_session_action_type gbl_action_type =
77 : : RTE_SECURITY_ACTION_TYPE_NONE;
78 : :
79 : : enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
80 : :
81 : : struct crypto_unittest_params {
82 : : struct rte_crypto_sym_xform cipher_xform;
83 : : struct rte_crypto_sym_xform auth_xform;
84 : : struct rte_crypto_sym_xform aead_xform;
85 : : #ifdef RTE_LIB_SECURITY
86 : : struct rte_security_docsis_xform docsis_xform;
87 : : #endif
88 : :
89 : : union {
90 : : void *sess;
91 : : #ifdef RTE_LIB_SECURITY
92 : : void *sec_session;
93 : : #endif
94 : : };
95 : : #ifdef RTE_LIB_SECURITY
96 : : enum rte_security_session_action_type type;
97 : : #endif
98 : : struct rte_crypto_op *op;
99 : :
100 : : struct rte_mbuf *obuf, *ibuf;
101 : :
102 : : uint8_t *digest;
103 : : };
104 : :
105 : : #define ALIGN_POW2_ROUNDUP(num, align) \
106 : : (((num) + (align) - 1) & ~((align) - 1))
107 : :
108 : : #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts) \
109 : : for (j = 0; j < num_child_ts; index++, j++) \
110 : : parent_ts.unit_test_suites[index] = child_ts[j]
111 : :
112 : : #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types) \
113 : : for (j = 0; j < num_blk_types; index++, j++) \
114 : : parent_ts.unit_test_suites[index] = \
115 : : build_blockcipher_test_suite(blk_types[j])
116 : :
117 : : #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types) \
118 : : for (j = index; j < index + num_blk_types; j++) \
119 : : free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
120 : :
121 : : /*
122 : : * Forward declarations.
123 : : */
124 : : static int
125 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
126 : : struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
127 : : uint8_t *hmac_key);
128 : :
129 : : static int
130 : : test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
131 : : struct crypto_unittest_params *ut_params,
132 : : struct crypto_testsuite_params *ts_param,
133 : : const uint8_t *cipher,
134 : : const uint8_t *digest,
135 : : const uint8_t *iv);
136 : :
137 : : static int
138 : : security_proto_supported(enum rte_security_session_action_type action,
139 : : enum rte_security_session_protocol proto);
140 : :
141 : : static int
142 : : dev_configure_and_start(uint64_t ff_disable);
143 : :
144 : : static int
145 : : check_cipher_capability(const struct crypto_testsuite_params *ts_params,
146 : : const enum rte_crypto_cipher_algorithm cipher_algo,
147 : : const uint16_t key_size, const uint16_t iv_size);
148 : :
149 : : static int
150 : : check_auth_capability(const struct crypto_testsuite_params *ts_params,
151 : : const enum rte_crypto_auth_algorithm auth_algo,
152 : : const uint16_t key_size, const uint16_t iv_size,
153 : : const uint16_t tag_size);
154 : :
155 : : static struct rte_mbuf *
156 : 7 : setup_test_string(struct rte_mempool *mpool,
157 : : const char *string, size_t len, uint8_t blocksize)
158 : : {
159 : 7 : struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
160 [ - + ]: 7 : size_t t_len = len - (blocksize ? (len % blocksize) : 0);
161 : :
162 [ + - ]: 7 : if (m) {
163 : : char *dst;
164 : :
165 : 7 : memset(m->buf_addr, 0, m->buf_len);
166 : 7 : dst = rte_pktmbuf_append(m, t_len);
167 [ - + ]: 7 : if (!dst) {
168 : 0 : rte_pktmbuf_free(m);
169 : 0 : return NULL;
170 : : }
171 [ + - ]: 7 : if (string != NULL)
172 : : rte_memcpy(dst, string, t_len);
173 : : else
174 : : memset(dst, 0, t_len);
175 : : }
176 : :
177 : : return m;
178 : : }
179 : :
180 : : /* Get number of bytes in X bits (rounding up) */
181 : : static uint32_t
182 : : ceil_byte_length(uint32_t num_bits)
183 : : {
184 : 4 : if (num_bits % 8)
185 : 0 : return ((num_bits >> 3) + 1);
186 : : else
187 : 4 : return (num_bits >> 3);
188 : : }
189 : :
190 : : static void
191 : 0 : post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused,
192 : : uint8_t is_op_success)
193 : : {
194 : : struct rte_crypto_op *op = user_data;
195 [ # # ]: 0 : op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
196 : : RTE_CRYPTO_OP_STATUS_ERROR;
197 : 0 : }
198 : :
199 : : static struct crypto_testsuite_params testsuite_params = { NULL };
200 : : struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
201 : : static struct crypto_unittest_params unittest_params;
202 : :
203 : : int
204 : 0 : process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
205 : : struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
206 : : uint8_t len_in_bits, uint8_t cipher_iv_len)
207 : : {
208 : 0 : struct rte_crypto_sym_op *sop = op->sym;
209 : 0 : struct rte_crypto_op *ret_op = NULL;
210 : : struct rte_crypto_vec data_vec[UINT8_MAX], dest_data_vec[UINT8_MAX];
211 : : struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
212 : : union rte_crypto_sym_ofs ofs;
213 : : struct rte_crypto_sym_vec vec;
214 : : struct rte_crypto_sgl sgl, dest_sgl;
215 : : uint32_t max_len;
216 : : union rte_cryptodev_session_ctx sess;
217 : : uint64_t auth_end_iova;
218 : : uint32_t count = 0;
219 : : struct rte_crypto_raw_dp_ctx *ctx;
220 : : uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
221 : : auth_len = 0;
222 : : int32_t n;
223 : : uint32_t n_success;
224 : : int ctx_service_size;
225 : 0 : int32_t status = 0;
226 : : int enqueue_status, dequeue_status;
227 : : struct crypto_unittest_params *ut_params = &unittest_params;
228 : 0 : int is_sgl = sop->m_src->nb_segs > 1;
229 : : int ret = TEST_SUCCESS, is_oop = 0;
230 : :
231 : 0 : ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
232 [ # # ]: 0 : if (ctx_service_size < 0)
233 : : return TEST_SKIPPED;
234 : :
235 : 0 : ctx = malloc(ctx_service_size);
236 [ # # ]: 0 : if (ctx == NULL)
237 : : return TEST_FAILED;
238 : :
239 : : /* Both are enums, setting crypto_sess will suit any session type */
240 : 0 : sess.crypto_sess = op->sym->session;
241 : :
242 : 0 : ret = rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx, op->sess_type, sess, 0);
243 [ # # ]: 0 : if (ret == -ENOTSUP) {
244 : : ret = TEST_SKIPPED;
245 : 0 : goto exit;
246 [ # # ]: 0 : } else if (ret) {
247 : : ret = TEST_FAILED;
248 : 0 : goto exit;
249 : : }
250 : :
251 : 0 : cipher_iv.iova = 0;
252 : 0 : cipher_iv.va = NULL;
253 : 0 : aad_auth_iv.iova = 0;
254 : 0 : aad_auth_iv.va = NULL;
255 : 0 : digest.iova = 0;
256 : 0 : digest.va = NULL;
257 : 0 : sgl.vec = data_vec;
258 : 0 : vec.num = 1;
259 : 0 : vec.src_sgl = &sgl;
260 : 0 : vec.iv = &cipher_iv;
261 : 0 : vec.digest = &digest;
262 : 0 : vec.aad = &aad_auth_iv;
263 : 0 : vec.status = &status;
264 : :
265 : 0 : ofs.raw = 0;
266 : :
267 [ # # # # ]: 0 : if ((sop->m_dst != NULL) && (sop->m_dst != sop->m_src))
268 : : is_oop = 1;
269 : :
270 [ # # ]: 0 : if (is_cipher && is_auth) {
271 : 0 : cipher_offset = sop->cipher.data.offset;
272 : 0 : cipher_len = sop->cipher.data.length;
273 : 0 : auth_offset = sop->auth.data.offset;
274 : 0 : auth_len = sop->auth.data.length;
275 : 0 : max_len = RTE_MAX(cipher_offset + cipher_len,
276 : : auth_offset + auth_len);
277 [ # # ]: 0 : if (len_in_bits) {
278 : 0 : max_len = max_len >> 3;
279 : 0 : cipher_offset = cipher_offset >> 3;
280 : 0 : auth_offset = auth_offset >> 3;
281 : 0 : cipher_len = cipher_len >> 3;
282 : 0 : auth_len = auth_len >> 3;
283 : : }
284 : 0 : ofs.ofs.cipher.head = cipher_offset;
285 : 0 : ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
286 : 0 : ofs.ofs.auth.head = auth_offset;
287 : 0 : ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
288 : 0 : cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
289 : 0 : cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
290 : 0 : aad_auth_iv.va = rte_crypto_op_ctod_offset(
291 : : op, void *, IV_OFFSET + cipher_iv_len);
292 : 0 : aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
293 : : cipher_iv_len);
294 : 0 : digest.va = (void *)sop->auth.digest.data;
295 : 0 : digest.iova = sop->auth.digest.phys_addr;
296 : :
297 [ # # ]: 0 : if (is_sgl) {
298 : 0 : uint32_t remaining_off = auth_offset + auth_len;
299 : 0 : struct rte_mbuf *sgl_buf = sop->m_src;
300 [ # # ]: 0 : if (is_oop)
301 : : sgl_buf = sop->m_dst;
302 : :
303 : 0 : while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)
304 [ # # # # ]: 0 : && sgl_buf->next != NULL) {
305 : 0 : remaining_off -= rte_pktmbuf_data_len(sgl_buf);
306 : : sgl_buf = sgl_buf->next;
307 : : }
308 : :
309 : 0 : auth_end_iova = (uint64_t)rte_pktmbuf_iova_offset(
310 : : sgl_buf, remaining_off);
311 : : } else {
312 : 0 : auth_end_iova = rte_pktmbuf_iova(op->sym->m_src) +
313 : 0 : auth_offset + auth_len;
314 : : }
315 : : /* Then check if digest-encrypted conditions are met */
316 [ # # # # ]: 0 : if ((auth_offset + auth_len < cipher_offset + cipher_len) &&
317 [ # # ]: 0 : (digest.iova == auth_end_iova) && is_sgl)
318 : 0 : max_len = RTE_MAX(max_len,
319 : : auth_offset + auth_len +
320 : : ut_params->auth_xform.auth.digest_length);
321 : :
322 [ # # ]: 0 : } else if (is_cipher) {
323 : 0 : cipher_offset = sop->cipher.data.offset;
324 : 0 : cipher_len = sop->cipher.data.length;
325 : 0 : max_len = cipher_len + cipher_offset;
326 [ # # ]: 0 : if (len_in_bits) {
327 : 0 : max_len = max_len >> 3;
328 : 0 : cipher_offset = cipher_offset >> 3;
329 : 0 : cipher_len = cipher_len >> 3;
330 : : }
331 : 0 : ofs.ofs.cipher.head = cipher_offset;
332 : 0 : ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
333 : 0 : cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
334 : 0 : cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
335 : :
336 [ # # ]: 0 : } else if (is_auth) {
337 : 0 : auth_offset = sop->auth.data.offset;
338 : 0 : auth_len = sop->auth.data.length;
339 : 0 : max_len = auth_len + auth_offset;
340 [ # # ]: 0 : if (len_in_bits) {
341 : 0 : max_len = max_len >> 3;
342 : 0 : auth_offset = auth_offset >> 3;
343 : 0 : auth_len = auth_len >> 3;
344 : : }
345 : 0 : ofs.ofs.auth.head = auth_offset;
346 : 0 : ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
347 : 0 : aad_auth_iv.va = rte_crypto_op_ctod_offset(
348 : : op, void *, IV_OFFSET + cipher_iv_len);
349 : 0 : aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
350 : : cipher_iv_len);
351 : 0 : digest.va = (void *)sop->auth.digest.data;
352 : 0 : digest.iova = sop->auth.digest.phys_addr;
353 : :
354 : : } else { /* aead */
355 : 0 : cipher_offset = sop->aead.data.offset;
356 : 0 : cipher_len = sop->aead.data.length;
357 : 0 : max_len = cipher_len + cipher_offset;
358 [ # # ]: 0 : if (len_in_bits) {
359 : 0 : max_len = max_len >> 3;
360 : 0 : cipher_offset = cipher_offset >> 3;
361 : 0 : cipher_len = cipher_len >> 3;
362 : : }
363 : 0 : ofs.ofs.cipher.head = cipher_offset;
364 : 0 : ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
365 : 0 : cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
366 : 0 : cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
367 : 0 : aad_auth_iv.va = (void *)sop->aead.aad.data;
368 : 0 : aad_auth_iv.iova = sop->aead.aad.phys_addr;
369 : 0 : digest.va = (void *)sop->aead.digest.data;
370 : 0 : digest.iova = sop->aead.digest.phys_addr;
371 : : }
372 : :
373 : 0 : n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
374 : : data_vec, RTE_DIM(data_vec));
375 [ # # # # ]: 0 : if (n < 0 || n > sop->m_src->nb_segs) {
376 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
377 : 0 : goto exit;
378 : : }
379 : :
380 : 0 : sgl.num = n;
381 : : /* Out of place */
382 [ # # ]: 0 : if (is_oop) {
383 : 0 : dest_sgl.vec = dest_data_vec;
384 : 0 : vec.dest_sgl = &dest_sgl;
385 : 0 : n = rte_crypto_mbuf_to_vec(sop->m_dst, 0, max_len,
386 : : dest_data_vec, RTE_DIM(dest_data_vec));
387 [ # # # # ]: 0 : if (n < 0 || n > sop->m_dst->nb_segs) {
388 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
389 : 0 : goto exit;
390 : : }
391 : 0 : dest_sgl.num = n;
392 : : } else
393 : 0 : vec.dest_sgl = NULL;
394 : :
395 [ # # ]: 0 : if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
396 : : &enqueue_status) < 1) {
397 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
398 : 0 : goto exit;
399 : : }
400 : :
401 [ # # ]: 0 : if (enqueue_status == 0) {
402 : 0 : status = rte_cryptodev_raw_enqueue_done(ctx, 1);
403 [ # # ]: 0 : if (status < 0) {
404 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
405 : 0 : goto exit;
406 : : }
407 [ # # ]: 0 : } else if (enqueue_status < 0) {
408 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
409 : 0 : goto exit;
410 : : }
411 : :
412 : 0 : n = n_success = 0;
413 [ # # # # ]: 0 : while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
414 : 0 : n = rte_cryptodev_raw_dequeue_burst(ctx,
415 : : NULL, 1, post_process_raw_dp_op,
416 : : (void **)&ret_op, 0, &n_success,
417 : : &dequeue_status);
418 [ # # ]: 0 : if (dequeue_status < 0) {
419 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
420 : 0 : goto exit;
421 : : }
422 [ # # ]: 0 : if (n == 0)
423 : : rte_pause();
424 : : }
425 : :
426 [ # # # # ]: 0 : if (n == 1 && dequeue_status == 0) {
427 [ # # ]: 0 : if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
428 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
429 : 0 : goto exit;
430 : : }
431 : : }
432 : :
433 [ # # # # ]: 0 : op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
434 [ # # ]: 0 : ret_op->status == RTE_CRYPTO_OP_STATUS_ERROR ||
435 [ # # ]: 0 : n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
436 : : RTE_CRYPTO_OP_STATUS_SUCCESS;
437 : :
438 : 0 : exit:
439 : 0 : free(ctx);
440 : 0 : return ret;
441 : : }
442 : :
443 : : static void
444 : 0 : process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
445 : : {
446 : : int32_t n, st;
447 : : struct rte_crypto_sym_op *sop;
448 : : union rte_crypto_sym_ofs ofs;
449 : : struct rte_crypto_sgl sgl;
450 : : struct rte_crypto_sym_vec symvec;
451 : : struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
452 : : struct rte_crypto_vec vec[UINT8_MAX];
453 : :
454 : : sop = op->sym;
455 : :
456 : 0 : n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
457 : : sop->aead.data.length, vec, RTE_DIM(vec));
458 : :
459 [ # # # # ]: 0 : if (n < 0 || n != sop->m_src->nb_segs) {
460 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
461 : 0 : return;
462 : : }
463 : :
464 : 0 : sgl.vec = vec;
465 : 0 : sgl.num = n;
466 : 0 : symvec.src_sgl = &sgl;
467 : 0 : symvec.iv = &iv_ptr;
468 : 0 : symvec.digest = &digest_ptr;
469 : 0 : symvec.aad = &aad_ptr;
470 : 0 : symvec.status = &st;
471 : 0 : symvec.num = 1;
472 : :
473 : : /* for CPU crypto the IOVA address is not required */
474 : 0 : iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
475 : 0 : digest_ptr.va = (void *)sop->aead.digest.data;
476 : 0 : aad_ptr.va = (void *)sop->aead.aad.data;
477 : :
478 : 0 : ofs.raw = 0;
479 : :
480 : 0 : n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
481 : : &symvec);
482 : :
483 [ # # ]: 0 : if (n != 1)
484 : 0 : op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
485 : : else
486 : 0 : op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
487 : : }
488 : :
489 : : static void
490 : 0 : process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
491 : : {
492 : : int32_t n, st;
493 : : struct rte_crypto_sym_op *sop;
494 : : union rte_crypto_sym_ofs ofs;
495 : : struct rte_crypto_sgl sgl;
496 : : struct rte_crypto_sym_vec symvec;
497 : : struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
498 : : struct rte_crypto_vec vec[UINT8_MAX];
499 : :
500 : : sop = op->sym;
501 : :
502 : 0 : n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
503 : : sop->auth.data.length, vec, RTE_DIM(vec));
504 : :
505 [ # # # # ]: 0 : if (n < 0 || n != sop->m_src->nb_segs) {
506 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
507 : 0 : return;
508 : : }
509 : :
510 : 0 : sgl.vec = vec;
511 : 0 : sgl.num = n;
512 : 0 : symvec.src_sgl = &sgl;
513 : 0 : symvec.iv = &iv_ptr;
514 : 0 : symvec.digest = &digest_ptr;
515 : 0 : symvec.status = &st;
516 : 0 : symvec.num = 1;
517 : :
518 : 0 : iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
519 : 0 : digest_ptr.va = (void *)sop->auth.digest.data;
520 : :
521 : 0 : ofs.raw = 0;
522 : 0 : ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
523 : 0 : ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
524 : 0 : (sop->cipher.data.offset + sop->cipher.data.length);
525 : :
526 : 0 : n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
527 : : &symvec);
528 : :
529 [ # # ]: 0 : if (n != 1)
530 : 0 : op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
531 : : else
532 : 0 : op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
533 : : }
534 : :
535 : : static struct rte_crypto_op *
536 : 116 : process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
537 : : {
538 : :
539 [ - + ]: 116 : RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
540 : :
541 [ - + ]: 116 : if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
542 : 0 : RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
543 : 0 : return NULL;
544 : : }
545 : :
546 : 116 : op = NULL;
547 : :
548 [ - + ]: 116 : while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
549 : : rte_pause();
550 : :
551 [ + + ]: 116 : if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
552 : 11 : RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
553 : 11 : return NULL;
554 : : }
555 : :
556 : : return op;
557 : : }
558 : :
559 : : static int
560 : 1 : testsuite_setup(void)
561 : : {
562 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
563 : : struct rte_cryptodev_info info;
564 : : uint32_t i = 0, nb_devs, dev_id;
565 : : uint16_t qp_id;
566 : :
567 : : memset(ts_params, 0, sizeof(*ts_params));
568 : :
569 : 1 : ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
570 [ + - ]: 1 : if (ts_params->mbuf_pool == NULL) {
571 : : /* Not already created so create */
572 : 1 : ts_params->mbuf_pool = rte_pktmbuf_pool_create(
573 : : "CRYPTO_MBUFPOOL",
574 : : NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
575 : 1 : rte_socket_id());
576 [ - + ]: 1 : if (ts_params->mbuf_pool == NULL) {
577 : 0 : RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
578 : 0 : return TEST_FAILED;
579 : : }
580 : : }
581 : :
582 : 1 : ts_params->large_mbuf_pool = rte_mempool_lookup(
583 : : "CRYPTO_LARGE_MBUFPOOL");
584 [ + - ]: 1 : if (ts_params->large_mbuf_pool == NULL) {
585 : : /* Not already created so create */
586 : 1 : ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
587 : : "CRYPTO_LARGE_MBUFPOOL",
588 : : 1, 0, 0, UINT16_MAX,
589 : 1 : rte_socket_id());
590 [ - + ]: 1 : if (ts_params->large_mbuf_pool == NULL) {
591 : 0 : RTE_LOG(ERR, USER1,
592 : : "Can't create CRYPTO_LARGE_MBUFPOOL\n");
593 : 0 : return TEST_FAILED;
594 : : }
595 : : }
596 : :
597 : 1 : ts_params->op_mpool = rte_crypto_op_pool_create(
598 : : "MBUF_CRYPTO_SYM_OP_POOL",
599 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC,
600 : : NUM_MBUFS, MBUF_CACHE_SIZE,
601 : : DEFAULT_NUM_XFORMS *
602 : : sizeof(struct rte_crypto_sym_xform) +
603 : : MAXIMUM_IV_LENGTH,
604 : 1 : rte_socket_id());
605 [ - + ]: 1 : if (ts_params->op_mpool == NULL) {
606 : 0 : RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
607 : 0 : return TEST_FAILED;
608 : : }
609 : :
610 : 1 : nb_devs = rte_cryptodev_count();
611 [ - + ]: 1 : if (nb_devs < 1) {
612 : 0 : RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
613 : 0 : return TEST_SKIPPED;
614 : : }
615 : :
616 [ - + ]: 1 : if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
617 : 0 : RTE_LOG(WARNING, USER1, "No %s devices found?\n",
618 : : rte_cryptodev_driver_name_get(gbl_driver_id));
619 : 0 : return TEST_SKIPPED;
620 : : }
621 : :
622 : : /* Create list of valid crypto devs */
623 [ + + ]: 2 : for (i = 0; i < nb_devs; i++) {
624 : 1 : rte_cryptodev_info_get(i, &info);
625 [ + - ]: 1 : if (info.driver_id == gbl_driver_id)
626 : 1 : ts_params->valid_devs[ts_params->valid_dev_count++] = i;
627 : : }
628 : :
629 [ + - ]: 1 : if (ts_params->valid_dev_count < 1)
630 : : return TEST_FAILED;
631 : :
632 : : /* Set up all the qps on the first of the valid devices found */
633 : :
634 : 1 : dev_id = ts_params->valid_devs[0];
635 : :
636 : 1 : rte_cryptodev_info_get(dev_id, &info);
637 : :
638 : 1 : ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
639 : 1 : ts_params->conf.socket_id = SOCKET_ID_ANY;
640 : 1 : ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
641 : :
642 : : unsigned int session_size =
643 : 1 : rte_cryptodev_sym_get_private_session_size(dev_id);
644 : :
645 : : #ifdef RTE_LIB_SECURITY
646 : 1 : unsigned int security_session_size = rte_security_session_get_size(
647 : : rte_cryptodev_get_sec_ctx(dev_id));
648 : :
649 : : if (session_size < security_session_size)
650 : : session_size = security_session_size;
651 : : #endif
652 : : /*
653 : : * Create mempool with maximum number of sessions.
654 : : */
655 [ - + ]: 1 : if (info.sym.max_nb_sessions != 0 &&
656 : : info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
657 : 0 : RTE_LOG(ERR, USER1, "Device does not support "
658 : : "at least %u sessions\n",
659 : : MAX_NB_SESSIONS);
660 : 0 : return TEST_FAILED;
661 : : }
662 : :
663 : 1 : ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
664 : : "test_sess_mp", MAX_NB_SESSIONS, session_size, 0, 0,
665 : : SOCKET_ID_ANY);
666 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
667 : : "session mempool allocation failed");
668 : :
669 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
670 : : &ts_params->conf),
671 : : "Failed to configure cryptodev %u with %u qps",
672 : : dev_id, ts_params->conf.nb_queue_pairs);
673 : :
674 : 1 : ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
675 : 1 : ts_params->qp_conf.mp_session = ts_params->session_mpool;
676 : :
677 [ + + ]: 9 : for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
678 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
679 : : dev_id, qp_id, &ts_params->qp_conf,
680 : : rte_cryptodev_socket_id(dev_id)),
681 : : "Failed to setup queue pair %u on cryptodev %u",
682 : : qp_id, dev_id);
683 : : }
684 : :
685 : : return TEST_SUCCESS;
686 : : }
687 : :
688 : : static void
689 : 1 : testsuite_teardown(void)
690 : : {
691 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
692 : : int res;
693 : :
694 [ + - ]: 1 : if (ts_params->mbuf_pool != NULL) {
695 : 1 : RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
696 : : rte_mempool_avail_count(ts_params->mbuf_pool));
697 : : }
698 : :
699 [ + - ]: 1 : if (ts_params->op_mpool != NULL) {
700 : 1 : RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
701 : : rte_mempool_avail_count(ts_params->op_mpool));
702 : : }
703 : :
704 [ + - ]: 1 : if (ts_params->session_mpool != NULL) {
705 : 1 : rte_mempool_free(ts_params->session_mpool);
706 : 1 : ts_params->session_mpool = NULL;
707 : : }
708 : :
709 : 1 : res = rte_cryptodev_close(ts_params->valid_devs[0]);
710 [ - + ]: 1 : if (res)
711 : 0 : RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
712 : 1 : }
713 : :
714 : : static int
715 : 30 : check_capabilities_supported(enum rte_crypto_sym_xform_type type,
716 : : const int *algs, uint16_t num_algs)
717 : : {
718 : 30 : uint8_t dev_id = testsuite_params.valid_devs[0];
719 : : bool some_alg_supported = FALSE;
720 : : uint16_t i;
721 : :
722 [ + + ]: 71 : for (i = 0; i < num_algs && !some_alg_supported; i++) {
723 : 41 : struct rte_cryptodev_sym_capability_idx alg = {
724 : 41 : type, {algs[i]}
725 : : };
726 [ + + ]: 41 : if (rte_cryptodev_sym_capability_get(dev_id,
727 : : &alg) != NULL)
728 : : some_alg_supported = TRUE;
729 : : }
730 [ + + ]: 30 : if (!some_alg_supported)
731 : 13 : return TEST_SKIPPED;
732 : :
733 : : return 0;
734 : : }
735 : :
736 : : int
737 : 9 : check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
738 : : uint16_t num_ciphers)
739 : : {
740 : 17 : return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
741 : : (const int *) ciphers, num_ciphers);
742 : : }
743 : :
744 : : int
745 : 2 : check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
746 : : uint16_t num_auths)
747 : : {
748 : 9 : return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
749 : : (const int *) auths, num_auths);
750 : : }
751 : :
752 : : int
753 : 0 : check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
754 : : uint16_t num_aeads)
755 : : {
756 : 4 : return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
757 : : (const int *) aeads, num_aeads);
758 : : }
759 : :
760 : : static int
761 : 1 : null_testsuite_setup(void)
762 : : {
763 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
764 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
765 : : struct rte_cryptodev_info dev_info;
766 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
767 : : RTE_CRYPTO_CIPHER_NULL
768 : : };
769 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
770 : : RTE_CRYPTO_AUTH_NULL
771 : : };
772 : :
773 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
774 : :
775 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
776 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
777 : : "testsuite not met\n");
778 : 0 : return TEST_SKIPPED;
779 : : }
780 : :
781 [ + - ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
782 [ + - ]: 1 : && check_auth_capabilities_supported(auths,
783 : : RTE_DIM(auths)) != 0) {
784 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for NULL "
785 : : "testsuite not met\n");
786 : 1 : return TEST_SKIPPED;
787 : : }
788 : :
789 : : return 0;
790 : : }
791 : :
792 : : static int
793 : 1 : crypto_gen_testsuite_setup(void)
794 : : {
795 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
796 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
797 : : struct rte_cryptodev_info dev_info;
798 : :
799 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
800 : :
801 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
802 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
803 : : "testsuite not met\n");
804 : 0 : return TEST_SKIPPED;
805 : : }
806 : :
807 : : return 0;
808 : : }
809 : :
810 : : #ifdef RTE_LIB_SECURITY
811 : : static int
812 : 4 : sec_proto_testsuite_setup(enum rte_security_session_protocol protocol)
813 : : {
814 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
815 : : struct crypto_unittest_params *ut_params = &unittest_params;
816 : : struct rte_cryptodev_info dev_info;
817 : : int ret = 0;
818 : :
819 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
820 : :
821 [ + - ]: 4 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
822 : 4 : RTE_LOG(INFO, USER1,
823 : : "Feature flag requirements for security protocol testsuite not met\n");
824 : 4 : return TEST_SKIPPED;
825 : : }
826 : :
827 : : /* Reconfigure to enable security */
828 : 0 : ret = dev_configure_and_start(0);
829 [ # # ]: 0 : if (ret != TEST_SUCCESS)
830 : : return ret;
831 : :
832 : : /* Set action type */
833 : 0 : ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
834 : :
835 [ # # ]: 0 : if (security_proto_supported(RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL, protocol) < 0) {
836 : 0 : RTE_LOG(INFO, USER1,
837 : : "Capability requirements for security protocol test not met\n");
838 : : ret = TEST_SKIPPED;
839 : : }
840 : :
841 : 0 : test_sec_alg_list_populate();
842 : 0 : test_sec_auth_only_alg_list_populate();
843 : :
844 : : /*
845 : : * Stop the device. Device would be started again by individual test
846 : : * case setup routine.
847 : : */
848 : 0 : rte_cryptodev_stop(ts_params->valid_devs[0]);
849 : :
850 : 0 : return ret;
851 : : }
852 : :
853 : : static int
854 : 1 : ipsec_proto_testsuite_setup(void)
855 : : {
856 : 1 : return sec_proto_testsuite_setup(RTE_SECURITY_PROTOCOL_IPSEC);
857 : : }
858 : :
859 : : static int
860 : 3 : tls_record_proto_testsuite_setup(void)
861 : : {
862 : 3 : test_sec_proto_pattern_generate();
863 : :
864 : 3 : return sec_proto_testsuite_setup(RTE_SECURITY_PROTOCOL_TLS_RECORD);
865 : : }
866 : :
867 : : static int
868 : 1 : pdcp_proto_testsuite_setup(void)
869 : : {
870 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
871 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
872 : : struct rte_cryptodev_info dev_info;
873 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
874 : : RTE_CRYPTO_CIPHER_NULL,
875 : : RTE_CRYPTO_CIPHER_AES_CTR,
876 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
877 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2
878 : : };
879 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
880 : : RTE_CRYPTO_AUTH_NULL,
881 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
882 : : RTE_CRYPTO_AUTH_AES_CMAC,
883 : : RTE_CRYPTO_AUTH_ZUC_EIA3
884 : : };
885 : :
886 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_auth_key));
887 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_bearer));
888 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_crypto_key));
889 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in));
890 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_in_len));
891 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_out));
892 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_data_sn_size));
893 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn));
894 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_hfn_threshold));
895 : : RTE_BUILD_BUG_ON(RTE_DIM(pdcp_test_params) != RTE_DIM(pdcp_test_packet_direction));
896 : :
897 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
898 : :
899 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
900 : : !(dev_info.feature_flags &
901 : : RTE_CRYPTODEV_FF_SECURITY)) {
902 : 1 : RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
903 : : "testsuite not met\n");
904 : 1 : return TEST_SKIPPED;
905 : : }
906 : :
907 [ # # ]: 0 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
908 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
909 : : RTE_DIM(auths)) != 0) {
910 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
911 : : "testsuite not met\n");
912 : 0 : return TEST_SKIPPED;
913 : : }
914 : :
915 : : return 0;
916 : : }
917 : :
918 : : static int
919 : 1 : docsis_proto_testsuite_setup(void)
920 : : {
921 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
922 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
923 : : struct rte_cryptodev_info dev_info;
924 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
925 : : RTE_CRYPTO_CIPHER_AES_DOCSISBPI
926 : : };
927 : :
928 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
929 : :
930 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
931 : : !(dev_info.feature_flags &
932 : : RTE_CRYPTODEV_FF_SECURITY)) {
933 : 1 : RTE_LOG(INFO, USER1, "Feature flag requirements for DOCSIS "
934 : : "Proto testsuite not met\n");
935 : 1 : return TEST_SKIPPED;
936 : : }
937 : :
938 [ # # ]: 0 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
939 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for DOCSIS Proto "
940 : : "testsuite not met\n");
941 : 0 : return TEST_SKIPPED;
942 : : }
943 : :
944 : : return 0;
945 : : }
946 : : #endif
947 : :
948 : : static int
949 : 1 : aes_ccm_auth_testsuite_setup(void)
950 : : {
951 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
952 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
953 : : struct rte_cryptodev_info dev_info;
954 : 1 : const enum rte_crypto_aead_algorithm aeads[] = {
955 : : RTE_CRYPTO_AEAD_AES_CCM
956 : : };
957 : :
958 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
959 : :
960 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
961 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
962 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
963 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
964 : : "testsuite not met\n");
965 : 0 : return TEST_SKIPPED;
966 : : }
967 : :
968 [ - + ]: 1 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
969 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
970 : : "testsuite not met\n");
971 : 0 : return TEST_SKIPPED;
972 : : }
973 : :
974 : : return 0;
975 : : }
976 : :
977 : : static int
978 : 1 : aes_gcm_auth_testsuite_setup(void)
979 : : {
980 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
981 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
982 : : struct rte_cryptodev_info dev_info;
983 : 1 : const enum rte_crypto_aead_algorithm aeads[] = {
984 : : RTE_CRYPTO_AEAD_AES_GCM
985 : : };
986 : :
987 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
988 : :
989 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
990 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
991 : : "testsuite not met\n");
992 : 0 : return TEST_SKIPPED;
993 : : }
994 : :
995 [ - + ]: 1 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
996 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
997 : : "testsuite not met\n");
998 : 0 : return TEST_SKIPPED;
999 : : }
1000 : :
1001 : : return 0;
1002 : : }
1003 : :
1004 : : static int
1005 : 1 : aes_gmac_auth_testsuite_setup(void)
1006 : : {
1007 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1008 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1009 : : struct rte_cryptodev_info dev_info;
1010 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1011 : : RTE_CRYPTO_AUTH_AES_GMAC
1012 : : };
1013 : :
1014 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1015 : :
1016 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1017 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1018 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1019 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
1020 : : "testsuite not met\n");
1021 : 0 : return TEST_SKIPPED;
1022 : : }
1023 : :
1024 [ - + ]: 1 : if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1025 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
1026 : : "testsuite not met\n");
1027 : 0 : return TEST_SKIPPED;
1028 : : }
1029 : :
1030 : : return 0;
1031 : : }
1032 : :
1033 : : static int
1034 : 1 : chacha20_poly1305_testsuite_setup(void)
1035 : : {
1036 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1037 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1038 : : struct rte_cryptodev_info dev_info;
1039 : 1 : const enum rte_crypto_aead_algorithm aeads[] = {
1040 : : RTE_CRYPTO_AEAD_CHACHA20_POLY1305
1041 : : };
1042 : :
1043 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1044 : :
1045 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1046 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1047 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1048 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for "
1049 : : "Chacha20-Poly1305 testsuite not met\n");
1050 : 0 : return TEST_SKIPPED;
1051 : : }
1052 : :
1053 [ + - ]: 1 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1054 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for "
1055 : : "Chacha20-Poly1305 testsuite not met\n");
1056 : 1 : return TEST_SKIPPED;
1057 : : }
1058 : :
1059 : : return 0;
1060 : : }
1061 : :
1062 : : static int
1063 : 1 : snow3g_testsuite_setup(void)
1064 : : {
1065 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1066 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1067 : : struct rte_cryptodev_info dev_info;
1068 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1069 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1070 : :
1071 : : };
1072 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1073 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2
1074 : : };
1075 : :
1076 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1077 : :
1078 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1079 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
1080 : : "testsuite not met\n");
1081 : 0 : return TEST_SKIPPED;
1082 : : }
1083 : :
1084 [ + - ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1085 [ + - ]: 1 : && check_auth_capabilities_supported(auths,
1086 : : RTE_DIM(auths)) != 0) {
1087 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
1088 : : "testsuite not met\n");
1089 : 1 : return TEST_SKIPPED;
1090 : : }
1091 : :
1092 : : return 0;
1093 : : }
1094 : :
1095 : : static int
1096 : 1 : zuc_testsuite_setup(void)
1097 : : {
1098 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1099 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1100 : : struct rte_cryptodev_info dev_info;
1101 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1102 : : RTE_CRYPTO_CIPHER_ZUC_EEA3
1103 : : };
1104 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1105 : : RTE_CRYPTO_AUTH_ZUC_EIA3
1106 : : };
1107 : :
1108 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1109 : :
1110 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1111 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
1112 : : "testsuite not met\n");
1113 : 0 : return TEST_SKIPPED;
1114 : : }
1115 : :
1116 [ + - ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1117 [ + - ]: 1 : && check_auth_capabilities_supported(auths,
1118 : : RTE_DIM(auths)) != 0) {
1119 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
1120 : : "testsuite not met\n");
1121 : 1 : return TEST_SKIPPED;
1122 : : }
1123 : :
1124 : : return 0;
1125 : : }
1126 : :
1127 : : static int
1128 : 1 : hmac_md5_auth_testsuite_setup(void)
1129 : : {
1130 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1131 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1132 : : struct rte_cryptodev_info dev_info;
1133 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1134 : : RTE_CRYPTO_AUTH_MD5_HMAC
1135 : : };
1136 : :
1137 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1138 : :
1139 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1140 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1141 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1142 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1143 : : "Auth testsuite not met\n");
1144 : 0 : return TEST_SKIPPED;
1145 : : }
1146 : :
1147 [ - + ]: 1 : if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1148 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1149 : : "testsuite not met\n");
1150 : 0 : return TEST_SKIPPED;
1151 : : }
1152 : :
1153 : : return 0;
1154 : : }
1155 : :
1156 : : static int
1157 : 1 : kasumi_testsuite_setup(void)
1158 : : {
1159 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1160 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1161 : : struct rte_cryptodev_info dev_info;
1162 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1163 : : RTE_CRYPTO_CIPHER_KASUMI_F8
1164 : : };
1165 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1166 : : RTE_CRYPTO_AUTH_KASUMI_F9
1167 : : };
1168 : :
1169 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1170 : :
1171 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1172 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1173 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1174 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1175 : : "testsuite not met\n");
1176 : 0 : return TEST_SKIPPED;
1177 : : }
1178 : :
1179 [ + - ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1180 [ + - ]: 1 : && check_auth_capabilities_supported(auths,
1181 : : RTE_DIM(auths)) != 0) {
1182 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1183 : : "testsuite not met\n");
1184 : 1 : return TEST_SKIPPED;
1185 : : }
1186 : :
1187 : : return 0;
1188 : : }
1189 : :
1190 : : static int
1191 : 1 : negative_aes_gcm_testsuite_setup(void)
1192 : : {
1193 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1194 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1195 : : struct rte_cryptodev_info dev_info;
1196 : 1 : const enum rte_crypto_aead_algorithm aeads[] = {
1197 : : RTE_CRYPTO_AEAD_AES_GCM
1198 : : };
1199 : :
1200 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1201 : :
1202 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1203 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1204 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1205 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1206 : : "AES GCM testsuite not met\n");
1207 : 0 : return TEST_SKIPPED;
1208 : : }
1209 : :
1210 [ - + ]: 1 : if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1211 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1212 : : "AES GCM testsuite not met\n");
1213 : 0 : return TEST_SKIPPED;
1214 : : }
1215 : :
1216 : : return 0;
1217 : : }
1218 : :
1219 : : static int
1220 : 1 : negative_aes_gmac_testsuite_setup(void)
1221 : : {
1222 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1223 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1224 : : struct rte_cryptodev_info dev_info;
1225 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1226 : : RTE_CRYPTO_AUTH_AES_GMAC
1227 : : };
1228 : :
1229 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1230 : :
1231 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1232 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1233 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1234 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1235 : : "AES GMAC testsuite not met\n");
1236 : 0 : return TEST_SKIPPED;
1237 : : }
1238 : :
1239 [ - + ]: 1 : if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1240 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1241 : : "AES GMAC testsuite not met\n");
1242 : 0 : return TEST_SKIPPED;
1243 : : }
1244 : :
1245 : : return 0;
1246 : : }
1247 : :
1248 : : static int
1249 : 1 : mixed_cipher_hash_testsuite_setup(void)
1250 : : {
1251 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1252 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1253 : : struct rte_cryptodev_info dev_info;
1254 : : uint64_t feat_flags;
1255 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1256 : : RTE_CRYPTO_CIPHER_NULL,
1257 : : RTE_CRYPTO_CIPHER_AES_CTR,
1258 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
1259 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1260 : : };
1261 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1262 : : RTE_CRYPTO_AUTH_NULL,
1263 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1264 : : RTE_CRYPTO_AUTH_AES_CMAC,
1265 : : RTE_CRYPTO_AUTH_ZUC_EIA3
1266 : : };
1267 : :
1268 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1269 : 1 : feat_flags = dev_info.feature_flags;
1270 : :
1271 [ + - ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1272 [ - + ]: 1 : (global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1273 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1274 : : "Cipher Hash testsuite not met\n");
1275 : 0 : return TEST_SKIPPED;
1276 : : }
1277 : :
1278 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1279 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1280 : : RTE_DIM(auths)) != 0) {
1281 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1282 : : "Cipher Hash testsuite not met\n");
1283 : 0 : return TEST_SKIPPED;
1284 : : }
1285 : :
1286 : : return 0;
1287 : : }
1288 : :
1289 : : static int
1290 : 1 : esn_testsuite_setup(void)
1291 : : {
1292 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1293 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1294 : : struct rte_cryptodev_info dev_info;
1295 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1296 : : RTE_CRYPTO_CIPHER_AES_CBC
1297 : : };
1298 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1299 : : RTE_CRYPTO_AUTH_SHA1_HMAC
1300 : : };
1301 : :
1302 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1303 : :
1304 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1305 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1306 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1307 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1308 : : "testsuite not met\n");
1309 : 0 : return TEST_SKIPPED;
1310 : : }
1311 : :
1312 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1313 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1314 : : RTE_DIM(auths)) != 0) {
1315 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1316 : : "testsuite not met\n");
1317 : 0 : return TEST_SKIPPED;
1318 : : }
1319 : :
1320 : : return 0;
1321 : : }
1322 : :
1323 : : static int
1324 : 1 : multi_session_testsuite_setup(void)
1325 : : {
1326 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1327 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1328 : : struct rte_cryptodev_info dev_info;
1329 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1330 : : RTE_CRYPTO_CIPHER_AES_CBC
1331 : : };
1332 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1333 : : RTE_CRYPTO_AUTH_SHA512_HMAC
1334 : : };
1335 : :
1336 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1337 : :
1338 [ - + ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1339 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1340 : : "Session testsuite not met\n");
1341 : 0 : return TEST_SKIPPED;
1342 : : }
1343 : :
1344 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1345 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1346 : : RTE_DIM(auths)) != 0) {
1347 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1348 : : "Session testsuite not met\n");
1349 : 0 : return TEST_SKIPPED;
1350 : : }
1351 : :
1352 : : return 0;
1353 : : }
1354 : :
1355 : : static int
1356 : 1 : negative_hmac_sha1_testsuite_setup(void)
1357 : : {
1358 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1359 : 1 : uint8_t dev_id = ts_params->valid_devs[0];
1360 : : struct rte_cryptodev_info dev_info;
1361 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1362 : : RTE_CRYPTO_CIPHER_AES_CBC
1363 : : };
1364 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1365 : : RTE_CRYPTO_AUTH_SHA1_HMAC
1366 : : };
1367 : :
1368 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1369 : :
1370 [ + - ]: 1 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1371 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1372 [ # # ]: 0 : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1373 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1374 : : "HMAC SHA1 testsuite not met\n");
1375 : 0 : return TEST_SKIPPED;
1376 : : }
1377 : :
1378 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1379 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1380 : : RTE_DIM(auths)) != 0) {
1381 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1382 : : "HMAC SHA1 testsuite not met\n");
1383 : 0 : return TEST_SKIPPED;
1384 : : }
1385 : :
1386 : : return 0;
1387 : : }
1388 : :
1389 : : static int
1390 : 430 : dev_configure_and_start(uint64_t ff_disable)
1391 : : {
1392 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1393 : : struct crypto_unittest_params *ut_params = &unittest_params;
1394 : :
1395 : : uint16_t qp_id;
1396 : :
1397 : : /* Clear unit test parameters before running test */
1398 : : memset(ut_params, 0, sizeof(*ut_params));
1399 : :
1400 : : /* Reconfigure device to default parameters */
1401 : 430 : ts_params->conf.socket_id = SOCKET_ID_ANY;
1402 : 430 : ts_params->conf.ff_disable = ff_disable;
1403 : 430 : ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1404 : 430 : ts_params->qp_conf.mp_session = ts_params->session_mpool;
1405 : :
1406 [ - + ]: 430 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1407 : : &ts_params->conf),
1408 : : "Failed to configure cryptodev %u",
1409 : : ts_params->valid_devs[0]);
1410 : :
1411 [ + + ]: 3870 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1412 [ - + ]: 3440 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1413 : : ts_params->valid_devs[0], qp_id,
1414 : : &ts_params->qp_conf,
1415 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1416 : : "Failed to setup queue pair %u on cryptodev %u",
1417 : : qp_id, ts_params->valid_devs[0]);
1418 : : }
1419 : :
1420 : :
1421 : 430 : rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1422 : :
1423 : : /* Start the device */
1424 [ - + ]: 430 : TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1425 : : "Failed to start cryptodev %u",
1426 : : ts_params->valid_devs[0]);
1427 : :
1428 : : return TEST_SUCCESS;
1429 : : }
1430 : :
1431 : : int
1432 : 430 : ut_setup(void)
1433 : : {
1434 : : /* Configure and start the device with security feature disabled */
1435 : 430 : return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1436 : : }
1437 : :
1438 : : static int
1439 : 0 : ut_setup_security(void)
1440 : : {
1441 : : /* Configure and start the device with no features disabled */
1442 : 0 : return dev_configure_and_start(0);
1443 : : }
1444 : :
1445 : : static int
1446 : 0 : ut_setup_security_rx_inject(void)
1447 : : {
1448 : 0 : struct rte_mempool *mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
1449 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1450 : 0 : struct rte_eth_conf port_conf = {
1451 : : .rxmode = {
1452 : : .offloads = RTE_ETH_RX_OFFLOAD_CHECKSUM |
1453 : : RTE_ETH_RX_OFFLOAD_SECURITY,
1454 : : },
1455 : : .txmode = {
1456 : : .offloads = RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE,
1457 : : },
1458 : : .lpbk_mode = 1, /* Enable loopback */
1459 : : };
1460 : : struct rte_cryptodev_info dev_info;
1461 : 0 : struct rte_eth_rxconf rx_conf = {
1462 : : .rx_thresh = {
1463 : : .pthresh = 8,
1464 : : .hthresh = 8,
1465 : : .wthresh = 8,
1466 : : },
1467 : : .rx_free_thresh = 32,
1468 : : };
1469 : : uint16_t nb_ports;
1470 : : void *sec_ctx;
1471 : : int ret;
1472 : :
1473 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
1474 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY_RX_INJECT) ||
1475 : : !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
1476 : 0 : RTE_LOG(INFO, USER1,
1477 : : "Feature requirements for IPsec Rx inject test case not met\n");
1478 : 0 : return TEST_SKIPPED;
1479 : : }
1480 : :
1481 : 0 : sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
1482 [ # # ]: 0 : if (sec_ctx == NULL)
1483 : : return TEST_SKIPPED;
1484 : :
1485 : 0 : nb_ports = rte_eth_dev_count_avail();
1486 [ # # ]: 0 : if (nb_ports == 0)
1487 : : return TEST_SKIPPED;
1488 : :
1489 : 0 : ret = rte_eth_dev_configure(0 /* port_id */,
1490 : : 1 /* nb_rx_queue */,
1491 : : 0 /* nb_tx_queue */,
1492 : : &port_conf);
1493 [ # # ]: 0 : if (ret) {
1494 : : printf("Could not configure ethdev port 0 [err=%d]\n", ret);
1495 : 0 : return TEST_SKIPPED;
1496 : : }
1497 : :
1498 : : /* Rx queue setup */
1499 : 0 : ret = rte_eth_rx_queue_setup(0 /* port_id */,
1500 : : 0 /* rx_queue_id */,
1501 : : 1024 /* nb_rx_desc */,
1502 : : SOCKET_ID_ANY,
1503 : : &rx_conf,
1504 : : mbuf_pool);
1505 [ # # ]: 0 : if (ret) {
1506 : : printf("Could not setup eth port 0 queue 0\n");
1507 : 0 : return TEST_SKIPPED;
1508 : : }
1509 : :
1510 : 0 : ret = rte_security_rx_inject_configure(sec_ctx, 0, true);
1511 [ # # ]: 0 : if (ret) {
1512 : : printf("Could not enable Rx inject offload");
1513 : 0 : return TEST_SKIPPED;
1514 : : }
1515 : :
1516 : 0 : ret = rte_eth_dev_start(0);
1517 [ # # ]: 0 : if (ret) {
1518 : : printf("Could not start ethdev");
1519 : 0 : return TEST_SKIPPED;
1520 : : }
1521 : :
1522 : 0 : ret = rte_eth_promiscuous_enable(0);
1523 [ # # ]: 0 : if (ret) {
1524 : : printf("Could not enable promiscuous mode");
1525 : 0 : return TEST_SKIPPED;
1526 : : }
1527 : :
1528 : : /* Configure and start cryptodev with no features disabled */
1529 : 0 : return dev_configure_and_start(0);
1530 : : }
1531 : :
1532 : : static inline void
1533 : 0 : ext_mbuf_callback_fn_free(void *addr __rte_unused, void *opaque __rte_unused)
1534 : : {
1535 : 0 : }
1536 : :
1537 : : static inline void
1538 : 108 : ext_mbuf_memzone_free(int nb_segs)
1539 : : {
1540 : : int i;
1541 : :
1542 [ + + ]: 324 : for (i = 0; i <= nb_segs; i++) {
1543 : : char mz_name[RTE_MEMZONE_NAMESIZE];
1544 : : const struct rte_memzone *memzone;
1545 : : snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
1546 : 216 : memzone = rte_memzone_lookup(mz_name);
1547 [ + + ]: 216 : if (memzone != NULL) {
1548 : 2 : rte_memzone_free(memzone);
1549 : : memzone = NULL;
1550 : : }
1551 : : }
1552 : 108 : }
1553 : :
1554 : : static inline struct rte_mbuf *
1555 : 2 : ext_mbuf_create(struct rte_mempool *mbuf_pool, int pkt_len,
1556 : : int nb_segs, const void *input_text)
1557 : : {
1558 : : struct rte_mbuf *m = NULL, *mbuf = NULL;
1559 : : size_t data_off = 0;
1560 : : uint8_t *dst;
1561 : : int i, size;
1562 : : int t_len;
1563 : :
1564 [ - + ]: 2 : if (pkt_len < 1) {
1565 : : printf("Packet size must be 1 or more (is %d)\n", pkt_len);
1566 : 0 : return NULL;
1567 : : }
1568 : :
1569 [ - + ]: 2 : if (nb_segs < 1) {
1570 : : printf("Number of segments must be 1 or more (is %d)\n",
1571 : : nb_segs);
1572 : 0 : return NULL;
1573 : : }
1574 : :
1575 [ + - ]: 2 : t_len = pkt_len >= nb_segs ? pkt_len / nb_segs : 1;
1576 : : size = pkt_len;
1577 : :
1578 : : /* Create chained mbuf_src with external buffer */
1579 [ + + ]: 4 : for (i = 0; size > 0; i++) {
1580 : : struct rte_mbuf_ext_shared_info *ret_shinfo = NULL;
1581 : 2 : uint16_t data_len = RTE_MIN(size, t_len);
1582 : : char mz_name[RTE_MEMZONE_NAMESIZE];
1583 : : const struct rte_memzone *memzone;
1584 : : void *ext_buf_addr = NULL;
1585 : : rte_iova_t buf_iova;
1586 : 2 : bool freed = false;
1587 : : uint16_t buf_len;
1588 : :
1589 : 2 : buf_len = RTE_ALIGN_CEIL(data_len + 1024 +
1590 : : sizeof(struct rte_mbuf_ext_shared_info), 8);
1591 : :
1592 : : snprintf(mz_name, RTE_MEMZONE_NAMESIZE, "ext_buf_%d", i);
1593 : 2 : memzone = rte_memzone_lookup(mz_name);
1594 [ - + - - ]: 2 : if (memzone != NULL && memzone->len != buf_len) {
1595 : 0 : rte_memzone_free(memzone);
1596 : : memzone = NULL;
1597 : : }
1598 [ + - ]: 2 : if (memzone == NULL) {
1599 : 2 : memzone = rte_memzone_reserve_aligned(mz_name, buf_len, SOCKET_ID_ANY,
1600 : : RTE_MEMZONE_IOVA_CONTIG, RTE_CACHE_LINE_SIZE);
1601 [ - + ]: 2 : if (memzone == NULL) {
1602 : : printf("Can't allocate memory zone %s\n", mz_name);
1603 : 0 : return NULL;
1604 : : }
1605 : : }
1606 : :
1607 : 2 : ext_buf_addr = memzone->addr;
1608 [ - + ]: 2 : if (input_text)
1609 : 0 : memcpy(ext_buf_addr, RTE_PTR_ADD(input_text, data_off), data_len);
1610 : :
1611 : : /* Create buffer to hold rte_mbuf header */
1612 : 2 : m = rte_pktmbuf_alloc(mbuf_pool);
1613 [ + - ]: 2 : if (i == 0)
1614 : : mbuf = m;
1615 : :
1616 [ - + ]: 2 : if (m == NULL) {
1617 : : printf("Cannot create segment for source mbuf");
1618 : 0 : goto fail;
1619 : : }
1620 : :
1621 : : /* Save shared data (like callback function) in external buffer's end */
1622 : : ret_shinfo = rte_pktmbuf_ext_shinfo_init_helper(ext_buf_addr, &buf_len,
1623 : : ext_mbuf_callback_fn_free, &freed);
1624 : : if (ret_shinfo == NULL) {
1625 : : printf("Shared mem initialization failed!\n");
1626 : 0 : goto fail;
1627 : : }
1628 : :
1629 : 2 : buf_iova = rte_mem_virt2iova(ext_buf_addr);
1630 : :
1631 : : /* Attach external buffer to mbuf */
1632 : : rte_pktmbuf_attach_extbuf(m, ext_buf_addr, buf_iova, buf_len,
1633 : : ret_shinfo);
1634 [ - + ]: 2 : if (m->ol_flags != RTE_MBUF_F_EXTERNAL) {
1635 : : printf("External buffer is not attached to mbuf\n");
1636 : 0 : goto fail;
1637 : : }
1638 : :
1639 [ - + ]: 2 : if (input_text) {
1640 : : dst = (uint8_t *)rte_pktmbuf_append(m, data_len);
1641 [ # # ]: 0 : if (dst == NULL) {
1642 : : printf("Cannot append %d bytes to the mbuf\n", data_len);
1643 : 0 : goto fail;
1644 : : }
1645 : : }
1646 : :
1647 [ - + ]: 2 : if (mbuf != m)
1648 : : rte_pktmbuf_chain(mbuf, m);
1649 : :
1650 : 2 : size -= data_len;
1651 : 2 : data_off += data_len;
1652 : : }
1653 : :
1654 : : return mbuf;
1655 : :
1656 : : fail:
1657 : 0 : rte_pktmbuf_free(mbuf);
1658 : 0 : ext_mbuf_memzone_free(nb_segs);
1659 : 0 : return NULL;
1660 : : }
1661 : :
1662 : : void
1663 : 430 : ut_teardown(void)
1664 : : {
1665 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1666 : : struct crypto_unittest_params *ut_params = &unittest_params;
1667 : :
1668 : : /* free crypto session structure */
1669 : : #ifdef RTE_LIB_SECURITY
1670 [ - + ]: 430 : if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1671 [ # # ]: 0 : if (ut_params->sec_session) {
1672 : 0 : rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1673 : 0 : (ts_params->valid_devs[0]),
1674 : : ut_params->sec_session);
1675 : 0 : ut_params->sec_session = NULL;
1676 : : }
1677 : : } else
1678 : : #endif
1679 : : {
1680 [ + + ]: 430 : if (ut_params->sess) {
1681 : 109 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
1682 : : ut_params->sess);
1683 : 109 : ut_params->sess = NULL;
1684 : : }
1685 : : }
1686 : :
1687 : : /* free crypto operation structure */
1688 : 430 : rte_crypto_op_free(ut_params->op);
1689 : :
1690 : : /*
1691 : : * free mbuf - both obuf and ibuf are usually the same,
1692 : : * so check if they point at the same address is necessary,
1693 : : * to avoid freeing the mbuf twice.
1694 : : */
1695 [ + + ]: 430 : if (ut_params->obuf) {
1696 : 6 : rte_pktmbuf_free(ut_params->obuf);
1697 [ + + ]: 6 : if (ut_params->ibuf == ut_params->obuf)
1698 : 3 : ut_params->ibuf = 0;
1699 : 6 : ut_params->obuf = 0;
1700 : : }
1701 [ + + ]: 430 : if (ut_params->ibuf) {
1702 : 108 : ext_mbuf_memzone_free(1);
1703 : 108 : rte_pktmbuf_free(ut_params->ibuf);
1704 : 108 : ut_params->ibuf = 0;
1705 : : }
1706 : :
1707 [ + - ]: 430 : if (ts_params->mbuf_pool != NULL)
1708 : 430 : RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1709 : : rte_mempool_avail_count(ts_params->mbuf_pool));
1710 : :
1711 : : /* Stop the device */
1712 : 430 : rte_cryptodev_stop(ts_params->valid_devs[0]);
1713 : 430 : }
1714 : :
1715 : : static void
1716 : 0 : ut_teardown_rx_inject(void)
1717 : : {
1718 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1719 : : void *sec_ctx;
1720 : : int ret;
1721 : :
1722 [ # # ]: 0 : if (rte_eth_dev_count_avail() != 0) {
1723 : 0 : ret = rte_eth_dev_reset(0);
1724 [ # # ]: 0 : if (ret)
1725 : : printf("Could not reset eth port 0");
1726 : :
1727 : : }
1728 : :
1729 : 0 : ut_teardown();
1730 : :
1731 : 0 : sec_ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
1732 [ # # ]: 0 : if (sec_ctx == NULL)
1733 : : return;
1734 : :
1735 : 0 : ret = rte_security_rx_inject_configure(sec_ctx, 0, false);
1736 [ # # ]: 0 : if (ret) {
1737 : : printf("Could not disable Rx inject offload");
1738 : 0 : return;
1739 : : }
1740 : : }
1741 : :
1742 : : static int
1743 : 1 : test_device_configure_invalid_dev_id(void)
1744 : : {
1745 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1746 : : uint16_t dev_id, num_devs = 0;
1747 : :
1748 [ - + ]: 1 : TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1749 : : "Need at least %d devices for test", 1);
1750 : :
1751 : : /* valid dev_id values */
1752 : 1 : dev_id = ts_params->valid_devs[0];
1753 : :
1754 : : /* Stop the device in case it's started so it can be configured */
1755 : 1 : rte_cryptodev_stop(dev_id);
1756 : :
1757 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1758 : : "Failed test for rte_cryptodev_configure: "
1759 : : "invalid dev_num %u", dev_id);
1760 : :
1761 : : /* invalid dev_id values */
1762 : : dev_id = num_devs;
1763 : :
1764 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1765 : : "Failed test for rte_cryptodev_configure: "
1766 : : "invalid dev_num %u", dev_id);
1767 : :
1768 : : dev_id = 0xff;
1769 : :
1770 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1771 : : "Failed test for rte_cryptodev_configure:"
1772 : : "invalid dev_num %u", dev_id);
1773 : :
1774 : : return TEST_SUCCESS;
1775 : : }
1776 : :
1777 : : static int
1778 : 1 : test_device_configure_invalid_queue_pair_ids(void)
1779 : : {
1780 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1781 : 1 : uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1782 : :
1783 : : /* Stop the device in case it's started so it can be configured */
1784 : 1 : rte_cryptodev_stop(ts_params->valid_devs[0]);
1785 : :
1786 : : /* valid - max value queue pairs */
1787 : 1 : ts_params->conf.nb_queue_pairs = orig_nb_qps;
1788 : :
1789 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1790 : : &ts_params->conf),
1791 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
1792 : : ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1793 : :
1794 : : /* valid - one queue pairs */
1795 : 1 : ts_params->conf.nb_queue_pairs = 1;
1796 : :
1797 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1798 : : &ts_params->conf),
1799 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
1800 : : ts_params->valid_devs[0],
1801 : : ts_params->conf.nb_queue_pairs);
1802 : :
1803 : :
1804 : : /* invalid - zero queue pairs */
1805 : 1 : ts_params->conf.nb_queue_pairs = 0;
1806 : :
1807 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1808 : : &ts_params->conf),
1809 : : "Failed test for rte_cryptodev_configure, dev_id %u,"
1810 : : " invalid qps: %u",
1811 : : ts_params->valid_devs[0],
1812 : : ts_params->conf.nb_queue_pairs);
1813 : :
1814 : :
1815 : : /* invalid - max value supported by field queue pairs */
1816 : 1 : ts_params->conf.nb_queue_pairs = UINT16_MAX;
1817 : :
1818 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1819 : : &ts_params->conf),
1820 : : "Failed test for rte_cryptodev_configure, dev_id %u,"
1821 : : " invalid qps: %u",
1822 : : ts_params->valid_devs[0],
1823 : : ts_params->conf.nb_queue_pairs);
1824 : :
1825 : :
1826 : : /* invalid - max value + 1 queue pairs */
1827 : 1 : ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1828 : :
1829 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1830 : : &ts_params->conf),
1831 : : "Failed test for rte_cryptodev_configure, dev_id %u,"
1832 : : " invalid qps: %u",
1833 : : ts_params->valid_devs[0],
1834 : : ts_params->conf.nb_queue_pairs);
1835 : :
1836 : : /* revert to original testsuite value */
1837 : 1 : ts_params->conf.nb_queue_pairs = orig_nb_qps;
1838 : :
1839 : 1 : return TEST_SUCCESS;
1840 : : }
1841 : :
1842 : : static int
1843 : 1 : test_queue_pair_descriptor_setup(void)
1844 : : {
1845 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
1846 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
1847 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1848 : : };
1849 : : uint16_t qp_id;
1850 : :
1851 : : /* Stop the device in case it's started so it can be configured */
1852 : 1 : rte_cryptodev_stop(ts_params->valid_devs[0]);
1853 : :
1854 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1855 : : &ts_params->conf),
1856 : : "Failed to configure cryptodev %u",
1857 : : ts_params->valid_devs[0]);
1858 : :
1859 : : /*
1860 : : * Test various ring sizes on this device. memzones can't be
1861 : : * freed so are re-used if ring is released and re-created.
1862 : : */
1863 : 1 : qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1864 : 1 : qp_conf.mp_session = ts_params->session_mpool;
1865 : :
1866 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1867 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1868 : : ts_params->valid_devs[0], qp_id, &qp_conf,
1869 : : rte_cryptodev_socket_id(
1870 : : ts_params->valid_devs[0])),
1871 : : "Failed test for "
1872 : : "rte_cryptodev_queue_pair_setup: num_inflights "
1873 : : "%u on qp %u on cryptodev %u",
1874 : : qp_conf.nb_descriptors, qp_id,
1875 : : ts_params->valid_devs[0]);
1876 : : }
1877 : :
1878 : 1 : qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1879 : :
1880 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1881 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1882 : : ts_params->valid_devs[0], qp_id, &qp_conf,
1883 : : rte_cryptodev_socket_id(
1884 : : ts_params->valid_devs[0])),
1885 : : "Failed test for"
1886 : : " rte_cryptodev_queue_pair_setup: num_inflights"
1887 : : " %u on qp %u on cryptodev %u",
1888 : : qp_conf.nb_descriptors, qp_id,
1889 : : ts_params->valid_devs[0]);
1890 : : }
1891 : :
1892 : 1 : qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1893 : :
1894 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1895 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1896 : : ts_params->valid_devs[0], qp_id, &qp_conf,
1897 : : rte_cryptodev_socket_id(
1898 : : ts_params->valid_devs[0])),
1899 : : "Failed test for "
1900 : : "rte_cryptodev_queue_pair_setup: num_inflights"
1901 : : " %u on qp %u on cryptodev %u",
1902 : : qp_conf.nb_descriptors, qp_id,
1903 : : ts_params->valid_devs[0]);
1904 : : }
1905 : :
1906 : 1 : qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1907 : :
1908 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1909 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1910 : : ts_params->valid_devs[0], qp_id, &qp_conf,
1911 : : rte_cryptodev_socket_id(
1912 : : ts_params->valid_devs[0])),
1913 : : "Failed test for"
1914 : : " rte_cryptodev_queue_pair_setup:"
1915 : : "num_inflights %u on qp %u on cryptodev %u",
1916 : : qp_conf.nb_descriptors, qp_id,
1917 : : ts_params->valid_devs[0]);
1918 : : }
1919 : :
1920 : : /* test invalid queue pair id */
1921 : 1 : qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
1922 : :
1923 : : qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
1924 : :
1925 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1926 : : ts_params->valid_devs[0],
1927 : : qp_id, &qp_conf,
1928 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1929 : : "Failed test for rte_cryptodev_queue_pair_setup:"
1930 : : "invalid qp %u on cryptodev %u",
1931 : : qp_id, ts_params->valid_devs[0]);
1932 : :
1933 : : qp_id = 0xffff; /*invalid*/
1934 : :
1935 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1936 : : ts_params->valid_devs[0],
1937 : : qp_id, &qp_conf,
1938 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1939 : : "Failed test for rte_cryptodev_queue_pair_setup:"
1940 : : "invalid qp %u on cryptodev %u",
1941 : : qp_id, ts_params->valid_devs[0]);
1942 : :
1943 : : return TEST_SUCCESS;
1944 : : }
1945 : :
1946 : : /* ***** Plaintext data for tests ***** */
1947 : :
1948 : : const char catch_22_quote_1[] =
1949 : : "There was only one catch and that was Catch-22, which "
1950 : : "specified that a concern for one's safety in the face of "
1951 : : "dangers that were real and immediate was the process of a "
1952 : : "rational mind. Orr was crazy and could be grounded. All he "
1953 : : "had to do was ask; and as soon as he did, he would no longer "
1954 : : "be crazy and would have to fly more missions. Orr would be "
1955 : : "crazy to fly more missions and sane if he didn't, but if he "
1956 : : "was sane he had to fly them. If he flew them he was crazy "
1957 : : "and didn't have to; but if he didn't want to he was sane and "
1958 : : "had to. Yossarian was moved very deeply by the absolute "
1959 : : "simplicity of this clause of Catch-22 and let out a "
1960 : : "respectful whistle. \"That's some catch, that Catch-22\", he "
1961 : : "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1962 : :
1963 : : const char catch_22_quote[] =
1964 : : "What a lousy earth! He wondered how many people were "
1965 : : "destitute that same night even in his own prosperous country, "
1966 : : "how many homes were shanties, how many husbands were drunk "
1967 : : "and wives socked, and how many children were bullied, abused, "
1968 : : "or abandoned. How many families hungered for food they could "
1969 : : "not afford to buy? How many hearts were broken? How many "
1970 : : "suicides would take place that same night, how many people "
1971 : : "would go insane? How many cockroaches and landlords would "
1972 : : "triumph? How many winners were losers, successes failures, "
1973 : : "and rich men poor men? How many wise guys were stupid? How "
1974 : : "many happy endings were unhappy endings? How many honest men "
1975 : : "were liars, brave men cowards, loyal men traitors, how many "
1976 : : "sainted men were corrupt, how many people in positions of "
1977 : : "trust had sold their souls to bodyguards, how many had never "
1978 : : "had souls? How many straight-and-narrow paths were crooked "
1979 : : "paths? How many best families were worst families and how "
1980 : : "many good people were bad people? When you added them all up "
1981 : : "and then subtracted, you might be left with only the children, "
1982 : : "and perhaps with Albert Einstein and an old violinist or "
1983 : : "sculptor somewhere.";
1984 : :
1985 : : #define QUOTE_480_BYTES (480)
1986 : : #define QUOTE_512_BYTES (512)
1987 : : #define QUOTE_768_BYTES (768)
1988 : : #define QUOTE_1024_BYTES (1024)
1989 : :
1990 : :
1991 : :
1992 : : /* ***** SHA1 Hash Tests ***** */
1993 : :
1994 : : #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1995 : :
1996 : : static uint8_t hmac_sha1_key[] = {
1997 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1998 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1999 : : 0xDE, 0xF4, 0xDE, 0xAD };
2000 : :
2001 : : /* ***** SHA224 Hash Tests ***** */
2002 : :
2003 : : #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
2004 : :
2005 : :
2006 : : /* ***** AES-CBC Cipher Tests ***** */
2007 : :
2008 : : #define CIPHER_KEY_LENGTH_AES_CBC (16)
2009 : : #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
2010 : :
2011 : : static uint8_t aes_cbc_key[] = {
2012 : : 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
2013 : : 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
2014 : :
2015 : : static uint8_t aes_cbc_iv[] = {
2016 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
2017 : : 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
2018 : :
2019 : :
2020 : : /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
2021 : :
2022 : : static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
2023 : : 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
2024 : : 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
2025 : : 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
2026 : : 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
2027 : : 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
2028 : : 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
2029 : : 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
2030 : : 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
2031 : : 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
2032 : : 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
2033 : : 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
2034 : : 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
2035 : : 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
2036 : : 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
2037 : : 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
2038 : : 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
2039 : : 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
2040 : : 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
2041 : : 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
2042 : : 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
2043 : : 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
2044 : : 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
2045 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2046 : : 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
2047 : : 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
2048 : : 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
2049 : : 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
2050 : : 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
2051 : : 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
2052 : : 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
2053 : : 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
2054 : : 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
2055 : : 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
2056 : : 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
2057 : : 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
2058 : : 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
2059 : : 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
2060 : : 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
2061 : : 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
2062 : : 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
2063 : : 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
2064 : : 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
2065 : : 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
2066 : : 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
2067 : : 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
2068 : : 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
2069 : : 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
2070 : : 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
2071 : : 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
2072 : : 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
2073 : : 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
2074 : : 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
2075 : : 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
2076 : : 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
2077 : : 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
2078 : : 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
2079 : : 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
2080 : : 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
2081 : : 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
2082 : : 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
2083 : : 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
2084 : : 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
2085 : : 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
2086 : : 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
2087 : : };
2088 : :
2089 : : static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
2090 : : 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
2091 : : 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2092 : : 0x18, 0x8c, 0x1d, 0x32
2093 : : };
2094 : :
2095 : :
2096 : : /* Multisession Vector context Test */
2097 : : /*Begin Session 0 */
2098 : : static uint8_t ms_aes_cbc_key0[] = {
2099 : : 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2100 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2101 : : };
2102 : :
2103 : : static uint8_t ms_aes_cbc_iv0[] = {
2104 : : 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2105 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2106 : : };
2107 : :
2108 : : static const uint8_t ms_aes_cbc_cipher0[] = {
2109 : : 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
2110 : : 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
2111 : : 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
2112 : : 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
2113 : : 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
2114 : : 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
2115 : : 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
2116 : : 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
2117 : : 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
2118 : : 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
2119 : : 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
2120 : : 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
2121 : : 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
2122 : : 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
2123 : : 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
2124 : : 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
2125 : : 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
2126 : : 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
2127 : : 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
2128 : : 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
2129 : : 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
2130 : : 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
2131 : : 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
2132 : : 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
2133 : : 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
2134 : : 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
2135 : : 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
2136 : : 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
2137 : : 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
2138 : : 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
2139 : : 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
2140 : : 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
2141 : : 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
2142 : : 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
2143 : : 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
2144 : : 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
2145 : : 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
2146 : : 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
2147 : : 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
2148 : : 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
2149 : : 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
2150 : : 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
2151 : : 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
2152 : : 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
2153 : : 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
2154 : : 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
2155 : : 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
2156 : : 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
2157 : : 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
2158 : : 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
2159 : : 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
2160 : : 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
2161 : : 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
2162 : : 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
2163 : : 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
2164 : : 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
2165 : : 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
2166 : : 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
2167 : : 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
2168 : : 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
2169 : : 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
2170 : : 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
2171 : : 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
2172 : : 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
2173 : : };
2174 : :
2175 : :
2176 : : static uint8_t ms_hmac_key0[] = {
2177 : : 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2178 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2179 : : 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2180 : : 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2181 : : 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2182 : : 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2183 : : 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2184 : : 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2185 : : };
2186 : :
2187 : : static const uint8_t ms_hmac_digest0[] = {
2188 : : 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
2189 : : 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
2190 : : 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
2191 : : 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
2192 : : 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
2193 : : 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
2194 : : 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
2195 : : 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
2196 : : };
2197 : :
2198 : : /* End Session 0 */
2199 : : /* Begin session 1 */
2200 : :
2201 : : static uint8_t ms_aes_cbc_key1[] = {
2202 : : 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2203 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2204 : : };
2205 : :
2206 : : static uint8_t ms_aes_cbc_iv1[] = {
2207 : : 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2208 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2209 : : };
2210 : :
2211 : : static const uint8_t ms_aes_cbc_cipher1[] = {
2212 : : 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
2213 : : 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
2214 : : 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
2215 : : 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
2216 : : 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
2217 : : 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
2218 : : 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
2219 : : 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
2220 : : 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
2221 : : 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
2222 : : 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
2223 : : 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
2224 : : 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
2225 : : 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
2226 : : 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
2227 : : 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
2228 : : 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
2229 : : 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
2230 : : 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
2231 : : 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
2232 : : 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
2233 : : 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
2234 : : 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
2235 : : 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
2236 : : 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
2237 : : 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
2238 : : 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
2239 : : 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
2240 : : 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
2241 : : 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
2242 : : 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
2243 : : 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
2244 : : 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
2245 : : 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
2246 : : 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
2247 : : 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
2248 : : 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
2249 : : 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
2250 : : 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
2251 : : 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
2252 : : 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
2253 : : 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
2254 : : 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
2255 : : 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
2256 : : 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
2257 : : 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
2258 : : 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
2259 : : 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
2260 : : 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
2261 : : 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
2262 : : 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
2263 : : 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
2264 : : 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
2265 : : 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
2266 : : 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
2267 : : 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
2268 : : 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
2269 : : 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
2270 : : 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
2271 : : 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
2272 : : 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
2273 : : 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
2274 : : 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
2275 : : 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
2276 : :
2277 : : };
2278 : :
2279 : : static uint8_t ms_hmac_key1[] = {
2280 : : 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2281 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2282 : : 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2283 : : 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2284 : : 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2285 : : 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2286 : : 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2287 : : 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2288 : : };
2289 : :
2290 : : static const uint8_t ms_hmac_digest1[] = {
2291 : : 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
2292 : : 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
2293 : : 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
2294 : : 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
2295 : : 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
2296 : : 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
2297 : : 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
2298 : : 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
2299 : : };
2300 : : /* End Session 1 */
2301 : : /* Begin Session 2 */
2302 : : static uint8_t ms_aes_cbc_key2[] = {
2303 : : 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2304 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2305 : : };
2306 : :
2307 : : static uint8_t ms_aes_cbc_iv2[] = {
2308 : : 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2309 : : 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2310 : : };
2311 : :
2312 : : static const uint8_t ms_aes_cbc_cipher2[] = {
2313 : : 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
2314 : : 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
2315 : : 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
2316 : : 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
2317 : : 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
2318 : : 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
2319 : : 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
2320 : : 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
2321 : : 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
2322 : : 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
2323 : : 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
2324 : : 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
2325 : : 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
2326 : : 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
2327 : : 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
2328 : : 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
2329 : : 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
2330 : : 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
2331 : : 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
2332 : : 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
2333 : : 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
2334 : : 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
2335 : : 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
2336 : : 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
2337 : : 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
2338 : : 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
2339 : : 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
2340 : : 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
2341 : : 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
2342 : : 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
2343 : : 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
2344 : : 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
2345 : : 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
2346 : : 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
2347 : : 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
2348 : : 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
2349 : : 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
2350 : : 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
2351 : : 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
2352 : : 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
2353 : : 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
2354 : : 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
2355 : : 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2356 : : 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2357 : : 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2358 : : 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2359 : : 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2360 : : 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2361 : : 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2362 : : 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2363 : : 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2364 : : 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2365 : : 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2366 : : 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2367 : : 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2368 : : 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2369 : : 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2370 : : 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2371 : : 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2372 : : 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2373 : : 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2374 : : 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2375 : : 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2376 : : 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2377 : : };
2378 : :
2379 : : static uint8_t ms_hmac_key2[] = {
2380 : : 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2381 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2382 : : 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2383 : : 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2384 : : 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2385 : : 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2386 : : 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2387 : : 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2388 : : };
2389 : :
2390 : : static const uint8_t ms_hmac_digest2[] = {
2391 : : 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2392 : : 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2393 : : 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2394 : : 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2395 : : 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2396 : : 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2397 : : 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2398 : : 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2399 : : };
2400 : :
2401 : : /* End Session 2 */
2402 : :
2403 : :
2404 : : static int
2405 : 2 : test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2406 : : {
2407 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2408 : : struct crypto_unittest_params *ut_params = &unittest_params;
2409 : : /* Verify the capabilities */
2410 : : struct rte_cryptodev_sym_capability_idx cap_idx;
2411 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2412 : 2 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2413 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2414 : : &cap_idx) == NULL)
2415 : : return TEST_SKIPPED;
2416 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2417 : 2 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2418 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2419 : : &cap_idx) == NULL)
2420 : : return TEST_SKIPPED;
2421 : :
2422 : : /* Generate test mbuf data and space for digest */
2423 : 2 : ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2424 : : catch_22_quote, QUOTE_512_BYTES, 0);
2425 : :
2426 : 2 : ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2427 : : DIGEST_BYTE_LENGTH_SHA1);
2428 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2429 : :
2430 : : /* Setup Cipher Parameters */
2431 : 2 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2432 : 2 : ut_params->cipher_xform.next = &ut_params->auth_xform;
2433 : :
2434 : 2 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2435 : 2 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2436 : 2 : ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2437 : 2 : ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2438 : 2 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2439 : 2 : ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2440 : :
2441 : : /* Setup HMAC Parameters */
2442 : 2 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2443 : :
2444 : 2 : ut_params->auth_xform.next = NULL;
2445 : :
2446 : 2 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2447 : 2 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2448 : 2 : ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2449 : 2 : ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2450 : 2 : ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2451 : :
2452 : 2 : rte_errno = 0;
2453 : 4 : ut_params->sess = rte_cryptodev_sym_session_create(
2454 : 2 : ts_params->valid_devs[0], &ut_params->cipher_xform,
2455 : : ts_params->session_mpool);
2456 [ + - ]: 2 : if (rte_errno == ENOTSUP)
2457 : : return TEST_SKIPPED;
2458 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2459 : :
2460 : : /* Generate crypto op data structure */
2461 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2462 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2463 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
2464 : : "Failed to allocate symmetric crypto operation struct");
2465 : :
2466 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2467 : :
2468 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2469 : :
2470 : : /* set crypto operation source mbuf */
2471 : 2 : sym_op->m_src = ut_params->ibuf;
2472 : :
2473 : : /* Set crypto operation authentication parameters */
2474 : 2 : sym_op->auth.digest.data = ut_params->digest;
2475 [ - + ]: 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2476 : : ut_params->ibuf, QUOTE_512_BYTES);
2477 : :
2478 : 2 : sym_op->auth.data.offset = 0;
2479 : 2 : sym_op->auth.data.length = QUOTE_512_BYTES;
2480 : :
2481 : : /* Copy IV at the end of the crypto operation */
2482 [ - + ]: 2 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2483 : : aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2484 : :
2485 : : /* Set crypto operation cipher parameters */
2486 : 2 : sym_op->cipher.data.offset = 0;
2487 : 2 : sym_op->cipher.data.length = QUOTE_512_BYTES;
2488 : :
2489 : : /* Process crypto operation */
2490 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2491 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2492 : : ut_params->op);
2493 : : else
2494 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(
2495 : : process_crypto_request(ts_params->valid_devs[0],
2496 : : ut_params->op),
2497 : : "failed to process sym crypto op");
2498 : :
2499 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2500 : : "crypto op processing failed");
2501 : :
2502 : : /* Validate obuf */
2503 : 2 : uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2504 : : uint8_t *);
2505 : :
2506 [ - + ]: 2 : TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2507 : : catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2508 : : QUOTE_512_BYTES,
2509 : : "ciphertext data not as expected");
2510 : :
2511 : 2 : uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2512 : :
2513 [ + - - + ]: 4 : TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2514 : : catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2515 : : gbl_driver_id == rte_cryptodev_driver_id_get(
2516 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2517 : : TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2518 : : DIGEST_BYTE_LENGTH_SHA1,
2519 : : "Generated digest data not as expected");
2520 : :
2521 : : return TEST_SUCCESS;
2522 : : }
2523 : :
2524 : : /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2525 : :
2526 : : #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
2527 : :
2528 : : static uint8_t hmac_sha512_key[] = {
2529 : : 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2530 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2531 : : 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2532 : : 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2533 : : 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2534 : : 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2535 : : 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2536 : : 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2537 : :
2538 : : static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2539 : : 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2540 : : 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2541 : : 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2542 : : 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2543 : : 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2544 : : 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2545 : : 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2546 : : 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2547 : :
2548 : :
2549 : :
2550 : : static int
2551 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2552 : : struct crypto_unittest_params *ut_params,
2553 : : uint8_t *cipher_key,
2554 : : uint8_t *hmac_key);
2555 : :
2556 : : static int
2557 : : test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2558 : : struct crypto_unittest_params *ut_params,
2559 : : struct crypto_testsuite_params *ts_params,
2560 : : const uint8_t *cipher,
2561 : : const uint8_t *digest,
2562 : : const uint8_t *iv);
2563 : :
2564 : :
2565 : : static int
2566 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2567 : : struct crypto_unittest_params *ut_params,
2568 : : uint8_t *cipher_key,
2569 : : uint8_t *hmac_key)
2570 : : {
2571 : :
2572 : : /* Setup Cipher Parameters */
2573 : 4 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2574 : 4 : ut_params->cipher_xform.next = NULL;
2575 : :
2576 : 4 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2577 : 4 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2578 : 4 : ut_params->cipher_xform.cipher.key.data = cipher_key;
2579 : 4 : ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2580 : 4 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2581 : 4 : ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2582 : :
2583 : : /* Setup HMAC Parameters */
2584 : 4 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2585 : 4 : ut_params->auth_xform.next = &ut_params->cipher_xform;
2586 : :
2587 : 4 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2588 : 4 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2589 : 4 : ut_params->auth_xform.auth.key.data = hmac_key;
2590 : 4 : ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2591 : 4 : ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2592 : :
2593 : : return TEST_SUCCESS;
2594 : : }
2595 : :
2596 : :
2597 : : static int
2598 : 5 : test_AES_CBC_HMAC_SHA512_decrypt_perform(void *sess,
2599 : : struct crypto_unittest_params *ut_params,
2600 : : struct crypto_testsuite_params *ts_params,
2601 : : const uint8_t *cipher,
2602 : : const uint8_t *digest,
2603 : : const uint8_t *iv)
2604 : : {
2605 : : int ret;
2606 : :
2607 : : /* Generate test mbuf data and digest */
2608 : 5 : ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2609 : : (const char *)
2610 : : cipher,
2611 : : QUOTE_512_BYTES, 0);
2612 : :
2613 : 5 : ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2614 : : DIGEST_BYTE_LENGTH_SHA512);
2615 [ - + ]: 5 : TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2616 : :
2617 : : rte_memcpy(ut_params->digest,
2618 : : digest,
2619 : : DIGEST_BYTE_LENGTH_SHA512);
2620 : :
2621 : : /* Generate Crypto op data structure */
2622 : 5 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2623 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2624 [ - + ]: 5 : TEST_ASSERT_NOT_NULL(ut_params->op,
2625 : : "Failed to allocate symmetric crypto operation struct");
2626 : :
2627 : : rte_crypto_op_attach_sym_session(ut_params->op, sess);
2628 : :
2629 : 5 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2630 : :
2631 : : /* set crypto operation source mbuf */
2632 : 5 : sym_op->m_src = ut_params->ibuf;
2633 : :
2634 : 5 : sym_op->auth.digest.data = ut_params->digest;
2635 [ - + ]: 5 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2636 : : ut_params->ibuf, QUOTE_512_BYTES);
2637 : :
2638 : 5 : sym_op->auth.data.offset = 0;
2639 : 5 : sym_op->auth.data.length = QUOTE_512_BYTES;
2640 : :
2641 : : /* Copy IV at the end of the crypto operation */
2642 [ - + ]: 5 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2643 : : iv, CIPHER_IV_LENGTH_AES_CBC);
2644 : :
2645 : 5 : sym_op->cipher.data.offset = 0;
2646 : 5 : sym_op->cipher.data.length = QUOTE_512_BYTES;
2647 : :
2648 : : /* Process crypto operation */
2649 [ - + ]: 5 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2650 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2651 : : ut_params->op);
2652 [ - + ]: 5 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
2653 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
2654 [ # # ]: 0 : if (ret != TEST_SUCCESS)
2655 : : return ret;
2656 : : } else
2657 [ - + ]: 5 : TEST_ASSERT_NOT_NULL(
2658 : : process_crypto_request(ts_params->valid_devs[0],
2659 : : ut_params->op),
2660 : : "failed to process sym crypto op");
2661 : :
2662 [ - + ]: 5 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2663 : : "crypto op processing failed");
2664 : :
2665 : 5 : ut_params->obuf = ut_params->op->sym->m_src;
2666 : :
2667 : : /* Validate obuf */
2668 [ - + ]: 5 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
2669 : : rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2670 : : catch_22_quote,
2671 : : QUOTE_512_BYTES,
2672 : : "Plaintext data not as expected");
2673 : :
2674 : : /* Validate obuf */
2675 [ - + ]: 5 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2676 : : "Digest verification failed");
2677 : :
2678 : : return TEST_SUCCESS;
2679 : : }
2680 : :
2681 : : /* ***** SNOW 3G Tests ***** */
2682 : : static int
2683 : 0 : create_wireless_algo_hash_session(uint8_t dev_id,
2684 : : const uint8_t *key, const uint8_t key_len,
2685 : : const uint8_t iv_len, const uint8_t auth_len,
2686 : : enum rte_crypto_auth_operation op,
2687 : : enum rte_crypto_auth_algorithm algo)
2688 : 0 : {
2689 : 0 : uint8_t hash_key[key_len];
2690 : :
2691 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2692 : : struct crypto_unittest_params *ut_params = &unittest_params;
2693 : :
2694 : : memcpy(hash_key, key, key_len);
2695 : :
2696 : 0 : debug_hexdump(stdout, "key:", key, key_len);
2697 : :
2698 : : /* Setup Authentication Parameters */
2699 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2700 : 0 : ut_params->auth_xform.next = NULL;
2701 : :
2702 : 0 : ut_params->auth_xform.auth.op = op;
2703 : 0 : ut_params->auth_xform.auth.algo = algo;
2704 : 0 : ut_params->auth_xform.auth.key.length = key_len;
2705 : 0 : ut_params->auth_xform.auth.key.data = hash_key;
2706 : 0 : ut_params->auth_xform.auth.digest_length = auth_len;
2707 : 0 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2708 : 0 : ut_params->auth_xform.auth.iv.length = iv_len;
2709 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2710 : : &ut_params->auth_xform, ts_params->session_mpool);
2711 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2712 : : return TEST_SKIPPED;
2713 : :
2714 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2715 : : return 0;
2716 : : }
2717 : :
2718 : : static int
2719 : 0 : create_wireless_algo_cipher_session(uint8_t dev_id,
2720 : : enum rte_crypto_cipher_operation op,
2721 : : enum rte_crypto_cipher_algorithm algo,
2722 : : const uint8_t *key, const uint8_t key_len,
2723 : : uint8_t iv_len)
2724 : 0 : {
2725 : 0 : uint8_t cipher_key[key_len];
2726 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2727 : : struct crypto_unittest_params *ut_params = &unittest_params;
2728 : :
2729 : : memcpy(cipher_key, key, key_len);
2730 : :
2731 : : /* Setup Cipher Parameters */
2732 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2733 : 0 : ut_params->cipher_xform.next = NULL;
2734 : :
2735 : 0 : ut_params->cipher_xform.cipher.algo = algo;
2736 : 0 : ut_params->cipher_xform.cipher.op = op;
2737 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
2738 : 0 : ut_params->cipher_xform.cipher.key.length = key_len;
2739 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2740 : 0 : ut_params->cipher_xform.cipher.iv.length = iv_len;
2741 : :
2742 : 0 : debug_hexdump(stdout, "key:", key, key_len);
2743 : :
2744 : : /* Create Crypto session */
2745 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2746 : : &ut_params->cipher_xform, ts_params->session_mpool);
2747 : :
2748 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2749 : : return TEST_SKIPPED;
2750 : :
2751 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2752 : : return 0;
2753 : : }
2754 : :
2755 : : static int
2756 : 0 : create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2757 : : unsigned int cipher_len,
2758 : : unsigned int cipher_offset)
2759 : : {
2760 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2761 : : struct crypto_unittest_params *ut_params = &unittest_params;
2762 : :
2763 : : /* Generate Crypto op data structure */
2764 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2765 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2766 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
2767 : : "Failed to allocate pktmbuf offload");
2768 : :
2769 : : /* Set crypto operation data parameters */
2770 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2771 : :
2772 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2773 : :
2774 : : /* set crypto operation source mbuf */
2775 : 0 : sym_op->m_src = ut_params->ibuf;
2776 : :
2777 : : /* iv */
2778 [ # # ]: 0 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2779 : : iv, iv_len);
2780 : 0 : sym_op->cipher.data.length = cipher_len;
2781 : 0 : sym_op->cipher.data.offset = cipher_offset;
2782 : 0 : return 0;
2783 : : }
2784 : :
2785 : : static int
2786 : 0 : create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2787 : : unsigned int cipher_len,
2788 : : unsigned int cipher_offset)
2789 : : {
2790 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2791 : : struct crypto_unittest_params *ut_params = &unittest_params;
2792 : :
2793 : : /* Generate Crypto op data structure */
2794 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2795 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2796 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
2797 : : "Failed to allocate pktmbuf offload");
2798 : :
2799 : : /* Set crypto operation data parameters */
2800 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2801 : :
2802 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2803 : :
2804 : : /* set crypto operation source mbuf */
2805 : 0 : sym_op->m_src = ut_params->ibuf;
2806 : 0 : sym_op->m_dst = ut_params->obuf;
2807 : :
2808 : : /* iv */
2809 [ # # ]: 0 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2810 : : iv, iv_len);
2811 : 0 : sym_op->cipher.data.length = cipher_len;
2812 : 0 : sym_op->cipher.data.offset = cipher_offset;
2813 : 0 : return 0;
2814 : : }
2815 : :
2816 : : static int
2817 : 1 : create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2818 : : enum rte_crypto_cipher_operation cipher_op,
2819 : : enum rte_crypto_auth_operation auth_op,
2820 : : enum rte_crypto_auth_algorithm auth_algo,
2821 : : enum rte_crypto_cipher_algorithm cipher_algo,
2822 : : const uint8_t *a_key, uint8_t a_key_len,
2823 : : const uint8_t *c_key, uint8_t c_key_len,
2824 : : uint8_t auth_iv_len, uint8_t auth_len,
2825 : : uint8_t cipher_iv_len)
2826 : :
2827 : : {
2828 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2829 : : struct crypto_unittest_params *ut_params = &unittest_params;
2830 : :
2831 : : /* Setup Authentication Parameters */
2832 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2833 : 1 : ut_params->auth_xform.next = NULL;
2834 : :
2835 : 1 : ut_params->auth_xform.auth.op = auth_op;
2836 : 1 : ut_params->auth_xform.auth.algo = auth_algo;
2837 : 1 : ut_params->auth_xform.auth.key.length = a_key_len;
2838 : 1 : ut_params->auth_xform.auth.key.data = a_key;
2839 : 1 : ut_params->auth_xform.auth.digest_length = auth_len;
2840 : : /* Auth IV will be after cipher IV */
2841 : 1 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2842 : 1 : ut_params->auth_xform.auth.iv.length = auth_iv_len;
2843 : :
2844 : : /* Setup Cipher Parameters */
2845 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2846 : 1 : ut_params->cipher_xform.next = &ut_params->auth_xform;
2847 : :
2848 : 1 : ut_params->cipher_xform.cipher.algo = cipher_algo;
2849 : 1 : ut_params->cipher_xform.cipher.op = cipher_op;
2850 : 1 : ut_params->cipher_xform.cipher.key.data = c_key;
2851 : 1 : ut_params->cipher_xform.cipher.key.length = c_key_len;
2852 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2853 : 1 : ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2854 : :
2855 : 1 : debug_hexdump(stdout, "Auth key:", a_key, c_key_len);
2856 : 1 : debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
2857 : :
2858 : : /* Create Crypto session*/
2859 : 1 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2860 : : &ut_params->cipher_xform, ts_params->session_mpool);
2861 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2862 : : return TEST_SKIPPED;
2863 : :
2864 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2865 : : return 0;
2866 : : }
2867 : :
2868 : : static int
2869 : 0 : create_wireless_cipher_auth_session(uint8_t dev_id,
2870 : : enum rte_crypto_cipher_operation cipher_op,
2871 : : enum rte_crypto_auth_operation auth_op,
2872 : : enum rte_crypto_auth_algorithm auth_algo,
2873 : : enum rte_crypto_cipher_algorithm cipher_algo,
2874 : : const struct wireless_test_data *tdata)
2875 : 0 : {
2876 : 0 : const uint8_t key_len = tdata->key.len;
2877 : 0 : uint8_t cipher_auth_key[key_len];
2878 : :
2879 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2880 : : struct crypto_unittest_params *ut_params = &unittest_params;
2881 : 0 : const uint8_t *key = tdata->key.data;
2882 : 0 : const uint8_t auth_len = tdata->digest.len;
2883 : 0 : uint8_t cipher_iv_len = tdata->cipher_iv.len;
2884 : 0 : uint8_t auth_iv_len = tdata->auth_iv.len;
2885 : :
2886 : : memcpy(cipher_auth_key, key, key_len);
2887 : :
2888 : : /* Setup Authentication Parameters */
2889 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2890 : 0 : ut_params->auth_xform.next = NULL;
2891 : :
2892 : 0 : ut_params->auth_xform.auth.op = auth_op;
2893 : 0 : ut_params->auth_xform.auth.algo = auth_algo;
2894 : 0 : ut_params->auth_xform.auth.key.length = key_len;
2895 : : /* Hash key = cipher key */
2896 : 0 : ut_params->auth_xform.auth.key.data = cipher_auth_key;
2897 : 0 : ut_params->auth_xform.auth.digest_length = auth_len;
2898 : : /* Auth IV will be after cipher IV */
2899 : 0 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2900 : 0 : ut_params->auth_xform.auth.iv.length = auth_iv_len;
2901 : :
2902 : : /* Setup Cipher Parameters */
2903 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2904 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
2905 : :
2906 : 0 : ut_params->cipher_xform.cipher.algo = cipher_algo;
2907 : 0 : ut_params->cipher_xform.cipher.op = cipher_op;
2908 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2909 : 0 : ut_params->cipher_xform.cipher.key.length = key_len;
2910 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2911 : 0 : ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2912 : :
2913 : :
2914 : 0 : debug_hexdump(stdout, "key:", key, key_len);
2915 : :
2916 : : /* Create Crypto session*/
2917 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2918 : : &ut_params->cipher_xform, ts_params->session_mpool);
2919 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2920 : : return TEST_SKIPPED;
2921 : :
2922 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2923 : : return 0;
2924 : : }
2925 : :
2926 : : static int
2927 : : create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2928 : : const struct wireless_test_data *tdata)
2929 : : {
2930 : 0 : return create_wireless_cipher_auth_session(dev_id,
2931 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2932 : : RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2933 : : RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2934 : : }
2935 : :
2936 : : static int
2937 : 1 : create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2938 : : enum rte_crypto_cipher_operation cipher_op,
2939 : : enum rte_crypto_auth_operation auth_op,
2940 : : enum rte_crypto_auth_algorithm auth_algo,
2941 : : enum rte_crypto_cipher_algorithm cipher_algo,
2942 : : const uint8_t *a_key, const uint8_t a_key_len,
2943 : : const uint8_t *c_key, const uint8_t c_key_len,
2944 : : uint8_t auth_iv_len, uint8_t auth_len,
2945 : : uint8_t cipher_iv_len)
2946 : : {
2947 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
2948 : : struct crypto_unittest_params *ut_params = &unittest_params;
2949 : :
2950 : : /* Setup Authentication Parameters */
2951 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2952 : 1 : ut_params->auth_xform.auth.op = auth_op;
2953 : 1 : ut_params->auth_xform.next = &ut_params->cipher_xform;
2954 : 1 : ut_params->auth_xform.auth.algo = auth_algo;
2955 : 1 : ut_params->auth_xform.auth.key.length = a_key_len;
2956 : 1 : ut_params->auth_xform.auth.key.data = a_key;
2957 : 1 : ut_params->auth_xform.auth.digest_length = auth_len;
2958 : : /* Auth IV will be after cipher IV */
2959 : 1 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2960 : 1 : ut_params->auth_xform.auth.iv.length = auth_iv_len;
2961 : :
2962 : : /* Setup Cipher Parameters */
2963 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2964 : 1 : ut_params->cipher_xform.next = NULL;
2965 : 1 : ut_params->cipher_xform.cipher.algo = cipher_algo;
2966 : 1 : ut_params->cipher_xform.cipher.op = cipher_op;
2967 : 1 : ut_params->cipher_xform.cipher.key.data = c_key;
2968 : 1 : ut_params->cipher_xform.cipher.key.length = c_key_len;
2969 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2970 : 1 : ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2971 : :
2972 : 1 : debug_hexdump(stdout, "Auth key:", a_key, a_key_len);
2973 : 1 : debug_hexdump(stdout, "Cipher key:", c_key, c_key_len);
2974 : :
2975 : : /* Create Crypto session*/
2976 [ - + ]: 1 : if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2977 : 0 : ut_params->auth_xform.next = NULL;
2978 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
2979 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2980 : : &ut_params->cipher_xform, ts_params->session_mpool);
2981 : : } else
2982 : 1 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
2983 : : &ut_params->auth_xform, ts_params->session_mpool);
2984 : :
2985 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
2986 : : return TEST_SKIPPED;
2987 : :
2988 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2989 : :
2990 : : return 0;
2991 : : }
2992 : :
2993 : : static int
2994 : 0 : create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2995 : : unsigned int auth_tag_len,
2996 : : const uint8_t *iv, unsigned int iv_len,
2997 : : unsigned int data_pad_len,
2998 : : enum rte_crypto_auth_operation op,
2999 : : unsigned int auth_len, unsigned int auth_offset)
3000 : : {
3001 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3002 : :
3003 : : struct crypto_unittest_params *ut_params = &unittest_params;
3004 : :
3005 : : /* Generate Crypto op data structure */
3006 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3007 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3008 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
3009 : : "Failed to allocate pktmbuf offload");
3010 : :
3011 : : /* Set crypto operation data parameters */
3012 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3013 : :
3014 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3015 : :
3016 : : /* set crypto operation source mbuf */
3017 : 0 : sym_op->m_src = ut_params->ibuf;
3018 : :
3019 : : /* iv */
3020 [ # # ]: 0 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
3021 : : iv, iv_len);
3022 : : /* digest */
3023 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3024 : : ut_params->ibuf, auth_tag_len);
3025 : :
3026 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3027 : : "no room to append auth tag");
3028 : 0 : ut_params->digest = sym_op->auth.digest.data;
3029 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3030 : : ut_params->ibuf, data_pad_len);
3031 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3032 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
3033 : : else
3034 [ # # ]: 0 : rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3035 : :
3036 : 0 : debug_hexdump(stdout, "digest:",
3037 : 0 : sym_op->auth.digest.data,
3038 : : auth_tag_len);
3039 : :
3040 : 0 : sym_op->auth.data.length = auth_len;
3041 : 0 : sym_op->auth.data.offset = auth_offset;
3042 : :
3043 : 0 : return 0;
3044 : : }
3045 : :
3046 : : static int
3047 : 0 : create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
3048 : : enum rte_crypto_auth_operation op)
3049 : : {
3050 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3051 : : struct crypto_unittest_params *ut_params = &unittest_params;
3052 : :
3053 : 0 : const uint8_t *auth_tag = tdata->digest.data;
3054 : 0 : const unsigned int auth_tag_len = tdata->digest.len;
3055 [ # # ]: 0 : unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
3056 : 0 : unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3057 : :
3058 : 0 : const uint8_t *cipher_iv = tdata->cipher_iv.data;
3059 : 0 : const uint8_t cipher_iv_len = tdata->cipher_iv.len;
3060 : 0 : const uint8_t *auth_iv = tdata->auth_iv.data;
3061 : 0 : const uint8_t auth_iv_len = tdata->auth_iv.len;
3062 : 0 : const unsigned int cipher_len = tdata->validCipherLenInBits.len;
3063 : 0 : const unsigned int auth_len = tdata->validAuthLenInBits.len;
3064 : :
3065 : : /* Generate Crypto op data structure */
3066 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3067 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3068 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
3069 : : "Failed to allocate pktmbuf offload");
3070 : : /* Set crypto operation data parameters */
3071 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3072 : :
3073 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3074 : :
3075 : : /* set crypto operation source mbuf */
3076 : 0 : sym_op->m_src = ut_params->ibuf;
3077 : :
3078 : : /* digest */
3079 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3080 : : ut_params->ibuf, auth_tag_len);
3081 : :
3082 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3083 : : "no room to append auth tag");
3084 : 0 : ut_params->digest = sym_op->auth.digest.data;
3085 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3086 : : ut_params->ibuf, data_pad_len);
3087 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3088 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
3089 : : else
3090 [ # # ]: 0 : rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3091 : :
3092 : 0 : debug_hexdump(stdout, "digest:",
3093 : 0 : sym_op->auth.digest.data,
3094 : : auth_tag_len);
3095 : :
3096 : : /* Copy cipher and auth IVs at the end of the crypto operation */
3097 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3098 : : IV_OFFSET);
3099 [ # # ]: 0 : rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3100 : 0 : iv_ptr += cipher_iv_len;
3101 [ # # ]: 0 : rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3102 : :
3103 : 0 : sym_op->cipher.data.length = cipher_len;
3104 : 0 : sym_op->cipher.data.offset = 0;
3105 : 0 : sym_op->auth.data.length = auth_len;
3106 : 0 : sym_op->auth.data.offset = 0;
3107 : :
3108 : 0 : return 0;
3109 : : }
3110 : :
3111 : : static int
3112 : : create_zuc_cipher_hash_generate_operation(
3113 : : const struct wireless_test_data *tdata)
3114 : : {
3115 : 0 : return create_wireless_cipher_hash_operation(tdata,
3116 : : RTE_CRYPTO_AUTH_OP_GENERATE);
3117 : : }
3118 : :
3119 : : static int
3120 : 0 : create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
3121 : : const unsigned auth_tag_len,
3122 : : const uint8_t *auth_iv, uint8_t auth_iv_len,
3123 : : unsigned data_pad_len,
3124 : : enum rte_crypto_auth_operation op,
3125 : : const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3126 : : const unsigned cipher_len, const unsigned cipher_offset,
3127 : : const unsigned auth_len, const unsigned auth_offset)
3128 : : {
3129 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3130 : : struct crypto_unittest_params *ut_params = &unittest_params;
3131 : :
3132 : 0 : enum rte_crypto_cipher_algorithm cipher_algo =
3133 : : ut_params->cipher_xform.cipher.algo;
3134 : 0 : enum rte_crypto_auth_algorithm auth_algo =
3135 : : ut_params->auth_xform.auth.algo;
3136 : :
3137 : : /* Generate Crypto op data structure */
3138 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3139 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3140 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
3141 : : "Failed to allocate pktmbuf offload");
3142 : : /* Set crypto operation data parameters */
3143 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3144 : :
3145 : 0 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3146 : :
3147 : : /* set crypto operation source mbuf */
3148 : 0 : sym_op->m_src = ut_params->ibuf;
3149 : :
3150 : : /* digest */
3151 : 0 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3152 : : ut_params->ibuf, auth_tag_len);
3153 : :
3154 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3155 : : "no room to append auth tag");
3156 : 0 : ut_params->digest = sym_op->auth.digest.data;
3157 : :
3158 [ # # ]: 0 : if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
3159 : 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3160 : : ut_params->ibuf, data_pad_len);
3161 : : } else {
3162 : : struct rte_mbuf *m = ut_params->ibuf;
3163 : : unsigned int offset = data_pad_len;
3164 : :
3165 [ # # # # ]: 0 : while (offset > m->data_len && m->next != NULL) {
3166 : 0 : offset -= m->data_len;
3167 : : m = m->next;
3168 : : }
3169 : 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3170 : : m, offset);
3171 : : }
3172 : :
3173 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3174 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
3175 : : else
3176 [ # # ]: 0 : rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3177 : :
3178 : 0 : debug_hexdump(stdout, "digest:",
3179 : 0 : sym_op->auth.digest.data,
3180 : : auth_tag_len);
3181 : :
3182 : : /* Copy cipher and auth IVs at the end of the crypto operation */
3183 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3184 : : IV_OFFSET);
3185 [ # # ]: 0 : rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3186 : 0 : iv_ptr += cipher_iv_len;
3187 [ # # ]: 0 : rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3188 : :
3189 : 0 : if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3190 [ # # ]: 0 : cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3191 : : cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3192 : 0 : sym_op->cipher.data.length = cipher_len;
3193 : 0 : sym_op->cipher.data.offset = cipher_offset;
3194 : : } else {
3195 : 0 : sym_op->cipher.data.length = cipher_len >> 3;
3196 : 0 : sym_op->cipher.data.offset = cipher_offset >> 3;
3197 : : }
3198 : :
3199 : 0 : if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3200 [ # # # # ]: 0 : auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3201 : : auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3202 : 0 : sym_op->auth.data.length = auth_len;
3203 : 0 : sym_op->auth.data.offset = auth_offset;
3204 : : } else {
3205 : 0 : sym_op->auth.data.length = auth_len >> 3;
3206 : 0 : sym_op->auth.data.offset = auth_offset >> 3;
3207 : : }
3208 : :
3209 : : return 0;
3210 : : }
3211 : :
3212 : : static int
3213 : 2 : create_wireless_algo_auth_cipher_operation(
3214 : : const uint8_t *auth_tag, unsigned int auth_tag_len,
3215 : : const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3216 : : const uint8_t *auth_iv, uint8_t auth_iv_len,
3217 : : unsigned int data_pad_len,
3218 : : unsigned int cipher_len, unsigned int cipher_offset,
3219 : : unsigned int auth_len, unsigned int auth_offset,
3220 : : uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
3221 : : {
3222 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3223 : : struct crypto_unittest_params *ut_params = &unittest_params;
3224 : :
3225 : 2 : enum rte_crypto_cipher_algorithm cipher_algo =
3226 : : ut_params->cipher_xform.cipher.algo;
3227 : 2 : enum rte_crypto_auth_algorithm auth_algo =
3228 : : ut_params->auth_xform.auth.algo;
3229 : :
3230 : : /* Generate Crypto op data structure */
3231 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3232 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3233 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
3234 : : "Failed to allocate pktmbuf offload");
3235 : :
3236 : : /* Set crypto operation data parameters */
3237 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3238 : :
3239 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3240 : :
3241 : : /* set crypto operation mbufs */
3242 : 2 : sym_op->m_src = ut_params->ibuf;
3243 [ - + ]: 2 : if (op_mode == OUT_OF_PLACE)
3244 : 0 : sym_op->m_dst = ut_params->obuf;
3245 : :
3246 : : /* digest */
3247 [ - + ]: 2 : if (!do_sgl) {
3248 [ # # ]: 0 : sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3249 : : (op_mode == IN_PLACE ?
3250 : : ut_params->ibuf : ut_params->obuf),
3251 : : uint8_t *, data_pad_len);
3252 [ # # ]: 0 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3253 : : (op_mode == IN_PLACE ?
3254 : : ut_params->ibuf : ut_params->obuf),
3255 : : data_pad_len);
3256 : 0 : memset(sym_op->auth.digest.data, 0, auth_tag_len);
3257 : : } else {
3258 : 2 : uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3259 : : struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3260 [ - + ]: 2 : sym_op->m_src : sym_op->m_dst);
3261 [ + + ]: 32 : while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3262 : 30 : remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3263 : 30 : sgl_buf = sgl_buf->next;
3264 : : }
3265 : :
3266 : : /* The last segment should be large enough to hold full digest */
3267 [ - + ]: 2 : if (sgl_buf->data_len < auth_tag_len) {
3268 : 0 : rte_pktmbuf_free(sgl_buf->next);
3269 : 0 : sgl_buf->next = NULL;
3270 [ # # # # ]: 0 : TEST_ASSERT_NOT_NULL(rte_pktmbuf_append(sgl_buf,
3271 : : auth_tag_len - sgl_buf->data_len),
3272 : : "No room to append auth tag");
3273 : : }
3274 : :
3275 : 2 : sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3276 : : uint8_t *, remaining_off);
3277 : 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3278 : : remaining_off);
3279 : : memset(sym_op->auth.digest.data, 0, remaining_off);
3280 [ - + ]: 2 : while (sgl_buf->next != NULL) {
3281 : 0 : memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3282 : 0 : 0, rte_pktmbuf_data_len(sgl_buf));
3283 : 0 : sgl_buf = sgl_buf->next;
3284 : : }
3285 : : }
3286 : :
3287 : : /* Copy digest for the verification */
3288 [ + + ]: 2 : if (verify)
3289 : 1 : memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3290 : :
3291 : : /* Copy cipher and auth IVs at the end of the crypto operation */
3292 : 2 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3293 : : ut_params->op, uint8_t *, IV_OFFSET);
3294 : :
3295 [ - + ]: 2 : rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3296 : 2 : iv_ptr += cipher_iv_len;
3297 [ - + ]: 2 : rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3298 : :
3299 : : /* Only copy over the offset data needed from src to dst in OOP,
3300 : : * if the auth and cipher offsets are not aligned
3301 : : */
3302 [ - + ]: 2 : if (op_mode == OUT_OF_PLACE) {
3303 [ # # ]: 0 : if (cipher_offset > auth_offset)
3304 : 0 : rte_memcpy(
3305 : 0 : rte_pktmbuf_mtod_offset(
3306 : : sym_op->m_dst,
3307 : : uint8_t *, auth_offset >> 3),
3308 : 0 : rte_pktmbuf_mtod_offset(
3309 : : sym_op->m_src,
3310 : : uint8_t *, auth_offset >> 3),
3311 [ # # ]: 0 : ((cipher_offset >> 3) - (auth_offset >> 3)));
3312 : : }
3313 : :
3314 : 2 : if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3315 [ - + ]: 2 : cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3316 : : cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3317 : 0 : sym_op->cipher.data.length = cipher_len;
3318 : 0 : sym_op->cipher.data.offset = cipher_offset;
3319 : : } else {
3320 : 2 : sym_op->cipher.data.length = cipher_len >> 3;
3321 : 2 : sym_op->cipher.data.offset = cipher_offset >> 3;
3322 : : }
3323 : :
3324 : 2 : if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3325 [ + - - + ]: 2 : auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3326 : : auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3327 : 0 : sym_op->auth.data.length = auth_len;
3328 : 0 : sym_op->auth.data.offset = auth_offset;
3329 : : } else {
3330 : 2 : sym_op->auth.data.length = auth_len >> 3;
3331 : 2 : sym_op->auth.data.offset = auth_offset >> 3;
3332 : : }
3333 : :
3334 : : return 0;
3335 : : }
3336 : :
3337 : : static int
3338 : 0 : test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3339 : : {
3340 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3341 : : struct crypto_unittest_params *ut_params = &unittest_params;
3342 : :
3343 : : int retval;
3344 : : unsigned plaintext_pad_len;
3345 : : unsigned plaintext_len;
3346 : : uint8_t *plaintext;
3347 : : struct rte_cryptodev_info dev_info;
3348 : :
3349 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3350 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3351 : :
3352 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3353 [ # # ]: 0 : ((tdata->validAuthLenInBits.len % 8) != 0)) {
3354 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
3355 : 0 : return TEST_SKIPPED;
3356 : : }
3357 : :
3358 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3359 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3360 : : printf("Device doesn't support RAW data-path APIs.\n");
3361 : 0 : return TEST_SKIPPED;
3362 : : }
3363 : :
3364 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3365 : : return TEST_SKIPPED;
3366 : :
3367 : : /* Verify the capabilities */
3368 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3369 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3370 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3371 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3372 : : &cap_idx) == NULL)
3373 : : return TEST_SKIPPED;
3374 : :
3375 : : /* Create SNOW 3G session */
3376 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3377 : 0 : tdata->key.data, tdata->key.len,
3378 : 0 : tdata->auth_iv.len, tdata->digest.len,
3379 : : RTE_CRYPTO_AUTH_OP_GENERATE,
3380 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3381 [ # # ]: 0 : if (retval < 0)
3382 : : return retval;
3383 : :
3384 : : /* alloc mbuf and set payload */
3385 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3386 : :
3387 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3388 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3389 : :
3390 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3391 : : /* Append data which is padded to a multiple of */
3392 : : /* the algorithms block size */
3393 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3394 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3395 : : plaintext_pad_len);
3396 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3397 : :
3398 : : /* Create SNOW 3G operation */
3399 : 0 : retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3400 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
3401 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3402 : 0 : tdata->validAuthLenInBits.len,
3403 : : 0);
3404 [ # # ]: 0 : if (retval < 0)
3405 : : return retval;
3406 : :
3407 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3408 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3409 : : 0);
3410 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3411 : : return retval;
3412 : : } else
3413 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3414 : : ut_params->op);
3415 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3416 : : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3417 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3418 : : uint8_t *,
3419 : : plaintext_pad_len);
3420 : :
3421 : : /* Validate obuf */
3422 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
3423 : : ut_params->digest,
3424 : : tdata->digest.data,
3425 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3426 : : "SNOW 3G Generated auth tag not as expected");
3427 : :
3428 : : return 0;
3429 : : }
3430 : :
3431 : : static int
3432 : 0 : test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3433 : : {
3434 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3435 : : struct crypto_unittest_params *ut_params = &unittest_params;
3436 : :
3437 : : int retval;
3438 : : unsigned plaintext_pad_len;
3439 : : unsigned plaintext_len;
3440 : : uint8_t *plaintext;
3441 : : struct rte_cryptodev_info dev_info;
3442 : :
3443 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3444 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3445 : :
3446 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3447 [ # # ]: 0 : ((tdata->validAuthLenInBits.len % 8) != 0)) {
3448 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
3449 : 0 : return TEST_SKIPPED;
3450 : : }
3451 : :
3452 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3453 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3454 : : printf("Device doesn't support RAW data-path APIs.\n");
3455 : 0 : return TEST_SKIPPED;
3456 : : }
3457 : :
3458 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3459 : : return TEST_SKIPPED;
3460 : :
3461 : : /* Verify the capabilities */
3462 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3463 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3464 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3465 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3466 : : &cap_idx) == NULL)
3467 : : return TEST_SKIPPED;
3468 : :
3469 : : /* Create SNOW 3G session */
3470 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3471 : 0 : tdata->key.data, tdata->key.len,
3472 : 0 : tdata->auth_iv.len, tdata->digest.len,
3473 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3474 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3475 [ # # ]: 0 : if (retval < 0)
3476 : : return retval;
3477 : : /* alloc mbuf and set payload */
3478 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3479 : :
3480 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3481 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3482 : :
3483 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3484 : : /* Append data which is padded to a multiple of */
3485 : : /* the algorithms block size */
3486 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3487 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3488 : : plaintext_pad_len);
3489 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3490 : :
3491 : : /* Create SNOW 3G operation */
3492 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
3493 : 0 : tdata->digest.len,
3494 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
3495 : : plaintext_pad_len,
3496 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3497 : 0 : tdata->validAuthLenInBits.len,
3498 : : 0);
3499 [ # # ]: 0 : if (retval < 0)
3500 : : return retval;
3501 : :
3502 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3503 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3504 : : 0);
3505 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3506 : : return retval;
3507 : : } else
3508 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3509 : : ut_params->op);
3510 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3511 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3512 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3513 : : uint8_t *,
3514 : : plaintext_pad_len);
3515 : :
3516 : : /* Validate obuf */
3517 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3518 : : return 0;
3519 : : else
3520 : 0 : return -1;
3521 : :
3522 : : return 0;
3523 : : }
3524 : :
3525 : : static int
3526 : 0 : test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3527 : : {
3528 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3529 : : struct crypto_unittest_params *ut_params = &unittest_params;
3530 : :
3531 : : int retval;
3532 : : unsigned plaintext_pad_len;
3533 : : unsigned plaintext_len;
3534 : : uint8_t *plaintext;
3535 : : struct rte_cryptodev_info dev_info;
3536 : :
3537 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3538 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3539 : :
3540 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3541 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3542 : : printf("Device doesn't support RAW data-path APIs.\n");
3543 : 0 : return TEST_SKIPPED;
3544 : : }
3545 : :
3546 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3547 : : return TEST_SKIPPED;
3548 : :
3549 : : /* Verify the capabilities */
3550 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3551 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3552 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3553 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3554 : : &cap_idx) == NULL)
3555 : : return TEST_SKIPPED;
3556 : :
3557 : : /* Create KASUMI session */
3558 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3559 : 0 : tdata->key.data, tdata->key.len,
3560 : 0 : 0, tdata->digest.len,
3561 : : RTE_CRYPTO_AUTH_OP_GENERATE,
3562 : : RTE_CRYPTO_AUTH_KASUMI_F9);
3563 [ # # ]: 0 : if (retval < 0)
3564 : : return retval;
3565 : :
3566 : : /* alloc mbuf and set payload */
3567 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3568 : :
3569 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3570 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3571 : :
3572 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3573 : : /* Append data which is padded to a multiple of */
3574 : : /* the algorithms block size */
3575 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3576 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3577 : : plaintext_pad_len);
3578 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3579 : :
3580 : : /* Create KASUMI operation */
3581 : 0 : retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3582 : : NULL, 0,
3583 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3584 : 0 : tdata->plaintext.len,
3585 : : 0);
3586 [ # # ]: 0 : if (retval < 0)
3587 : : return retval;
3588 : :
3589 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3590 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3591 : : ut_params->op);
3592 [ # # ]: 0 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3593 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3594 : : 0);
3595 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3596 : : return retval;
3597 : : } else
3598 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3599 : : ut_params->op);
3600 : :
3601 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3602 : : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3603 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3604 : : uint8_t *,
3605 : : plaintext_pad_len);
3606 : :
3607 : : /* Validate obuf */
3608 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
3609 : : ut_params->digest,
3610 : : tdata->digest.data,
3611 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
3612 : : "KASUMI Generated auth tag not as expected");
3613 : :
3614 : : return 0;
3615 : : }
3616 : :
3617 : : static int
3618 : 0 : test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3619 : : {
3620 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3621 : : struct crypto_unittest_params *ut_params = &unittest_params;
3622 : :
3623 : : int retval;
3624 : : unsigned plaintext_pad_len;
3625 : : unsigned plaintext_len;
3626 : : uint8_t *plaintext;
3627 : : struct rte_cryptodev_info dev_info;
3628 : :
3629 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3630 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3631 : :
3632 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3633 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3634 : : printf("Device doesn't support RAW data-path APIs.\n");
3635 : 0 : return TEST_SKIPPED;
3636 : : }
3637 : :
3638 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3639 : : return TEST_SKIPPED;
3640 : :
3641 : : /* Verify the capabilities */
3642 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3643 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3644 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3645 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3646 : : &cap_idx) == NULL)
3647 : : return TEST_SKIPPED;
3648 : :
3649 : : /* Create KASUMI session */
3650 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3651 : 0 : tdata->key.data, tdata->key.len,
3652 : 0 : 0, tdata->digest.len,
3653 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3654 : : RTE_CRYPTO_AUTH_KASUMI_F9);
3655 [ # # ]: 0 : if (retval < 0)
3656 : : return retval;
3657 : : /* alloc mbuf and set payload */
3658 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3659 : :
3660 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3661 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3662 : :
3663 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3664 : : /* Append data which is padded to a multiple */
3665 : : /* of the algorithms block size */
3666 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3667 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3668 : : plaintext_pad_len);
3669 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3670 : :
3671 : : /* Create KASUMI operation */
3672 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
3673 : 0 : tdata->digest.len,
3674 : : NULL, 0,
3675 : : plaintext_pad_len,
3676 : : RTE_CRYPTO_AUTH_OP_VERIFY,
3677 : 0 : tdata->plaintext.len,
3678 : : 0);
3679 [ # # ]: 0 : if (retval < 0)
3680 : : return retval;
3681 : :
3682 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3683 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
3684 : : 0);
3685 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3686 : : return retval;
3687 : : } else
3688 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3689 : : ut_params->op);
3690 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3691 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
3692 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
3693 : : uint8_t *,
3694 : : plaintext_pad_len);
3695 : :
3696 : : /* Validate obuf */
3697 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3698 : : return 0;
3699 : : else
3700 : 0 : return -1;
3701 : :
3702 : : return 0;
3703 : : }
3704 : :
3705 : : static int
3706 : 0 : test_snow3g_hash_generate_test_case_1(void)
3707 : : {
3708 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_1);
3709 : : }
3710 : :
3711 : : static int
3712 : 0 : test_snow3g_hash_generate_test_case_2(void)
3713 : : {
3714 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_2);
3715 : : }
3716 : :
3717 : : static int
3718 : 0 : test_snow3g_hash_generate_test_case_3(void)
3719 : : {
3720 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_3);
3721 : : }
3722 : :
3723 : : static int
3724 : 0 : test_snow3g_hash_generate_test_case_4(void)
3725 : : {
3726 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_4);
3727 : : }
3728 : :
3729 : : static int
3730 : 0 : test_snow3g_hash_generate_test_case_5(void)
3731 : : {
3732 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_5);
3733 : : }
3734 : :
3735 : : static int
3736 : 0 : test_snow3g_hash_generate_test_case_6(void)
3737 : : {
3738 : 0 : return test_snow3g_authentication(&snow3g_hash_test_case_6);
3739 : : }
3740 : :
3741 : : static int
3742 : 0 : test_snow3g_hash_verify_test_case_1(void)
3743 : : {
3744 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3745 : :
3746 : : }
3747 : :
3748 : : static int
3749 : 0 : test_snow3g_hash_verify_test_case_2(void)
3750 : : {
3751 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3752 : : }
3753 : :
3754 : : static int
3755 : 0 : test_snow3g_hash_verify_test_case_3(void)
3756 : : {
3757 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3758 : : }
3759 : :
3760 : : static int
3761 : 0 : test_snow3g_hash_verify_test_case_4(void)
3762 : : {
3763 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3764 : : }
3765 : :
3766 : : static int
3767 : 0 : test_snow3g_hash_verify_test_case_5(void)
3768 : : {
3769 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3770 : : }
3771 : :
3772 : : static int
3773 : 0 : test_snow3g_hash_verify_test_case_6(void)
3774 : : {
3775 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3776 : : }
3777 : :
3778 : : static int
3779 : 0 : test_kasumi_hash_generate_test_case_1(void)
3780 : : {
3781 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_1);
3782 : : }
3783 : :
3784 : : static int
3785 : 0 : test_kasumi_hash_generate_test_case_2(void)
3786 : : {
3787 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_2);
3788 : : }
3789 : :
3790 : : static int
3791 : 0 : test_kasumi_hash_generate_test_case_3(void)
3792 : : {
3793 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_3);
3794 : : }
3795 : :
3796 : : static int
3797 : 0 : test_kasumi_hash_generate_test_case_4(void)
3798 : : {
3799 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_4);
3800 : : }
3801 : :
3802 : : static int
3803 : 0 : test_kasumi_hash_generate_test_case_5(void)
3804 : : {
3805 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_5);
3806 : : }
3807 : :
3808 : : static int
3809 : 0 : test_kasumi_hash_generate_test_case_6(void)
3810 : : {
3811 : 0 : return test_kasumi_authentication(&kasumi_hash_test_case_6);
3812 : : }
3813 : :
3814 : : static int
3815 : 0 : test_kasumi_hash_verify_test_case_1(void)
3816 : : {
3817 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3818 : : }
3819 : :
3820 : : static int
3821 : 0 : test_kasumi_hash_verify_test_case_2(void)
3822 : : {
3823 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3824 : : }
3825 : :
3826 : : static int
3827 : 0 : test_kasumi_hash_verify_test_case_3(void)
3828 : : {
3829 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3830 : : }
3831 : :
3832 : : static int
3833 : 0 : test_kasumi_hash_verify_test_case_4(void)
3834 : : {
3835 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3836 : : }
3837 : :
3838 : : static int
3839 : 0 : test_kasumi_hash_verify_test_case_5(void)
3840 : : {
3841 : 0 : return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3842 : : }
3843 : :
3844 : : static int
3845 : 0 : test_kasumi_encryption(const struct kasumi_test_data *tdata)
3846 : : {
3847 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3848 : : struct crypto_unittest_params *ut_params = &unittest_params;
3849 : :
3850 : : int retval;
3851 : : uint8_t *plaintext, *ciphertext;
3852 : : unsigned plaintext_pad_len;
3853 : : unsigned plaintext_len;
3854 : : struct rte_cryptodev_info dev_info;
3855 : :
3856 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3857 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3858 : :
3859 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3860 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3861 : : printf("Device doesn't support RAW data-path APIs.\n");
3862 : 0 : return TEST_SKIPPED;
3863 : : }
3864 : :
3865 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3866 : : return TEST_SKIPPED;
3867 : :
3868 : : /* Verify the capabilities */
3869 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3870 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3871 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3872 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3873 : : &cap_idx) == NULL)
3874 : : return TEST_SKIPPED;
3875 : :
3876 : : /* Create KASUMI session */
3877 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3878 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3879 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
3880 : 0 : tdata->key.data, tdata->key.len,
3881 : 0 : tdata->cipher_iv.len);
3882 [ # # ]: 0 : if (retval < 0)
3883 : : return retval;
3884 : :
3885 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3886 : :
3887 : : /* Clear mbuf payload */
3888 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3889 : : rte_pktmbuf_tailroom(ut_params->ibuf));
3890 : :
3891 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3892 : : /* Append data which is padded to a multiple */
3893 : : /* of the algorithms block size */
3894 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3895 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3896 : : plaintext_pad_len);
3897 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3898 : :
3899 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3900 : :
3901 : : /* Create KASUMI operation */
3902 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3903 : 0 : tdata->cipher_iv.len,
3904 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3905 : 0 : tdata->validCipherOffsetInBits.len);
3906 [ # # ]: 0 : if (retval < 0)
3907 : : return retval;
3908 : :
3909 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
3910 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
3911 : 0 : tdata->cipher_iv.len);
3912 [ # # ]: 0 : if (retval != TEST_SUCCESS)
3913 : : return retval;
3914 : : } else
3915 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3916 : : ut_params->op);
3917 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3918 : :
3919 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
3920 [ # # ]: 0 : if (ut_params->obuf)
3921 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3922 : : else
3923 : 0 : ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3924 : :
3925 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3926 : :
3927 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3928 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
3929 : : /* Validate obuf */
3930 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
3931 : : ciphertext,
3932 : : reference_ciphertext,
3933 : : tdata->validCipherLenInBits.len,
3934 : : "KASUMI Ciphertext data not as expected");
3935 : : return 0;
3936 : : }
3937 : :
3938 : : static int
3939 : 0 : test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3940 : : {
3941 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
3942 : : struct crypto_unittest_params *ut_params = &unittest_params;
3943 : :
3944 : : int retval;
3945 : :
3946 : : unsigned int plaintext_pad_len;
3947 : : unsigned int plaintext_len;
3948 : :
3949 : : uint8_t buffer[10000];
3950 : : const uint8_t *ciphertext;
3951 : :
3952 : : struct rte_cryptodev_info dev_info;
3953 : :
3954 : : /* Verify the capabilities */
3955 : : struct rte_cryptodev_sym_capability_idx cap_idx;
3956 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3957 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3958 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3959 : : &cap_idx) == NULL)
3960 : : return TEST_SKIPPED;
3961 : :
3962 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3963 : :
3964 : 0 : uint64_t feat_flags = dev_info.feature_flags;
3965 : :
3966 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3967 : : printf("Device doesn't support in-place scatter-gather. "
3968 : : "Test Skipped.\n");
3969 : 0 : return TEST_SKIPPED;
3970 : : }
3971 : :
3972 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3973 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3974 : : printf("Device doesn't support RAW data-path APIs.\n");
3975 : 0 : return TEST_SKIPPED;
3976 : : }
3977 : :
3978 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3979 : : return TEST_SKIPPED;
3980 : :
3981 : : /* Create KASUMI session */
3982 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3983 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3984 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
3985 : 0 : tdata->key.data, tdata->key.len,
3986 : 0 : tdata->cipher_iv.len);
3987 [ # # ]: 0 : if (retval < 0)
3988 : : return retval;
3989 : :
3990 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
3991 : :
3992 : :
3993 : : /* Append data which is padded to a multiple */
3994 : : /* of the algorithms block size */
3995 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3996 : :
3997 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3998 : : plaintext_pad_len, 10, 0);
3999 : :
4000 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4001 : :
4002 : : /* Create KASUMI operation */
4003 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4004 : 0 : tdata->cipher_iv.len,
4005 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4006 : 0 : tdata->validCipherOffsetInBits.len);
4007 [ # # ]: 0 : if (retval < 0)
4008 : : return retval;
4009 : :
4010 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4011 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4012 : 0 : tdata->cipher_iv.len);
4013 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4014 : : return retval;
4015 : : } else
4016 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4017 : : ut_params->op);
4018 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4019 : :
4020 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4021 : :
4022 [ # # ]: 0 : if (ut_params->obuf)
4023 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4024 : : plaintext_len, buffer);
4025 : : else
4026 : 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4027 [ # # ]: 0 : tdata->validCipherOffsetInBits.len >> 3,
4028 : : plaintext_len, buffer);
4029 : :
4030 : : /* Validate obuf */
4031 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4032 : :
4033 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4034 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4035 : : /* Validate obuf */
4036 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4037 : : ciphertext,
4038 : : reference_ciphertext,
4039 : : tdata->validCipherLenInBits.len,
4040 : : "KASUMI Ciphertext data not as expected");
4041 : : return 0;
4042 : : }
4043 : :
4044 : : static int
4045 : 0 : test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
4046 : : {
4047 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4048 : : struct crypto_unittest_params *ut_params = &unittest_params;
4049 : :
4050 : : int retval;
4051 : : uint8_t *plaintext, *ciphertext;
4052 : : unsigned plaintext_pad_len;
4053 : : unsigned plaintext_len;
4054 : :
4055 : : /* Verify the capabilities */
4056 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4057 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4058 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4059 : : /* Data-path service does not support OOP */
4060 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4061 : : &cap_idx) == NULL)
4062 : : return TEST_SKIPPED;
4063 : :
4064 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4065 : : return TEST_SKIPPED;
4066 : :
4067 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4068 : : return TEST_SKIPPED;
4069 : :
4070 : : /* Create KASUMI session */
4071 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4072 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4073 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4074 : 0 : tdata->key.data, tdata->key.len,
4075 : 0 : tdata->cipher_iv.len);
4076 [ # # ]: 0 : if (retval < 0)
4077 : : return retval;
4078 : :
4079 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4080 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4081 : :
4082 : : /* Clear mbuf payload */
4083 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4084 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
4085 : :
4086 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4087 : : /* Append data which is padded to a multiple */
4088 : : /* of the algorithms block size */
4089 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4090 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4091 : : plaintext_pad_len);
4092 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4093 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4094 : :
4095 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4096 : :
4097 : : /* Create KASUMI operation */
4098 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4099 : 0 : tdata->cipher_iv.len,
4100 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4101 : 0 : tdata->validCipherOffsetInBits.len);
4102 [ # # ]: 0 : if (retval < 0)
4103 : : return retval;
4104 : :
4105 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4106 : : ut_params->op);
4107 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4108 : :
4109 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4110 [ # # ]: 0 : if (ut_params->obuf)
4111 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4112 : : else
4113 : 0 : ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
4114 : :
4115 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4116 : :
4117 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4118 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4119 : : /* Validate obuf */
4120 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4121 : : ciphertext,
4122 : : reference_ciphertext,
4123 : : tdata->validCipherLenInBits.len,
4124 : : "KASUMI Ciphertext data not as expected");
4125 : : return 0;
4126 : : }
4127 : :
4128 : : static int
4129 : 0 : test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
4130 : : {
4131 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4132 : : struct crypto_unittest_params *ut_params = &unittest_params;
4133 : :
4134 : : int retval;
4135 : : unsigned int plaintext_pad_len;
4136 : : unsigned int plaintext_len;
4137 : :
4138 : : const uint8_t *ciphertext;
4139 : : uint8_t buffer[2048];
4140 : :
4141 : : struct rte_cryptodev_info dev_info;
4142 : :
4143 : : /* Verify the capabilities */
4144 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4145 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4146 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4147 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4148 : : &cap_idx) == NULL)
4149 : : return TEST_SKIPPED;
4150 : :
4151 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4152 : : return TEST_SKIPPED;
4153 : :
4154 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4155 : : return TEST_SKIPPED;
4156 : :
4157 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4158 : :
4159 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4160 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4161 : : printf("Device doesn't support out-of-place scatter-gather "
4162 : : "in both input and output mbufs. "
4163 : : "Test Skipped.\n");
4164 : 0 : return TEST_SKIPPED;
4165 : : }
4166 : :
4167 : : /* Create KASUMI session */
4168 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4169 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4170 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4171 : 0 : tdata->key.data, tdata->key.len,
4172 : 0 : tdata->cipher_iv.len);
4173 [ # # ]: 0 : if (retval < 0)
4174 : : return retval;
4175 : :
4176 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4177 : : /* Append data which is padded to a multiple */
4178 : : /* of the algorithms block size */
4179 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4180 : :
4181 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4182 : : plaintext_pad_len, 10, 0);
4183 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4184 : : plaintext_pad_len, 3, 0);
4185 : :
4186 : : /* Append data which is padded to a multiple */
4187 : : /* of the algorithms block size */
4188 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4189 : :
4190 : : /* Create KASUMI operation */
4191 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4192 : 0 : tdata->cipher_iv.len,
4193 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4194 : 0 : tdata->validCipherOffsetInBits.len);
4195 [ # # ]: 0 : if (retval < 0)
4196 : : return retval;
4197 : :
4198 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4199 : : ut_params->op);
4200 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4201 : :
4202 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4203 [ # # ]: 0 : if (ut_params->obuf)
4204 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4205 : : plaintext_pad_len, buffer);
4206 : : else
4207 : 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4208 [ # # ]: 0 : tdata->validCipherOffsetInBits.len >> 3,
4209 : : plaintext_pad_len, buffer);
4210 : :
4211 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4212 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4213 : : /* Validate obuf */
4214 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4215 : : ciphertext,
4216 : : reference_ciphertext,
4217 : : tdata->validCipherLenInBits.len,
4218 : : "KASUMI Ciphertext data not as expected");
4219 : : return 0;
4220 : : }
4221 : :
4222 : :
4223 : : static int
4224 : 0 : test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
4225 : : {
4226 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4227 : : struct crypto_unittest_params *ut_params = &unittest_params;
4228 : :
4229 : : int retval;
4230 : : uint8_t *ciphertext, *plaintext;
4231 : : unsigned ciphertext_pad_len;
4232 : : unsigned ciphertext_len;
4233 : :
4234 : : /* Verify the capabilities */
4235 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4236 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4237 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4238 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4239 : : &cap_idx) == NULL)
4240 : : return TEST_SKIPPED;
4241 : :
4242 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4243 : : return TEST_SKIPPED;
4244 : :
4245 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4246 : : return TEST_SKIPPED;
4247 : :
4248 : : /* Create KASUMI session */
4249 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4250 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
4251 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4252 : 0 : tdata->key.data, tdata->key.len,
4253 : 0 : tdata->cipher_iv.len);
4254 [ # # ]: 0 : if (retval < 0)
4255 : : return retval;
4256 : :
4257 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4258 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4259 : :
4260 : : /* Clear mbuf payload */
4261 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4262 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
4263 : :
4264 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4265 : : /* Append data which is padded to a multiple */
4266 : : /* of the algorithms block size */
4267 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4268 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4269 : : ciphertext_pad_len);
4270 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4271 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4272 : :
4273 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4274 : :
4275 : : /* Create KASUMI operation */
4276 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4277 : 0 : tdata->cipher_iv.len,
4278 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4279 : 0 : tdata->validCipherOffsetInBits.len);
4280 [ # # ]: 0 : if (retval < 0)
4281 : : return retval;
4282 : :
4283 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4284 : : ut_params->op);
4285 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4286 : :
4287 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4288 [ # # ]: 0 : if (ut_params->obuf)
4289 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4290 : : else
4291 : 0 : plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4292 : :
4293 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4294 : :
4295 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
4296 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4297 : : /* Validate obuf */
4298 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4299 : : plaintext,
4300 : : reference_plaintext,
4301 : : tdata->validCipherLenInBits.len,
4302 : : "KASUMI Plaintext data not as expected");
4303 : : return 0;
4304 : : }
4305 : :
4306 : : static int
4307 : 0 : test_kasumi_decryption(const struct kasumi_test_data *tdata)
4308 : : {
4309 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4310 : : struct crypto_unittest_params *ut_params = &unittest_params;
4311 : :
4312 : : int retval;
4313 : : uint8_t *ciphertext, *plaintext;
4314 : : unsigned ciphertext_pad_len;
4315 : : unsigned ciphertext_len;
4316 : : struct rte_cryptodev_info dev_info;
4317 : :
4318 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4319 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4320 : :
4321 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4322 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4323 : : printf("Device doesn't support RAW data-path APIs.\n");
4324 : 0 : return TEST_SKIPPED;
4325 : : }
4326 : :
4327 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4328 : : return TEST_SKIPPED;
4329 : :
4330 : : /* Verify the capabilities */
4331 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4332 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4333 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4334 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4335 : : &cap_idx) == NULL)
4336 : : return TEST_SKIPPED;
4337 : :
4338 : : /* Create KASUMI session */
4339 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4340 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
4341 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
4342 : 0 : tdata->key.data, tdata->key.len,
4343 : 0 : tdata->cipher_iv.len);
4344 [ # # ]: 0 : if (retval < 0)
4345 : : return retval;
4346 : :
4347 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4348 : :
4349 : : /* Clear mbuf payload */
4350 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4351 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4352 : :
4353 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4354 : : /* Append data which is padded to a multiple */
4355 : : /* of the algorithms block size */
4356 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4357 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4358 : : ciphertext_pad_len);
4359 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4360 : :
4361 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4362 : :
4363 : : /* Create KASUMI operation */
4364 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4365 : 0 : tdata->cipher_iv.len,
4366 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4367 : 0 : tdata->validCipherOffsetInBits.len);
4368 [ # # ]: 0 : if (retval < 0)
4369 : : return retval;
4370 : :
4371 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4372 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4373 : : 0);
4374 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4375 : : return retval;
4376 : : } else
4377 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4378 : : ut_params->op);
4379 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4380 : :
4381 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4382 [ # # ]: 0 : if (ut_params->obuf)
4383 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4384 : : else
4385 : 0 : plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4386 : :
4387 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4388 : :
4389 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
4390 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
4391 : : /* Validate obuf */
4392 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4393 : : plaintext,
4394 : : reference_plaintext,
4395 : : tdata->validCipherLenInBits.len,
4396 : : "KASUMI Plaintext data not as expected");
4397 : : return 0;
4398 : : }
4399 : :
4400 : : static int
4401 : 0 : test_snow3g_encryption(const struct snow3g_test_data *tdata)
4402 : : {
4403 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4404 : : struct crypto_unittest_params *ut_params = &unittest_params;
4405 : :
4406 : : int retval;
4407 : : uint8_t *plaintext, *ciphertext;
4408 : : unsigned plaintext_pad_len;
4409 : : unsigned plaintext_len;
4410 : : struct rte_cryptodev_info dev_info;
4411 : :
4412 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4413 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4414 : :
4415 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4416 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4417 : : printf("Device doesn't support RAW data-path APIs.\n");
4418 : 0 : return TEST_SKIPPED;
4419 : : }
4420 : :
4421 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4422 : : return TEST_SKIPPED;
4423 : :
4424 : : /* Verify the capabilities */
4425 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4426 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4427 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4428 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4429 : : &cap_idx) == NULL)
4430 : : return TEST_SKIPPED;
4431 : :
4432 : : /* Create SNOW 3G session */
4433 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4434 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4435 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4436 : 0 : tdata->key.data, tdata->key.len,
4437 : 0 : tdata->cipher_iv.len);
4438 [ # # ]: 0 : if (retval < 0)
4439 : : return retval;
4440 : :
4441 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4442 : :
4443 : : /* Clear mbuf payload */
4444 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4445 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4446 : :
4447 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4448 : : /* Append data which is padded to a multiple of */
4449 : : /* the algorithms block size */
4450 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4451 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4452 : : plaintext_pad_len);
4453 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4454 : :
4455 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4456 : :
4457 : : /* Create SNOW 3G operation */
4458 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4459 : 0 : tdata->cipher_iv.len,
4460 : 0 : tdata->validCipherLenInBits.len,
4461 : : 0);
4462 [ # # ]: 0 : if (retval < 0)
4463 : : return retval;
4464 : :
4465 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4466 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4467 : 0 : tdata->cipher_iv.len);
4468 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4469 : : return retval;
4470 : : } else
4471 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4472 : : ut_params->op);
4473 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4474 : :
4475 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4476 [ # # ]: 0 : if (ut_params->obuf)
4477 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4478 : : else
4479 : : ciphertext = plaintext;
4480 : :
4481 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4482 : :
4483 : : /* Validate obuf */
4484 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4485 : : ciphertext,
4486 : : tdata->ciphertext.data,
4487 : : tdata->validDataLenInBits.len,
4488 : : "SNOW 3G Ciphertext data not as expected");
4489 : : return 0;
4490 : : }
4491 : :
4492 : :
4493 : : static int
4494 : 0 : test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4495 : : {
4496 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4497 : : struct crypto_unittest_params *ut_params = &unittest_params;
4498 : : uint8_t *plaintext, *ciphertext;
4499 : :
4500 : : int retval;
4501 : : unsigned plaintext_pad_len;
4502 : : unsigned plaintext_len;
4503 : : struct rte_cryptodev_info dev_info;
4504 : :
4505 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4506 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4507 : :
4508 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4509 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4510 : : printf("Device does not support RAW data-path APIs.\n");
4511 : 0 : return -ENOTSUP;
4512 : : }
4513 : :
4514 : : /* Verify the capabilities */
4515 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4516 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4517 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4518 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4519 : : &cap_idx) == NULL)
4520 : : return TEST_SKIPPED;
4521 : :
4522 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4523 : : return TEST_SKIPPED;
4524 : :
4525 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4526 : : return TEST_SKIPPED;
4527 : :
4528 : : /* Create SNOW 3G session */
4529 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4530 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4531 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4532 : 0 : tdata->key.data, tdata->key.len,
4533 : 0 : tdata->cipher_iv.len);
4534 [ # # ]: 0 : if (retval < 0)
4535 : : return retval;
4536 : :
4537 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4538 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4539 : :
4540 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4541 : : "Failed to allocate input buffer in mempool");
4542 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
4543 : : "Failed to allocate output buffer in mempool");
4544 : :
4545 : : /* Clear mbuf payload */
4546 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4547 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4548 : :
4549 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4550 : : /* Append data which is padded to a multiple of */
4551 : : /* the algorithms block size */
4552 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4553 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4554 : : plaintext_pad_len);
4555 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4556 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4557 : :
4558 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4559 : :
4560 : : /* Create SNOW 3G operation */
4561 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4562 : 0 : tdata->cipher_iv.len,
4563 : 0 : tdata->validCipherLenInBits.len,
4564 : : 0);
4565 [ # # ]: 0 : if (retval < 0)
4566 : : return retval;
4567 : :
4568 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4569 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4570 : 0 : tdata->cipher_iv.len);
4571 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4572 : : return retval;
4573 : : } else
4574 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4575 : : ut_params->op);
4576 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4577 : :
4578 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4579 [ # # ]: 0 : if (ut_params->obuf)
4580 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4581 : : else
4582 : : ciphertext = plaintext;
4583 : :
4584 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4585 : :
4586 : : /* Validate obuf */
4587 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4588 : : ciphertext,
4589 : : tdata->ciphertext.data,
4590 : : tdata->validDataLenInBits.len,
4591 : : "SNOW 3G Ciphertext data not as expected");
4592 : : return 0;
4593 : : }
4594 : :
4595 : : static int
4596 : 0 : test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata,
4597 : : uint8_t sgl_in, uint8_t sgl_out)
4598 : : {
4599 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4600 : : struct crypto_unittest_params *ut_params = &unittest_params;
4601 : :
4602 : : int retval;
4603 : : unsigned int plaintext_pad_len;
4604 : : unsigned int plaintext_len;
4605 : : uint8_t buffer[10000];
4606 : : const uint8_t *ciphertext;
4607 : :
4608 : : struct rte_cryptodev_info dev_info;
4609 : :
4610 : : /* Verify the capabilities */
4611 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4612 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4613 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4614 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4615 : : &cap_idx) == NULL)
4616 : : return TEST_SKIPPED;
4617 : :
4618 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4619 : : return TEST_SKIPPED;
4620 : :
4621 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4622 : : return TEST_SKIPPED;
4623 : :
4624 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4625 : :
4626 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4627 : :
4628 [ # # # # ]: 0 : if (((sgl_in && sgl_out) && !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
4629 [ # # ]: 0 : || ((!sgl_in && sgl_out) &&
4630 [ # # ]: 0 : !(feat_flags & RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
4631 [ # # ]: 0 : || ((sgl_in && !sgl_out) &&
4632 [ # # ]: 0 : !(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))) {
4633 : : printf("Device doesn't support out-of-place scatter gather type. "
4634 : : "Test Skipped.\n");
4635 : 0 : return TEST_SKIPPED;
4636 : : }
4637 : :
4638 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4639 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4640 : : printf("Device does not support RAW data-path APIs.\n");
4641 : 0 : return -ENOTSUP;
4642 : : }
4643 : :
4644 : : /* Create SNOW 3G session */
4645 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4646 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4647 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4648 : 0 : tdata->key.data, tdata->key.len,
4649 : 0 : tdata->cipher_iv.len);
4650 [ # # ]: 0 : if (retval < 0)
4651 : : return retval;
4652 : :
4653 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
4654 : : /* Append data which is padded to a multiple of */
4655 : : /* the algorithms block size */
4656 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4657 : :
4658 [ # # ]: 0 : if (sgl_in)
4659 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4660 : : plaintext_pad_len, 10, 0);
4661 : : else {
4662 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4663 : : rte_pktmbuf_append(ut_params->ibuf, plaintext_pad_len);
4664 : : }
4665 : :
4666 [ # # ]: 0 : if (sgl_out)
4667 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4668 : : plaintext_pad_len, 3, 0);
4669 : : else {
4670 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4671 : : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4672 : : }
4673 : :
4674 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4675 : : "Failed to allocate input buffer in mempool");
4676 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
4677 : : "Failed to allocate output buffer in mempool");
4678 : :
4679 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4680 : :
4681 : : /* Create SNOW 3G operation */
4682 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4683 : 0 : tdata->cipher_iv.len,
4684 : 0 : tdata->validCipherLenInBits.len,
4685 : : 0);
4686 [ # # ]: 0 : if (retval < 0)
4687 : : return retval;
4688 : :
4689 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4690 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4691 : 0 : tdata->cipher_iv.len);
4692 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4693 : : return retval;
4694 : : } else
4695 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4696 : : ut_params->op);
4697 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4698 : :
4699 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4700 [ # # ]: 0 : if (ut_params->obuf)
4701 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4702 : : plaintext_len, buffer);
4703 : : else
4704 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4705 : : plaintext_len, buffer);
4706 : :
4707 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4708 : :
4709 : : /* Validate obuf */
4710 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
4711 : : ciphertext,
4712 : : tdata->ciphertext.data,
4713 : : tdata->validDataLenInBits.len,
4714 : : "SNOW 3G Ciphertext data not as expected");
4715 : :
4716 : : return 0;
4717 : : }
4718 : :
4719 : : /* Shift right a buffer by "offset" bits, "offset" < 8 */
4720 : : static void
4721 : 0 : buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4722 : : {
4723 : : uint8_t curr_byte, prev_byte;
4724 [ # # ]: 0 : uint32_t length_in_bytes = ceil_byte_length(length + offset);
4725 : 0 : uint8_t lower_byte_mask = (1 << offset) - 1;
4726 : : unsigned i;
4727 : :
4728 : 0 : prev_byte = buffer[0];
4729 : 0 : buffer[0] >>= offset;
4730 : :
4731 [ # # ]: 0 : for (i = 1; i < length_in_bytes; i++) {
4732 : 0 : curr_byte = buffer[i];
4733 : 0 : buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4734 : 0 : (curr_byte >> offset);
4735 : : prev_byte = curr_byte;
4736 : : }
4737 : 0 : }
4738 : :
4739 : : static int
4740 : 0 : test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4741 : : {
4742 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4743 : : struct crypto_unittest_params *ut_params = &unittest_params;
4744 : : uint8_t *plaintext, *ciphertext;
4745 : : int retval;
4746 : : uint32_t plaintext_len;
4747 : : uint32_t plaintext_pad_len;
4748 : : uint8_t extra_offset = 4;
4749 : : uint8_t *expected_ciphertext_shifted;
4750 : : struct rte_cryptodev_info dev_info;
4751 : :
4752 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4753 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4754 : :
4755 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4756 [ # # ]: 0 : ((tdata->validDataLenInBits.len % 8) != 0)) {
4757 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
4758 : 0 : return TEST_SKIPPED;
4759 : : }
4760 : :
4761 : : /* Verify the capabilities */
4762 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4763 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4764 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4765 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4766 : : &cap_idx) == NULL)
4767 : : return TEST_SKIPPED;
4768 : :
4769 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4770 : : return TEST_SKIPPED;
4771 : :
4772 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4773 : : return TEST_SKIPPED;
4774 : :
4775 : : /* Create SNOW 3G session */
4776 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4777 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4778 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4779 : 0 : tdata->key.data, tdata->key.len,
4780 : 0 : tdata->cipher_iv.len);
4781 [ # # ]: 0 : if (retval < 0)
4782 : : return retval;
4783 : :
4784 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4785 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4786 : :
4787 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4788 : : "Failed to allocate input buffer in mempool");
4789 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
4790 : : "Failed to allocate output buffer in mempool");
4791 : :
4792 : : /* Clear mbuf payload */
4793 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4794 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4795 : :
4796 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4797 : : /*
4798 : : * Append data which is padded to a
4799 : : * multiple of the algorithms block size
4800 : : */
4801 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4802 : :
4803 : 0 : plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4804 : : plaintext_pad_len);
4805 : :
4806 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4807 : :
4808 : 0 : memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4809 : 0 : buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4810 : :
4811 : : #ifdef RTE_APP_TEST_DEBUG
4812 : : rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4813 : : #endif
4814 : : /* Create SNOW 3G operation */
4815 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4816 : 0 : tdata->cipher_iv.len,
4817 : 0 : tdata->validCipherLenInBits.len,
4818 : : extra_offset);
4819 [ # # ]: 0 : if (retval < 0)
4820 : : return retval;
4821 : :
4822 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4823 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4824 : 0 : tdata->cipher_iv.len);
4825 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4826 : : return retval;
4827 : : } else
4828 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4829 : : ut_params->op);
4830 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4831 : :
4832 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4833 [ # # ]: 0 : if (ut_params->obuf)
4834 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4835 : : else
4836 : : ciphertext = plaintext;
4837 : :
4838 : : #ifdef RTE_APP_TEST_DEBUG
4839 : : rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4840 : : #endif
4841 : :
4842 : 0 : expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4843 : :
4844 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4845 : : "failed to reserve memory for ciphertext shifted\n");
4846 : :
4847 : 0 : memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4848 [ # # ]: 0 : ceil_byte_length(tdata->ciphertext.len));
4849 : 0 : buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4850 : : extra_offset);
4851 : : /* Validate obuf */
4852 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # ]
4853 : : ciphertext,
4854 : : expected_ciphertext_shifted,
4855 : : tdata->validDataLenInBits.len,
4856 : : extra_offset,
4857 : : "SNOW 3G Ciphertext data not as expected");
4858 : : return 0;
4859 : : }
4860 : :
4861 : 0 : static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4862 : : {
4863 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4864 : : struct crypto_unittest_params *ut_params = &unittest_params;
4865 : :
4866 : : int retval;
4867 : :
4868 : : uint8_t *plaintext, *ciphertext;
4869 : : unsigned ciphertext_pad_len;
4870 : : unsigned ciphertext_len;
4871 : : struct rte_cryptodev_info dev_info;
4872 : :
4873 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4874 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4875 : :
4876 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4877 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4878 : : printf("Device doesn't support RAW data-path APIs.\n");
4879 : 0 : return TEST_SKIPPED;
4880 : : }
4881 : :
4882 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4883 : : return TEST_SKIPPED;
4884 : :
4885 : : /* Verify the capabilities */
4886 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4887 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4888 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4889 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4890 : : &cap_idx) == NULL)
4891 : : return TEST_SKIPPED;
4892 : :
4893 : : /* Create SNOW 3G session */
4894 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4895 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
4896 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4897 : 0 : tdata->key.data, tdata->key.len,
4898 : 0 : tdata->cipher_iv.len);
4899 [ # # ]: 0 : if (retval < 0)
4900 : : return retval;
4901 : :
4902 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4903 : :
4904 : : /* Clear mbuf payload */
4905 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4906 : : rte_pktmbuf_tailroom(ut_params->ibuf));
4907 : :
4908 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4909 : : /* Append data which is padded to a multiple of */
4910 : : /* the algorithms block size */
4911 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4912 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4913 : : ciphertext_pad_len);
4914 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4915 : :
4916 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4917 : :
4918 : : /* Create SNOW 3G operation */
4919 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4920 : 0 : tdata->cipher_iv.len,
4921 : 0 : tdata->validCipherLenInBits.len,
4922 : 0 : tdata->cipher.offset_bits);
4923 [ # # ]: 0 : if (retval < 0)
4924 : : return retval;
4925 : :
4926 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
4927 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
4928 : 0 : tdata->cipher_iv.len);
4929 [ # # ]: 0 : if (retval != TEST_SUCCESS)
4930 : : return retval;
4931 : : } else
4932 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4933 : : ut_params->op);
4934 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4935 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
4936 [ # # ]: 0 : if (ut_params->obuf)
4937 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4938 : : else
4939 : : plaintext = ciphertext;
4940 : :
4941 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4942 : :
4943 : : /* Validate obuf */
4944 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
# # ]
4945 : : tdata->plaintext.data,
4946 : : tdata->validDataLenInBits.len,
4947 : : "SNOW 3G Plaintext data not as expected");
4948 : : return 0;
4949 : : }
4950 : :
4951 : 0 : static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4952 : : {
4953 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
4954 : : struct crypto_unittest_params *ut_params = &unittest_params;
4955 : :
4956 : : int retval;
4957 : :
4958 : : uint8_t *plaintext, *ciphertext;
4959 : : unsigned ciphertext_pad_len;
4960 : : unsigned ciphertext_len;
4961 : : struct rte_cryptodev_info dev_info;
4962 : :
4963 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4964 : 0 : uint64_t feat_flags = dev_info.feature_flags;
4965 : :
4966 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4967 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4968 : : printf("Device does not support RAW data-path APIs.\n");
4969 : 0 : return -ENOTSUP;
4970 : : }
4971 : : /* Verify the capabilities */
4972 : : struct rte_cryptodev_sym_capability_idx cap_idx;
4973 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4974 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4975 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4976 : : &cap_idx) == NULL)
4977 : : return TEST_SKIPPED;
4978 : :
4979 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4980 : : return TEST_SKIPPED;
4981 : :
4982 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4983 : : return TEST_SKIPPED;
4984 : :
4985 : : /* Create SNOW 3G session */
4986 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4987 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
4988 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4989 : 0 : tdata->key.data, tdata->key.len,
4990 : 0 : tdata->cipher_iv.len);
4991 [ # # ]: 0 : if (retval < 0)
4992 : : return retval;
4993 : :
4994 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4995 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4996 : :
4997 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4998 : : "Failed to allocate input buffer");
4999 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
5000 : : "Failed to allocate output buffer");
5001 : :
5002 : : /* Clear mbuf payload */
5003 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5004 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5005 : :
5006 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5007 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
5008 : :
5009 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5010 : : /* Append data which is padded to a multiple of */
5011 : : /* the algorithms block size */
5012 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5013 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5014 : : ciphertext_pad_len);
5015 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5016 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5017 : :
5018 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
5019 : :
5020 : : /* Create SNOW 3G operation */
5021 : 0 : retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
5022 : 0 : tdata->cipher_iv.len,
5023 : 0 : tdata->validCipherLenInBits.len,
5024 : : 0);
5025 [ # # ]: 0 : if (retval < 0)
5026 : : return retval;
5027 : :
5028 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5029 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
5030 : 0 : tdata->cipher_iv.len);
5031 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5032 : : return retval;
5033 : : } else
5034 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5035 : : ut_params->op);
5036 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5037 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
5038 [ # # ]: 0 : if (ut_params->obuf)
5039 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5040 : : else
5041 : : plaintext = ciphertext;
5042 : :
5043 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
5044 : :
5045 : : /* Validate obuf */
5046 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
# # ]
5047 : : tdata->plaintext.data,
5048 : : tdata->validDataLenInBits.len,
5049 : : "SNOW 3G Plaintext data not as expected");
5050 : : return 0;
5051 : : }
5052 : :
5053 : : static int
5054 : 0 : test_zuc_cipher_auth(const struct wireless_test_data *tdata)
5055 : : {
5056 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5057 : : struct crypto_unittest_params *ut_params = &unittest_params;
5058 : :
5059 : : int retval;
5060 : :
5061 : : uint8_t *plaintext, *ciphertext;
5062 : : unsigned int plaintext_pad_len;
5063 : : unsigned int plaintext_len;
5064 : :
5065 : : struct rte_cryptodev_info dev_info;
5066 : :
5067 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5068 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5069 : :
5070 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5071 [ # # ]: 0 : ((tdata->validAuthLenInBits.len % 8 != 0) ||
5072 [ # # ]: 0 : (tdata->validDataLenInBits.len % 8 != 0))) {
5073 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
5074 : 0 : return TEST_SKIPPED;
5075 : : }
5076 : :
5077 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5078 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5079 : : printf("Device doesn't support RAW data-path APIs.\n");
5080 : 0 : return TEST_SKIPPED;
5081 : : }
5082 : :
5083 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5084 : : return TEST_SKIPPED;
5085 : :
5086 : : /* Check if device supports ZUC EEA3 */
5087 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
5088 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
5089 : : return TEST_SKIPPED;
5090 : :
5091 : : /* Check if device supports ZUC EIA3 */
5092 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
5093 : 0 : tdata->key.len, tdata->auth_iv.len,
5094 : 0 : tdata->digest.len) < 0)
5095 : : return TEST_SKIPPED;
5096 : :
5097 : : /* Create ZUC session */
5098 : 0 : retval = create_zuc_cipher_auth_encrypt_generate_session(
5099 : 0 : ts_params->valid_devs[0],
5100 : : tdata);
5101 [ # # ]: 0 : if (retval != 0)
5102 : : return retval;
5103 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5104 : :
5105 : : /* clear mbuf payload */
5106 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5107 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5108 : :
5109 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5110 : : /* Append data which is padded to a multiple of */
5111 : : /* the algorithms block size */
5112 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5113 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5114 : : plaintext_pad_len);
5115 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5116 : :
5117 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5118 : :
5119 : : /* Create ZUC operation */
5120 : : retval = create_zuc_cipher_hash_generate_operation(tdata);
5121 [ # # ]: 0 : if (retval < 0)
5122 : : return retval;
5123 : :
5124 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5125 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5126 : 0 : tdata->cipher_iv.len);
5127 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5128 : : return retval;
5129 : : } else
5130 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5131 : : ut_params->op);
5132 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5133 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
5134 [ # # ]: 0 : if (ut_params->obuf)
5135 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5136 : : else
5137 : : ciphertext = plaintext;
5138 : :
5139 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5140 : : /* Validate obuf */
5141 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
5142 : : ciphertext,
5143 : : tdata->ciphertext.data,
5144 : : tdata->validDataLenInBits.len,
5145 : : "ZUC Ciphertext data not as expected");
5146 : :
5147 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5148 : : uint8_t *,
5149 : : plaintext_pad_len);
5150 : :
5151 : : /* Validate obuf */
5152 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5153 : : ut_params->digest,
5154 : : tdata->digest.data,
5155 : : tdata->digest.len,
5156 : : "ZUC Generated auth tag not as expected");
5157 : : return 0;
5158 : : }
5159 : :
5160 : : static int
5161 : 0 : test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
5162 : : {
5163 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5164 : : struct crypto_unittest_params *ut_params = &unittest_params;
5165 : :
5166 : : int retval;
5167 : :
5168 : : uint8_t *plaintext, *ciphertext;
5169 : : unsigned plaintext_pad_len;
5170 : : unsigned plaintext_len;
5171 : : struct rte_cryptodev_info dev_info;
5172 : :
5173 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5174 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5175 : :
5176 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5177 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5178 : : printf("Device doesn't support RAW data-path APIs.\n");
5179 : 0 : return TEST_SKIPPED;
5180 : : }
5181 : :
5182 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5183 : : return TEST_SKIPPED;
5184 : :
5185 : : /* Verify the capabilities */
5186 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5187 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5188 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5189 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5190 : : &cap_idx) == NULL)
5191 : : return TEST_SKIPPED;
5192 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5193 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5194 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5195 : : &cap_idx) == NULL)
5196 : : return TEST_SKIPPED;
5197 : :
5198 : : /* Create SNOW 3G session */
5199 : 0 : retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
5200 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5201 : : RTE_CRYPTO_AUTH_OP_GENERATE,
5202 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5203 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5204 : : tdata->key.data, tdata->key.len,
5205 : 0 : tdata->key.data, tdata->key.len,
5206 : 0 : tdata->auth_iv.len, tdata->digest.len,
5207 : 0 : tdata->cipher_iv.len);
5208 [ # # ]: 0 : if (retval != 0)
5209 : : return retval;
5210 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5211 : :
5212 : : /* clear mbuf payload */
5213 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5214 : : rte_pktmbuf_tailroom(ut_params->ibuf));
5215 : :
5216 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5217 : : /* Append data which is padded to a multiple of */
5218 : : /* the algorithms block size */
5219 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5220 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5221 : : plaintext_pad_len);
5222 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5223 : :
5224 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5225 : :
5226 : : /* Create SNOW 3G operation */
5227 : 0 : retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5228 : 0 : tdata->digest.len, tdata->auth_iv.data,
5229 : 0 : tdata->auth_iv.len,
5230 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5231 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5232 : 0 : tdata->validCipherLenInBits.len,
5233 : : 0,
5234 : 0 : tdata->validAuthLenInBits.len,
5235 : : 0
5236 : : );
5237 [ # # ]: 0 : if (retval < 0)
5238 : : return retval;
5239 : :
5240 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5241 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5242 : 0 : tdata->cipher_iv.len);
5243 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5244 : : return retval;
5245 : : } else
5246 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5247 : : ut_params->op);
5248 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5249 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
5250 [ # # ]: 0 : if (ut_params->obuf)
5251 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5252 : : else
5253 : : ciphertext = plaintext;
5254 : :
5255 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5256 : : /* Validate obuf */
5257 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
5258 : : ciphertext,
5259 : : tdata->ciphertext.data,
5260 : : tdata->validDataLenInBits.len,
5261 : : "SNOW 3G Ciphertext data not as expected");
5262 : :
5263 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5264 : : uint8_t *,
5265 : : plaintext_pad_len);
5266 : :
5267 : : /* Validate obuf */
5268 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5269 : : ut_params->digest,
5270 : : tdata->digest.data,
5271 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5272 : : "SNOW 3G Generated auth tag not as expected");
5273 : : return 0;
5274 : : }
5275 : :
5276 : : static int
5277 : 0 : test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
5278 : : uint8_t op_mode, uint8_t verify)
5279 : : {
5280 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5281 : : struct crypto_unittest_params *ut_params = &unittest_params;
5282 : :
5283 : : int retval;
5284 : :
5285 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
5286 : : unsigned int plaintext_pad_len;
5287 : : unsigned int plaintext_len;
5288 : : unsigned int ciphertext_pad_len;
5289 : : unsigned int ciphertext_len;
5290 : : unsigned int digest_offset;
5291 : :
5292 : : struct rte_cryptodev_info dev_info;
5293 : :
5294 : : /* Verify the capabilities */
5295 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5296 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5297 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5298 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5299 : : &cap_idx) == NULL)
5300 : : return TEST_SKIPPED;
5301 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5302 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5303 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5304 : : &cap_idx) == NULL)
5305 : : return TEST_SKIPPED;
5306 : :
5307 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5308 : : return TEST_SKIPPED;
5309 : :
5310 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5311 : :
5312 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5313 : :
5314 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5315 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5316 : : printf("Device doesn't support digest encrypted.\n");
5317 : 0 : return TEST_SKIPPED;
5318 : : }
5319 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5320 : : return TEST_SKIPPED;
5321 : : }
5322 : :
5323 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5324 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5325 : : printf("Device doesn't support RAW data-path APIs.\n");
5326 : 0 : return TEST_SKIPPED;
5327 : : }
5328 : :
5329 : : /* Create SNOW 3G session */
5330 : 0 : retval = create_wireless_algo_auth_cipher_session(
5331 : 0 : ts_params->valid_devs[0],
5332 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5333 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5334 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5335 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5336 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5337 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5338 : : tdata->key.data, tdata->key.len,
5339 : 0 : tdata->key.data, tdata->key.len,
5340 : 0 : tdata->auth_iv.len, tdata->digest.len,
5341 : 0 : tdata->cipher_iv.len);
5342 [ # # ]: 0 : if (retval != 0)
5343 : : return retval;
5344 : :
5345 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5346 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5347 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5348 : :
5349 : : /* clear mbuf payload */
5350 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5351 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
5352 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5353 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5354 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
5355 : :
5356 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5357 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5358 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5359 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5360 : :
5361 [ # # ]: 0 : if (verify) {
5362 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5363 : : ciphertext_pad_len);
5364 [ # # ]: 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5365 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5366 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5367 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5368 : : ciphertext_len);
5369 : : } else {
5370 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5371 : : plaintext_pad_len);
5372 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5373 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5374 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5375 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5376 : : }
5377 : :
5378 : : /* Create SNOW 3G operation */
5379 : 0 : retval = create_wireless_algo_auth_cipher_operation(
5380 : 0 : tdata->digest.data, tdata->digest.len,
5381 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5382 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
5383 : 0 : (tdata->digest.offset_bytes == 0 ?
5384 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
5385 : : : tdata->digest.offset_bytes),
5386 : 0 : tdata->validCipherLenInBits.len,
5387 : 0 : tdata->cipher.offset_bits,
5388 : 0 : tdata->validAuthLenInBits.len,
5389 [ # # ]: 0 : tdata->auth.offset_bits,
5390 : : op_mode, 0, verify);
5391 : :
5392 [ # # ]: 0 : if (retval < 0)
5393 : : return retval;
5394 : :
5395 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5396 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5397 : 0 : tdata->cipher_iv.len);
5398 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5399 : : return retval;
5400 : : } else
5401 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5402 : : ut_params->op);
5403 : :
5404 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5405 : :
5406 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
5407 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5408 : :
5409 [ # # ]: 0 : if (verify) {
5410 [ # # ]: 0 : if (ut_params->obuf)
5411 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5412 : : uint8_t *);
5413 : : else
5414 : 0 : plaintext = ciphertext +
5415 : 0 : (tdata->cipher.offset_bits >> 3);
5416 : :
5417 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5418 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5419 : 0 : debug_hexdump(stdout, "plaintext expected:",
5420 : 0 : tdata->plaintext.data,
5421 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5422 : : } else {
5423 [ # # ]: 0 : if (ut_params->obuf)
5424 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5425 : : uint8_t *);
5426 : : else
5427 : : ciphertext = plaintext;
5428 : :
5429 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5430 : : ciphertext_len);
5431 : 0 : debug_hexdump(stdout, "ciphertext expected:",
5432 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5433 : :
5434 [ # # ]: 0 : if (tdata->digest.offset_bytes == 0)
5435 : : digest_offset = plaintext_pad_len;
5436 : : else
5437 : : digest_offset = tdata->digest.offset_bytes;
5438 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5439 : : uint8_t *, digest_offset);
5440 : :
5441 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
5442 : 0 : tdata->digest.len);
5443 : 0 : debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5444 : 0 : tdata->digest.len);
5445 : : }
5446 : :
5447 : : /* Validate obuf */
5448 [ # # ]: 0 : if (verify) {
5449 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5450 : : plaintext,
5451 : : tdata->plaintext.data,
5452 : : (tdata->plaintext.len - tdata->cipher.offset_bits -
5453 : : (tdata->digest.len << 3)),
5454 : : tdata->cipher.offset_bits,
5455 : : "SNOW 3G Plaintext data not as expected");
5456 : : } else {
5457 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5458 : : ciphertext,
5459 : : tdata->ciphertext.data,
5460 : : (tdata->validDataLenInBits.len -
5461 : : tdata->cipher.offset_bits),
5462 : : tdata->cipher.offset_bits,
5463 : : "SNOW 3G Ciphertext data not as expected");
5464 : :
5465 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5466 : : ut_params->digest,
5467 : : tdata->digest.data,
5468 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5469 : : "SNOW 3G Generated auth tag not as expected");
5470 : : }
5471 : : return 0;
5472 : : }
5473 : :
5474 : : static int
5475 : 0 : test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5476 : : uint8_t op_mode, uint8_t verify)
5477 : : {
5478 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5479 : : struct crypto_unittest_params *ut_params = &unittest_params;
5480 : :
5481 : : int retval;
5482 : :
5483 : : const uint8_t *plaintext = NULL;
5484 : : const uint8_t *ciphertext = NULL;
5485 : : const uint8_t *digest = NULL;
5486 : : unsigned int plaintext_pad_len;
5487 : : unsigned int plaintext_len;
5488 : : unsigned int ciphertext_pad_len;
5489 : : unsigned int ciphertext_len;
5490 : : uint8_t buffer[10000];
5491 : : uint8_t digest_buffer[10000];
5492 : :
5493 : : struct rte_cryptodev_info dev_info;
5494 : :
5495 : : /* Verify the capabilities */
5496 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5497 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5498 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5499 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5500 : : &cap_idx) == NULL)
5501 : : return TEST_SKIPPED;
5502 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5503 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5504 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5505 : : &cap_idx) == NULL)
5506 : : return TEST_SKIPPED;
5507 : :
5508 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5509 : : return TEST_SKIPPED;
5510 : :
5511 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5512 : :
5513 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5514 : :
5515 [ # # ]: 0 : if (op_mode == IN_PLACE) {
5516 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5517 : : printf("Device doesn't support in-place scatter-gather "
5518 : : "in both input and output mbufs.\n");
5519 : 0 : return TEST_SKIPPED;
5520 : : }
5521 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5522 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5523 : : printf("Device doesn't support RAW data-path APIs.\n");
5524 : 0 : return TEST_SKIPPED;
5525 : : }
5526 : : } else {
5527 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5528 : : return TEST_SKIPPED;
5529 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5530 : : printf("Device doesn't support out-of-place scatter-gather "
5531 : : "in both input and output mbufs.\n");
5532 : 0 : return TEST_SKIPPED;
5533 : : }
5534 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5535 : : printf("Device doesn't support digest encrypted.\n");
5536 : 0 : return TEST_SKIPPED;
5537 : : }
5538 : : }
5539 : :
5540 : : /* Create SNOW 3G session */
5541 : 0 : retval = create_wireless_algo_auth_cipher_session(
5542 : 0 : ts_params->valid_devs[0],
5543 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5544 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5545 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5546 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5547 : : RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5548 : : RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5549 : : tdata->key.data, tdata->key.len,
5550 : 0 : tdata->key.data, tdata->key.len,
5551 : 0 : tdata->auth_iv.len, tdata->digest.len,
5552 : 0 : tdata->cipher_iv.len);
5553 : :
5554 [ # # ]: 0 : if (retval != 0)
5555 : : return retval;
5556 : :
5557 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5558 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5559 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5560 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5561 : :
5562 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5563 : : plaintext_pad_len, 15, 0);
5564 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5565 : : "Failed to allocate input buffer in mempool");
5566 : :
5567 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5568 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5569 : : plaintext_pad_len, 15, 0);
5570 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
5571 : : "Failed to allocate output buffer in mempool");
5572 : : }
5573 : :
5574 [ # # ]: 0 : if (verify) {
5575 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5576 : 0 : tdata->ciphertext.data);
5577 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5578 : : ciphertext_len, buffer);
5579 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5580 : : ciphertext_len);
5581 : : } else {
5582 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5583 : 0 : tdata->plaintext.data);
5584 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5585 : : plaintext_len, buffer);
5586 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5587 : : plaintext_len);
5588 : : }
5589 : : memset(buffer, 0, sizeof(buffer));
5590 : :
5591 : : /* Create SNOW 3G operation */
5592 : 0 : retval = create_wireless_algo_auth_cipher_operation(
5593 : 0 : tdata->digest.data, tdata->digest.len,
5594 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5595 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
5596 : 0 : (tdata->digest.offset_bytes == 0 ?
5597 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
5598 : : : tdata->digest.offset_bytes),
5599 : 0 : tdata->validCipherLenInBits.len,
5600 : 0 : tdata->cipher.offset_bits,
5601 : 0 : tdata->validAuthLenInBits.len,
5602 [ # # ]: 0 : tdata->auth.offset_bits,
5603 : : op_mode, 1, verify);
5604 : :
5605 [ # # ]: 0 : if (retval < 0)
5606 : : return retval;
5607 : :
5608 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5609 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5610 : 0 : tdata->cipher_iv.len);
5611 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5612 : : return retval;
5613 : : } else
5614 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5615 : : ut_params->op);
5616 : :
5617 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5618 : :
5619 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
5620 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5621 : :
5622 [ # # ]: 0 : if (verify) {
5623 [ # # ]: 0 : if (ut_params->obuf)
5624 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5625 : : plaintext_len, buffer);
5626 : : else
5627 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5628 : : plaintext_len, buffer);
5629 : :
5630 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5631 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5632 : 0 : debug_hexdump(stdout, "plaintext expected:",
5633 : 0 : tdata->plaintext.data,
5634 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5635 : : } else {
5636 [ # # ]: 0 : if (ut_params->obuf)
5637 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5638 : : ciphertext_len, buffer);
5639 : : else
5640 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5641 : : ciphertext_len, buffer);
5642 : :
5643 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5644 : : ciphertext_len);
5645 : 0 : debug_hexdump(stdout, "ciphertext expected:",
5646 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5647 : :
5648 [ # # ]: 0 : if (ut_params->obuf)
5649 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
5650 : 0 : (tdata->digest.offset_bytes == 0 ?
5651 : : plaintext_pad_len : tdata->digest.offset_bytes),
5652 [ # # ]: 0 : tdata->digest.len, digest_buffer);
5653 : : else
5654 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
5655 : 0 : (tdata->digest.offset_bytes == 0 ?
5656 : : plaintext_pad_len : tdata->digest.offset_bytes),
5657 [ # # ]: 0 : tdata->digest.len, digest_buffer);
5658 : :
5659 : 0 : debug_hexdump(stdout, "digest:", digest,
5660 : 0 : tdata->digest.len);
5661 : 0 : debug_hexdump(stdout, "digest expected:",
5662 : 0 : tdata->digest.data, tdata->digest.len);
5663 : : }
5664 : :
5665 : : /* Validate obuf */
5666 [ # # ]: 0 : if (verify) {
5667 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5668 : : plaintext,
5669 : : tdata->plaintext.data,
5670 : : (tdata->plaintext.len - tdata->cipher.offset_bits -
5671 : : (tdata->digest.len << 3)),
5672 : : tdata->cipher.offset_bits,
5673 : : "SNOW 3G Plaintext data not as expected");
5674 : : } else {
5675 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
# # # # #
# # # #
# ]
5676 : : ciphertext,
5677 : : tdata->ciphertext.data,
5678 : : (tdata->validDataLenInBits.len -
5679 : : tdata->cipher.offset_bits),
5680 : : tdata->cipher.offset_bits,
5681 : : "SNOW 3G Ciphertext data not as expected");
5682 : :
5683 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5684 : : digest,
5685 : : tdata->digest.data,
5686 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5687 : : "SNOW 3G Generated auth tag not as expected");
5688 : : }
5689 : : return 0;
5690 : : }
5691 : :
5692 : : static int
5693 : 0 : test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5694 : : uint8_t op_mode, uint8_t verify)
5695 : : {
5696 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5697 : : struct crypto_unittest_params *ut_params = &unittest_params;
5698 : :
5699 : : int retval;
5700 : :
5701 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
5702 : : unsigned int plaintext_pad_len;
5703 : : unsigned int plaintext_len;
5704 : : unsigned int ciphertext_pad_len;
5705 : : unsigned int ciphertext_len;
5706 : : unsigned int digest_offset;
5707 : :
5708 : : struct rte_cryptodev_info dev_info;
5709 : :
5710 : : /* Verify the capabilities */
5711 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5712 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5713 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5714 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5715 : : &cap_idx) == NULL)
5716 : : return TEST_SKIPPED;
5717 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5718 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5719 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5720 : : &cap_idx) == NULL)
5721 : : return TEST_SKIPPED;
5722 : :
5723 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5724 : :
5725 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5726 : :
5727 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5728 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5729 : : printf("Device doesn't support RAW data-path APIs.\n");
5730 : 0 : return TEST_SKIPPED;
5731 : : }
5732 : :
5733 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5734 : : return TEST_SKIPPED;
5735 : :
5736 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5737 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5738 : : return TEST_SKIPPED;
5739 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5740 : : printf("Device doesn't support digest encrypted.\n");
5741 : 0 : return TEST_SKIPPED;
5742 : : }
5743 : : }
5744 : :
5745 : : /* Create KASUMI session */
5746 : 0 : retval = create_wireless_algo_auth_cipher_session(
5747 : 0 : ts_params->valid_devs[0],
5748 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5749 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5750 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5751 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5752 : : RTE_CRYPTO_AUTH_KASUMI_F9,
5753 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
5754 : : tdata->key.data, tdata->key.len,
5755 : 0 : tdata->key.data, tdata->key.len,
5756 : 0 : 0, tdata->digest.len,
5757 : 0 : tdata->cipher_iv.len);
5758 : :
5759 [ # # ]: 0 : if (retval != 0)
5760 : : return retval;
5761 : :
5762 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5763 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5764 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5765 : :
5766 : : /* clear mbuf payload */
5767 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5768 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
5769 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5770 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5771 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
5772 : :
5773 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5774 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5775 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5776 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5777 : :
5778 [ # # ]: 0 : if (verify) {
5779 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5780 : : ciphertext_pad_len);
5781 [ # # ]: 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5782 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5783 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5784 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5785 : : ciphertext_len);
5786 : : } else {
5787 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5788 : : plaintext_pad_len);
5789 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5790 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
5791 : 0 : rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5792 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5793 : : plaintext_len);
5794 : : }
5795 : :
5796 : : /* Create KASUMI operation */
5797 : 0 : retval = create_wireless_algo_auth_cipher_operation(
5798 : 0 : tdata->digest.data, tdata->digest.len,
5799 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
5800 : : NULL, 0,
5801 : 0 : (tdata->digest.offset_bytes == 0 ?
5802 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
5803 : : : tdata->digest.offset_bytes),
5804 : 0 : tdata->validCipherLenInBits.len,
5805 : 0 : tdata->validCipherOffsetInBits.len,
5806 [ # # ]: 0 : tdata->validAuthLenInBits.len,
5807 : : 0,
5808 : : op_mode, 0, verify);
5809 : :
5810 [ # # ]: 0 : if (retval < 0)
5811 : : return retval;
5812 : :
5813 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
5814 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
5815 : 0 : tdata->cipher_iv.len);
5816 [ # # ]: 0 : if (retval != TEST_SUCCESS)
5817 : : return retval;
5818 : : } else
5819 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5820 : : ut_params->op);
5821 : :
5822 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5823 : :
5824 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
5825 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5826 : :
5827 : :
5828 [ # # ]: 0 : if (verify) {
5829 [ # # ]: 0 : if (ut_params->obuf)
5830 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5831 : : uint8_t *);
5832 : : else
5833 : : plaintext = ciphertext;
5834 : :
5835 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
5836 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5837 : 0 : debug_hexdump(stdout, "plaintext expected:",
5838 : 0 : tdata->plaintext.data,
5839 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
5840 : : } else {
5841 [ # # ]: 0 : if (ut_params->obuf)
5842 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5843 : : uint8_t *);
5844 : : else
5845 : : ciphertext = plaintext;
5846 : :
5847 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5848 : : ciphertext_len);
5849 : 0 : debug_hexdump(stdout, "ciphertext expected:",
5850 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5851 : :
5852 [ # # ]: 0 : if (tdata->digest.offset_bytes == 0)
5853 : : digest_offset = plaintext_pad_len;
5854 : : else
5855 : : digest_offset = tdata->digest.offset_bytes;
5856 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
5857 : : uint8_t *, digest_offset);
5858 : :
5859 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
5860 : 0 : tdata->digest.len);
5861 : 0 : debug_hexdump(stdout, "digest expected:",
5862 : 0 : tdata->digest.data, tdata->digest.len);
5863 : : }
5864 : :
5865 : : /* Validate obuf */
5866 [ # # ]: 0 : if (verify) {
5867 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
5868 : : plaintext,
5869 : : tdata->plaintext.data,
5870 : : tdata->plaintext.len >> 3,
5871 : : "KASUMI Plaintext data not as expected");
5872 : : } else {
5873 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
5874 : : ciphertext,
5875 : : tdata->ciphertext.data,
5876 : : tdata->ciphertext.len >> 3,
5877 : : "KASUMI Ciphertext data not as expected");
5878 : :
5879 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
5880 : : ut_params->digest,
5881 : : tdata->digest.data,
5882 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
5883 : : "KASUMI Generated auth tag not as expected");
5884 : : }
5885 : : return 0;
5886 : : }
5887 : :
5888 : : static int
5889 : 0 : test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5890 : : uint8_t op_mode, uint8_t verify)
5891 : : {
5892 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
5893 : : struct crypto_unittest_params *ut_params = &unittest_params;
5894 : :
5895 : : int retval;
5896 : :
5897 : : const uint8_t *plaintext = NULL;
5898 : : const uint8_t *ciphertext = NULL;
5899 : : const uint8_t *digest = NULL;
5900 : : unsigned int plaintext_pad_len;
5901 : : unsigned int plaintext_len;
5902 : : unsigned int ciphertext_pad_len;
5903 : : unsigned int ciphertext_len;
5904 : : uint8_t buffer[10000];
5905 : : uint8_t digest_buffer[10000];
5906 : :
5907 : : struct rte_cryptodev_info dev_info;
5908 : :
5909 : : /* Verify the capabilities */
5910 : : struct rte_cryptodev_sym_capability_idx cap_idx;
5911 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5912 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5913 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5914 : : &cap_idx) == NULL)
5915 : : return TEST_SKIPPED;
5916 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5917 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5918 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5919 : : &cap_idx) == NULL)
5920 : : return TEST_SKIPPED;
5921 : :
5922 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5923 : : return TEST_SKIPPED;
5924 : :
5925 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5926 : :
5927 : 0 : uint64_t feat_flags = dev_info.feature_flags;
5928 : :
5929 [ # # ]: 0 : if (op_mode == IN_PLACE) {
5930 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5931 : : printf("Device doesn't support in-place scatter-gather "
5932 : : "in both input and output mbufs.\n");
5933 : 0 : return TEST_SKIPPED;
5934 : : }
5935 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5936 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5937 : : printf("Device doesn't support RAW data-path APIs.\n");
5938 : 0 : return TEST_SKIPPED;
5939 : : }
5940 : : } else {
5941 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5942 : : return TEST_SKIPPED;
5943 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5944 : : printf("Device doesn't support out-of-place scatter-gather "
5945 : : "in both input and output mbufs.\n");
5946 : 0 : return TEST_SKIPPED;
5947 : : }
5948 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5949 : : printf("Device doesn't support digest encrypted.\n");
5950 : 0 : return TEST_SKIPPED;
5951 : : }
5952 : : }
5953 : :
5954 : : /* Create KASUMI session */
5955 : 0 : retval = create_wireless_algo_auth_cipher_session(
5956 : 0 : ts_params->valid_devs[0],
5957 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5958 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5959 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5960 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
5961 : : RTE_CRYPTO_AUTH_KASUMI_F9,
5962 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
5963 : : tdata->key.data, tdata->key.len,
5964 : 0 : tdata->key.data, tdata->key.len,
5965 : 0 : 0, tdata->digest.len,
5966 : 0 : tdata->cipher_iv.len);
5967 : :
5968 [ # # ]: 0 : if (retval != 0)
5969 : : return retval;
5970 : :
5971 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5972 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
5973 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5974 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5975 : :
5976 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5977 : : plaintext_pad_len, 15, 0);
5978 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5979 : : "Failed to allocate input buffer in mempool");
5980 : :
5981 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
5982 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5983 : : plaintext_pad_len, 15, 0);
5984 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
5985 : : "Failed to allocate output buffer in mempool");
5986 : : }
5987 : :
5988 [ # # ]: 0 : if (verify) {
5989 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5990 : 0 : tdata->ciphertext.data);
5991 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5992 : : ciphertext_len, buffer);
5993 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
5994 : : ciphertext_len);
5995 : : } else {
5996 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5997 : 0 : tdata->plaintext.data);
5998 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5999 : : plaintext_len, buffer);
6000 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6001 : : plaintext_len);
6002 : : }
6003 : : memset(buffer, 0, sizeof(buffer));
6004 : :
6005 : : /* Create KASUMI operation */
6006 : 0 : retval = create_wireless_algo_auth_cipher_operation(
6007 : 0 : tdata->digest.data, tdata->digest.len,
6008 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6009 : : NULL, 0,
6010 : 0 : (tdata->digest.offset_bytes == 0 ?
6011 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
6012 : : : tdata->digest.offset_bytes),
6013 : 0 : tdata->validCipherLenInBits.len,
6014 : 0 : tdata->validCipherOffsetInBits.len,
6015 [ # # ]: 0 : tdata->validAuthLenInBits.len,
6016 : : 0,
6017 : : op_mode, 1, verify);
6018 : :
6019 [ # # ]: 0 : if (retval < 0)
6020 : : return retval;
6021 : :
6022 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6023 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6024 : 0 : tdata->cipher_iv.len);
6025 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6026 : : return retval;
6027 : : } else
6028 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6029 : : ut_params->op);
6030 : :
6031 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6032 : :
6033 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
6034 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6035 : :
6036 [ # # ]: 0 : if (verify) {
6037 [ # # ]: 0 : if (ut_params->obuf)
6038 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6039 : : plaintext_len, buffer);
6040 : : else
6041 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6042 : : plaintext_len, buffer);
6043 : :
6044 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6045 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6046 : 0 : debug_hexdump(stdout, "plaintext expected:",
6047 : 0 : tdata->plaintext.data,
6048 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6049 : : } else {
6050 [ # # ]: 0 : if (ut_params->obuf)
6051 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6052 : : ciphertext_len, buffer);
6053 : : else
6054 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6055 : : ciphertext_len, buffer);
6056 : :
6057 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6058 : : ciphertext_len);
6059 : 0 : debug_hexdump(stdout, "ciphertext expected:",
6060 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6061 : :
6062 [ # # ]: 0 : if (ut_params->obuf)
6063 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
6064 : 0 : (tdata->digest.offset_bytes == 0 ?
6065 : : plaintext_pad_len : tdata->digest.offset_bytes),
6066 [ # # ]: 0 : tdata->digest.len, digest_buffer);
6067 : : else
6068 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
6069 : 0 : (tdata->digest.offset_bytes == 0 ?
6070 : : plaintext_pad_len : tdata->digest.offset_bytes),
6071 [ # # ]: 0 : tdata->digest.len, digest_buffer);
6072 : :
6073 : 0 : debug_hexdump(stdout, "digest:", digest,
6074 : 0 : tdata->digest.len);
6075 : 0 : debug_hexdump(stdout, "digest expected:",
6076 : 0 : tdata->digest.data, tdata->digest.len);
6077 : : }
6078 : :
6079 : : /* Validate obuf */
6080 [ # # ]: 0 : if (verify) {
6081 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6082 : : plaintext,
6083 : : tdata->plaintext.data,
6084 : : tdata->plaintext.len >> 3,
6085 : : "KASUMI Plaintext data not as expected");
6086 : : } else {
6087 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6088 : : ciphertext,
6089 : : tdata->ciphertext.data,
6090 : : tdata->validDataLenInBits.len,
6091 : : "KASUMI Ciphertext data not as expected");
6092 : :
6093 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6094 : : digest,
6095 : : tdata->digest.data,
6096 : : DIGEST_BYTE_LENGTH_KASUMI_F9,
6097 : : "KASUMI Generated auth tag not as expected");
6098 : : }
6099 : : return 0;
6100 : : }
6101 : :
6102 : : static int
6103 : 0 : test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
6104 : : {
6105 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6106 : : struct crypto_unittest_params *ut_params = &unittest_params;
6107 : :
6108 : : int retval;
6109 : :
6110 : : uint8_t *plaintext, *ciphertext;
6111 : : unsigned plaintext_pad_len;
6112 : : unsigned plaintext_len;
6113 : : struct rte_cryptodev_info dev_info;
6114 : :
6115 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6116 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6117 : :
6118 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6119 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6120 : : printf("Device doesn't support RAW data-path APIs.\n");
6121 : 0 : return TEST_SKIPPED;
6122 : : }
6123 : :
6124 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6125 : : return TEST_SKIPPED;
6126 : :
6127 : : /* Verify the capabilities */
6128 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6129 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6130 : 0 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
6131 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6132 : : &cap_idx) == NULL)
6133 : : return TEST_SKIPPED;
6134 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6135 : 0 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
6136 [ # # ]: 0 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6137 : : &cap_idx) == NULL)
6138 : : return TEST_SKIPPED;
6139 : :
6140 : : /* Create KASUMI session */
6141 : 0 : retval = create_wireless_algo_cipher_auth_session(
6142 : 0 : ts_params->valid_devs[0],
6143 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6144 : : RTE_CRYPTO_AUTH_OP_GENERATE,
6145 : : RTE_CRYPTO_AUTH_KASUMI_F9,
6146 : : RTE_CRYPTO_CIPHER_KASUMI_F8,
6147 : : tdata->key.data, tdata->key.len,
6148 : 0 : tdata->key.data, tdata->key.len,
6149 : 0 : 0, tdata->digest.len,
6150 : 0 : tdata->cipher_iv.len);
6151 [ # # ]: 0 : if (retval != 0)
6152 : : return retval;
6153 : :
6154 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6155 : :
6156 : : /* clear mbuf payload */
6157 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6158 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6159 : :
6160 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6161 : : /* Append data which is padded to a multiple of */
6162 : : /* the algorithms block size */
6163 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6164 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6165 : : plaintext_pad_len);
6166 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6167 : :
6168 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6169 : :
6170 : : /* Create KASUMI operation */
6171 : 0 : retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
6172 : 0 : tdata->digest.len, NULL, 0,
6173 : : plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6174 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6175 : 0 : RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
6176 : 0 : tdata->validCipherOffsetInBits.len,
6177 : 0 : tdata->validAuthLenInBits.len,
6178 : : 0
6179 : : );
6180 [ # # ]: 0 : if (retval < 0)
6181 : : return retval;
6182 : :
6183 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6184 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6185 : 0 : tdata->cipher_iv.len);
6186 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6187 : : return retval;
6188 : : } else
6189 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6190 : : ut_params->op);
6191 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6192 : :
6193 [ # # ]: 0 : if (ut_params->op->sym->m_dst)
6194 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6195 : : else
6196 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
6197 : :
6198 : 0 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6199 : : tdata->validCipherOffsetInBits.len >> 3);
6200 : :
6201 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6202 : : uint8_t *,
6203 : : plaintext_pad_len);
6204 : :
6205 : 0 : const uint8_t *reference_ciphertext = tdata->ciphertext.data +
6206 : : (tdata->validCipherOffsetInBits.len >> 3);
6207 : : /* Validate obuf */
6208 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6209 : : ciphertext,
6210 : : reference_ciphertext,
6211 : : tdata->validCipherLenInBits.len,
6212 : : "KASUMI Ciphertext data not as expected");
6213 : :
6214 : : /* Validate obuf */
6215 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6216 : : ut_params->digest,
6217 : : tdata->digest.data,
6218 : : DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6219 : : "KASUMI Generated auth tag not as expected");
6220 : : return 0;
6221 : : }
6222 : :
6223 : : static int
6224 : 0 : check_cipher_capability(const struct crypto_testsuite_params *ts_params,
6225 : : const enum rte_crypto_cipher_algorithm cipher_algo,
6226 : : const uint16_t key_size, const uint16_t iv_size)
6227 : : {
6228 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6229 : : const struct rte_cryptodev_symmetric_capability *cap;
6230 : :
6231 : : /* Check if device supports the algorithm */
6232 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6233 : 0 : cap_idx.algo.cipher = cipher_algo;
6234 : :
6235 : 0 : cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6236 : : &cap_idx);
6237 : :
6238 [ # # ]: 0 : if (cap == NULL)
6239 : : return -1;
6240 : :
6241 : : /* Check if device supports key size and IV size */
6242 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(cap, key_size,
6243 : : iv_size) < 0) {
6244 : 0 : return -1;
6245 : : }
6246 : :
6247 : : return 0;
6248 : : }
6249 : :
6250 : : static int
6251 : 0 : check_auth_capability(const struct crypto_testsuite_params *ts_params,
6252 : : const enum rte_crypto_auth_algorithm auth_algo,
6253 : : const uint16_t key_size, const uint16_t iv_size,
6254 : : const uint16_t tag_size)
6255 : : {
6256 : : struct rte_cryptodev_sym_capability_idx cap_idx;
6257 : : const struct rte_cryptodev_symmetric_capability *cap;
6258 : :
6259 : : /* Check if device supports the algorithm */
6260 : 0 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6261 : 0 : cap_idx.algo.auth = auth_algo;
6262 : :
6263 : 0 : cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6264 : : &cap_idx);
6265 : :
6266 [ # # ]: 0 : if (cap == NULL)
6267 : : return -1;
6268 : :
6269 : : /* Check if device supports key size and IV size */
6270 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_auth(cap, key_size,
6271 : : tag_size, iv_size) < 0) {
6272 : 0 : return -1;
6273 : : }
6274 : :
6275 : : return 0;
6276 : : }
6277 : :
6278 : : static int
6279 : 0 : test_zuc_cipher(const struct wireless_test_data *tdata,
6280 : : enum rte_crypto_cipher_operation direction)
6281 : : {
6282 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6283 : : struct crypto_unittest_params *ut_params = &unittest_params;
6284 : :
6285 : : int retval;
6286 : : uint8_t *plaintext = NULL;
6287 : : uint8_t *ciphertext = NULL;
6288 : : unsigned int plaintext_pad_len, ciphertext_pad_len;
6289 : : unsigned int plaintext_len = 0;
6290 : : unsigned int ciphertext_len = 0;
6291 : : struct rte_cryptodev_info dev_info;
6292 : :
6293 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6294 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6295 : :
6296 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6297 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6298 : : printf("Device doesn't support RAW data-path APIs.\n");
6299 : 0 : return TEST_SKIPPED;
6300 : : }
6301 : :
6302 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6303 : : return TEST_SKIPPED;
6304 : :
6305 : : /* Check if device supports ZUC EEA3 */
6306 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6307 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6308 : : return TEST_SKIPPED;
6309 : :
6310 : : /* Create ZUC session */
6311 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6312 : : direction,
6313 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6314 : 0 : tdata->key.data, tdata->key.len,
6315 : 0 : tdata->cipher_iv.len);
6316 [ # # ]: 0 : if (retval != 0)
6317 : : return retval;
6318 : :
6319 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6320 : :
6321 : : /* Clear mbuf payload */
6322 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6323 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6324 : :
6325 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6326 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6327 : : /* Append data which is padded to a multiple */
6328 : : /* of the algorithms block size */
6329 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6330 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6331 : : plaintext_pad_len);
6332 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6333 : :
6334 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6335 : : } else {
6336 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6337 : : /* Append data which is padded to a multiple */
6338 : : /* of the algorithms block size */
6339 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6340 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6341 : : ciphertext_pad_len);
6342 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6343 : :
6344 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
6345 : : }
6346 : :
6347 : : /* Create ZUC operation */
6348 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6349 : 0 : tdata->cipher_iv.len,
6350 : 0 : tdata->plaintext.len,
6351 : 0 : tdata->validCipherOffsetInBits.len);
6352 [ # # ]: 0 : if (retval < 0)
6353 : : return retval;
6354 : :
6355 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6356 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6357 : 0 : tdata->cipher_iv.len);
6358 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6359 : : return retval;
6360 : : } else
6361 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6362 : : ut_params->op);
6363 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6364 : :
6365 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6366 : :
6367 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6368 [ # # ]: 0 : if (ut_params->obuf)
6369 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6370 : : else
6371 : : ciphertext = plaintext;
6372 : :
6373 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6374 : :
6375 : : /* Validate obuf */
6376 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6377 : : ciphertext,
6378 : : tdata->ciphertext.data,
6379 : : tdata->validCipherLenInBits.len,
6380 : : "ZUC Ciphertext data not as expected");
6381 : : } else {
6382 [ # # ]: 0 : if (ut_params->obuf)
6383 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6384 : : else
6385 : : plaintext = ciphertext;
6386 : :
6387 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6388 : :
6389 : 0 : const uint8_t *reference_plaintext = tdata->plaintext.data +
6390 : 0 : (tdata->validCipherOffsetInBits.len >> 3);
6391 : :
6392 : : /* Validate obuf */
6393 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6394 : : plaintext,
6395 : : reference_plaintext,
6396 : : tdata->validCipherLenInBits.len,
6397 : : "ZUC Plaintext data not as expected");
6398 : : }
6399 : :
6400 : : return 0;
6401 : : }
6402 : :
6403 : : static int
6404 : 0 : test_zuc_cipher_sgl(const struct wireless_test_data *tdata,
6405 : : enum rte_crypto_cipher_operation direction)
6406 : : {
6407 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6408 : : struct crypto_unittest_params *ut_params = &unittest_params;
6409 : :
6410 : : int retval;
6411 : :
6412 : : unsigned int plaintext_pad_len, ciphertext_pad_len;
6413 : : unsigned int plaintext_len = 0;
6414 : : unsigned int ciphertext_len = 0;
6415 : : const uint8_t *ciphertext, *plaintext;
6416 : : uint8_t buffer[2048];
6417 : : struct rte_cryptodev_info dev_info;
6418 : :
6419 : : /* Check if device supports ZUC EEA3 */
6420 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6421 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6422 : : return TEST_SKIPPED;
6423 : :
6424 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6425 : : return TEST_SKIPPED;
6426 : :
6427 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6428 : :
6429 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6430 : :
6431 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6432 : : printf("Device doesn't support in-place scatter-gather. "
6433 : : "Test Skipped.\n");
6434 : 0 : return TEST_SKIPPED;
6435 : : }
6436 : :
6437 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6438 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6439 : : printf("Device doesn't support RAW data-path APIs.\n");
6440 : 0 : return TEST_SKIPPED;
6441 : : }
6442 : :
6443 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6444 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6445 : :
6446 : : /* Append data which is padded to a multiple */
6447 : : /* of the algorithms block size */
6448 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6449 : :
6450 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6451 : : plaintext_pad_len, 10, 0);
6452 : :
6453 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6454 : 0 : tdata->plaintext.data);
6455 : : } else {
6456 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6457 : :
6458 : : /* Append data which is padded to a multiple */
6459 : : /* of the algorithms block size */
6460 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
6461 : :
6462 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6463 : : ciphertext_pad_len, 10, 0);
6464 : :
6465 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6466 : 0 : tdata->ciphertext.data);
6467 : :
6468 : : }
6469 : :
6470 : : /* Create ZUC session */
6471 : 0 : retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6472 : : direction,
6473 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6474 : 0 : tdata->key.data, tdata->key.len,
6475 : 0 : tdata->cipher_iv.len);
6476 [ # # ]: 0 : if (retval < 0)
6477 : : return retval;
6478 : :
6479 : : /* Clear mbuf payload */
6480 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT)
6481 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
6482 : : else
6483 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len, tdata->ciphertext.data);
6484 : :
6485 : : /* Create ZUC operation */
6486 : 0 : retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6487 : 0 : tdata->cipher_iv.len, tdata->plaintext.len,
6488 : 0 : tdata->validCipherOffsetInBits.len);
6489 [ # # ]: 0 : if (retval < 0)
6490 : : return retval;
6491 : :
6492 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6493 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 0, 1,
6494 : 0 : tdata->cipher_iv.len);
6495 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6496 : : return retval;
6497 : : } else
6498 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6499 : : ut_params->op);
6500 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6501 : :
6502 : 0 : ut_params->obuf = ut_params->op->sym->m_dst;
6503 : :
6504 [ # # ]: 0 : if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6505 [ # # ]: 0 : if (ut_params->obuf)
6506 : : ciphertext = rte_pktmbuf_read(ut_params->obuf,
6507 : : 0, plaintext_len, buffer);
6508 : : else
6509 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6510 : : 0, plaintext_len, buffer);
6511 : :
6512 : : /* Validate obuf */
6513 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6514 : :
6515 : : /* Validate obuf */
6516 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6517 : : ciphertext,
6518 : : tdata->ciphertext.data,
6519 : : tdata->validCipherLenInBits.len,
6520 : : "ZUC Ciphertext data not as expected");
6521 : : } else {
6522 [ # # ]: 0 : if (ut_params->obuf)
6523 : : plaintext = rte_pktmbuf_read(ut_params->obuf,
6524 : : 0, ciphertext_len, buffer);
6525 : : else
6526 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf,
6527 : : 0, ciphertext_len, buffer);
6528 : :
6529 : : /* Validate obuf */
6530 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
6531 : :
6532 : : /* Validate obuf */
6533 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6534 : : plaintext,
6535 : : tdata->plaintext.data,
6536 : : tdata->validCipherLenInBits.len,
6537 : : "ZUC Plaintext data not as expected");
6538 : : }
6539 : :
6540 : : return 0;
6541 : : }
6542 : :
6543 : : static int
6544 : 0 : test_zuc_authentication(const struct wireless_test_data *tdata,
6545 : : enum rte_crypto_auth_operation auth_op)
6546 : : {
6547 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6548 : : struct crypto_unittest_params *ut_params = &unittest_params;
6549 : :
6550 : : int retval;
6551 : : unsigned plaintext_pad_len;
6552 : : unsigned plaintext_len;
6553 : : uint8_t *plaintext;
6554 : :
6555 : : struct rte_cryptodev_info dev_info;
6556 : :
6557 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6558 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6559 : :
6560 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6561 [ # # ]: 0 : (tdata->validAuthLenInBits.len % 8 != 0)) {
6562 : : printf("Device doesn't support NON-Byte Aligned Data.\n");
6563 : 0 : return TEST_SKIPPED;
6564 : : }
6565 : :
6566 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6567 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6568 : : printf("Device doesn't support RAW data-path APIs.\n");
6569 : 0 : return TEST_SKIPPED;
6570 : : }
6571 : :
6572 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6573 : : return TEST_SKIPPED;
6574 : :
6575 : : /* Check if device supports ZUC EIA3 */
6576 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6577 : 0 : tdata->key.len, tdata->auth_iv.len,
6578 : 0 : tdata->digest.len) < 0)
6579 : : return TEST_SKIPPED;
6580 : :
6581 : : /* Create ZUC session */
6582 : 0 : retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6583 : 0 : tdata->key.data, tdata->key.len,
6584 : 0 : tdata->auth_iv.len, tdata->digest.len,
6585 : : auth_op, RTE_CRYPTO_AUTH_ZUC_EIA3);
6586 [ # # ]: 0 : if (retval != 0)
6587 : : return retval;
6588 : :
6589 : : /* alloc mbuf and set payload */
6590 [ # # ]: 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6591 : :
6592 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6593 : : rte_pktmbuf_tailroom(ut_params->ibuf));
6594 : :
6595 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6596 : : /* Append data which is padded to a multiple of */
6597 : : /* the algorithms block size */
6598 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6599 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6600 : : plaintext_pad_len);
6601 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6602 : :
6603 : : /* Create ZUC operation */
6604 : 0 : retval = create_wireless_algo_hash_operation(tdata->digest.data,
6605 : 0 : tdata->digest.len,
6606 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
6607 : : plaintext_pad_len,
6608 : 0 : auth_op, tdata->validAuthLenInBits.len, 0);
6609 [ # # ]: 0 : if (retval < 0)
6610 : : return retval;
6611 : :
6612 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6613 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 1,
6614 : : 0);
6615 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6616 : : return retval;
6617 : : } else
6618 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6619 : : ut_params->op);
6620 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6621 : 0 : ut_params->obuf = ut_params->op->sym->m_src;
6622 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6623 : : uint8_t *,
6624 : : plaintext_pad_len);
6625 : :
6626 [ # # ]: 0 : if (auth_op != RTE_CRYPTO_AUTH_OP_VERIFY) {
6627 : : /* Validate obuf */
6628 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6629 : : ut_params->digest,
6630 : : tdata->digest.data,
6631 : : tdata->digest.len,
6632 : : "ZUC Generated auth tag not as expected");
6633 : : return 0;
6634 : : }
6635 : :
6636 : : /* Validate obuf */
6637 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
6638 : : return 0;
6639 : : else
6640 : 0 : return -1;
6641 : :
6642 : : return 0;
6643 : : }
6644 : :
6645 : : static int
6646 : 0 : test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6647 : : uint8_t op_mode, uint8_t verify)
6648 : : {
6649 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6650 : : struct crypto_unittest_params *ut_params = &unittest_params;
6651 : :
6652 : : int retval;
6653 : :
6654 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
6655 : : unsigned int plaintext_pad_len;
6656 : : unsigned int plaintext_len;
6657 : : unsigned int ciphertext_pad_len;
6658 : : unsigned int ciphertext_len;
6659 : : unsigned int digest_offset;
6660 : :
6661 : : struct rte_cryptodev_info dev_info;
6662 : :
6663 : : /* Check if device supports ZUC EEA3 */
6664 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6665 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6666 : : return TEST_SKIPPED;
6667 : :
6668 : : /* Check if device supports ZUC EIA3 */
6669 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6670 : 0 : tdata->key.len, tdata->auth_iv.len,
6671 : 0 : tdata->digest.len) < 0)
6672 : : return TEST_SKIPPED;
6673 : :
6674 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6675 : : return TEST_SKIPPED;
6676 : :
6677 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6678 : :
6679 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6680 : :
6681 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6682 : : printf("Device doesn't support digest encrypted.\n");
6683 : 0 : return TEST_SKIPPED;
6684 : : }
6685 [ # # ]: 0 : if (op_mode == IN_PLACE) {
6686 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6687 : : printf("Device doesn't support in-place scatter-gather "
6688 : : "in both input and output mbufs.\n");
6689 : 0 : return TEST_SKIPPED;
6690 : : }
6691 : :
6692 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6693 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6694 : : printf("Device doesn't support RAW data-path APIs.\n");
6695 : 0 : return TEST_SKIPPED;
6696 : : }
6697 : : } else {
6698 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6699 : : return TEST_SKIPPED;
6700 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6701 : : printf("Device doesn't support out-of-place scatter-gather "
6702 : : "in both input and output mbufs.\n");
6703 : 0 : return TEST_SKIPPED;
6704 : : }
6705 : : }
6706 : :
6707 : : /* Create ZUC session */
6708 : 0 : retval = create_wireless_algo_auth_cipher_session(
6709 : 0 : ts_params->valid_devs[0],
6710 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6711 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6712 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6713 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
6714 : : RTE_CRYPTO_AUTH_ZUC_EIA3,
6715 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6716 : : tdata->key.data, tdata->key.len,
6717 : 0 : tdata->key.data, tdata->key.len,
6718 : 0 : tdata->auth_iv.len, tdata->digest.len,
6719 : 0 : tdata->cipher_iv.len);
6720 : :
6721 [ # # ]: 0 : if (retval != 0)
6722 : : return retval;
6723 : :
6724 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6725 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6726 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6727 : :
6728 : : /* clear mbuf payload */
6729 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6730 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
6731 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6732 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6733 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
6734 : :
6735 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6736 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6737 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6738 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6739 : :
6740 [ # # ]: 0 : if (verify) {
6741 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6742 : : ciphertext_pad_len);
6743 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6744 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6745 : : ciphertext_len);
6746 : : } else {
6747 : : /* make sure enough space to cover partial digest verify case */
6748 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6749 : : ciphertext_pad_len);
6750 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6751 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6752 : : plaintext_len);
6753 : : }
6754 : :
6755 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
6756 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6757 : :
6758 : : /* Create ZUC operation */
6759 : 0 : retval = create_wireless_algo_auth_cipher_operation(
6760 : 0 : tdata->digest.data, tdata->digest.len,
6761 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6762 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
6763 : 0 : (tdata->digest.offset_bytes == 0 ?
6764 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
6765 : : : tdata->digest.offset_bytes),
6766 : 0 : tdata->validCipherLenInBits.len,
6767 : 0 : tdata->validCipherOffsetInBits.len,
6768 [ # # ]: 0 : tdata->validAuthLenInBits.len,
6769 : : 0,
6770 : : op_mode, 0, verify);
6771 : :
6772 [ # # ]: 0 : if (retval < 0)
6773 : : return retval;
6774 : :
6775 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6776 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6777 : 0 : tdata->cipher_iv.len);
6778 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6779 : : return retval;
6780 : : } else
6781 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6782 : : ut_params->op);
6783 : :
6784 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6785 : :
6786 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
6787 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6788 : :
6789 : :
6790 [ # # ]: 0 : if (verify) {
6791 [ # # ]: 0 : if (ut_params->obuf)
6792 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6793 : : uint8_t *);
6794 : : else
6795 : : plaintext = ciphertext;
6796 : :
6797 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6798 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6799 : 0 : debug_hexdump(stdout, "plaintext expected:",
6800 : 0 : tdata->plaintext.data,
6801 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
6802 : : } else {
6803 [ # # ]: 0 : if (ut_params->obuf)
6804 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6805 : : uint8_t *);
6806 : : else
6807 : : ciphertext = plaintext;
6808 : :
6809 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6810 : : ciphertext_len);
6811 : 0 : debug_hexdump(stdout, "ciphertext expected:",
6812 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6813 : :
6814 [ # # ]: 0 : if (tdata->digest.offset_bytes == 0)
6815 : : digest_offset = plaintext_pad_len;
6816 : : else
6817 : : digest_offset = tdata->digest.offset_bytes;
6818 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
6819 : : uint8_t *, digest_offset);
6820 : :
6821 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
6822 : 0 : tdata->digest.len);
6823 : 0 : debug_hexdump(stdout, "digest expected:",
6824 : 0 : tdata->digest.data, tdata->digest.len);
6825 : : }
6826 : :
6827 : : /* Validate obuf */
6828 [ # # ]: 0 : if (verify) {
6829 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6830 : : plaintext,
6831 : : tdata->plaintext.data,
6832 : : tdata->plaintext.len >> 3,
6833 : : "ZUC Plaintext data not as expected");
6834 : : } else {
6835 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
6836 : : ciphertext,
6837 : : tdata->ciphertext.data,
6838 : : tdata->ciphertext.len >> 3,
6839 : : "ZUC Ciphertext data not as expected");
6840 : :
6841 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
6842 : : ut_params->digest,
6843 : : tdata->digest.data,
6844 : : tdata->digest.len,
6845 : : "ZUC Generated auth tag not as expected");
6846 : : }
6847 : : return 0;
6848 : : }
6849 : :
6850 : : static int
6851 : 0 : test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6852 : : uint8_t op_mode, uint8_t verify)
6853 : : {
6854 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
6855 : : struct crypto_unittest_params *ut_params = &unittest_params;
6856 : :
6857 : : int retval;
6858 : :
6859 : : const uint8_t *plaintext = NULL;
6860 : : const uint8_t *ciphertext = NULL;
6861 : : const uint8_t *digest = NULL;
6862 : : unsigned int plaintext_pad_len;
6863 : : unsigned int plaintext_len;
6864 : : unsigned int ciphertext_pad_len;
6865 : : unsigned int ciphertext_len;
6866 : : uint8_t buffer[10000];
6867 : : uint8_t digest_buffer[10000];
6868 : :
6869 : : struct rte_cryptodev_info dev_info;
6870 : :
6871 : : /* Check if device supports ZUC EEA3 */
6872 [ # # ]: 0 : if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6873 : 0 : tdata->key.len, tdata->cipher_iv.len) < 0)
6874 : : return TEST_SKIPPED;
6875 : :
6876 : : /* Check if device supports ZUC EIA3 */
6877 [ # # ]: 0 : if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6878 : 0 : tdata->key.len, tdata->auth_iv.len,
6879 : 0 : tdata->digest.len) < 0)
6880 : : return TEST_SKIPPED;
6881 : :
6882 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6883 : : return TEST_SKIPPED;
6884 : :
6885 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6886 : :
6887 : 0 : uint64_t feat_flags = dev_info.feature_flags;
6888 : :
6889 [ # # ]: 0 : if (op_mode == IN_PLACE) {
6890 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6891 : : printf("Device doesn't support in-place scatter-gather "
6892 : : "in both input and output mbufs.\n");
6893 : 0 : return TEST_SKIPPED;
6894 : : }
6895 : :
6896 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6897 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6898 : : printf("Device doesn't support RAW data-path APIs.\n");
6899 : 0 : return TEST_SKIPPED;
6900 : : }
6901 : : } else {
6902 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6903 : : return TEST_SKIPPED;
6904 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6905 : : printf("Device doesn't support out-of-place scatter-gather "
6906 : : "in both input and output mbufs.\n");
6907 : 0 : return TEST_SKIPPED;
6908 : : }
6909 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6910 : : printf("Device doesn't support digest encrypted.\n");
6911 : 0 : return TEST_SKIPPED;
6912 : : }
6913 : : }
6914 : :
6915 : : /* Create ZUC session */
6916 : 0 : retval = create_wireless_algo_auth_cipher_session(
6917 : 0 : ts_params->valid_devs[0],
6918 : : (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6919 : : : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6920 : : (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6921 : : : RTE_CRYPTO_AUTH_OP_GENERATE),
6922 : : RTE_CRYPTO_AUTH_ZUC_EIA3,
6923 : : RTE_CRYPTO_CIPHER_ZUC_EEA3,
6924 : : tdata->key.data, tdata->key.len,
6925 : 0 : tdata->key.data, tdata->key.len,
6926 : 0 : tdata->auth_iv.len, tdata->digest.len,
6927 : 0 : tdata->cipher_iv.len);
6928 : :
6929 [ # # ]: 0 : if (retval != 0)
6930 : : return retval;
6931 : :
6932 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6933 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len);
6934 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6935 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6936 : :
6937 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6938 : : plaintext_pad_len, 15, 0);
6939 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6940 : : "Failed to allocate input buffer in mempool");
6941 : :
6942 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
6943 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6944 : : plaintext_pad_len, 15, 0);
6945 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
6946 : : "Failed to allocate output buffer in mempool");
6947 : : }
6948 : :
6949 [ # # ]: 0 : if (verify) {
6950 : 0 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6951 : 0 : tdata->ciphertext.data);
6952 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6953 : : ciphertext_len, buffer);
6954 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
6955 : : ciphertext_len);
6956 : : } else {
6957 : 0 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6958 : 0 : tdata->plaintext.data);
6959 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6960 : : plaintext_len, buffer);
6961 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
6962 : : plaintext_len);
6963 : : }
6964 : : memset(buffer, 0, sizeof(buffer));
6965 : :
6966 : : /* Create ZUC operation */
6967 : 0 : retval = create_wireless_algo_auth_cipher_operation(
6968 : 0 : tdata->digest.data, tdata->digest.len,
6969 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
6970 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
6971 : 0 : (tdata->digest.offset_bytes == 0 ?
6972 [ # # ]: 0 : (verify ? ciphertext_pad_len : plaintext_pad_len)
6973 : : : tdata->digest.offset_bytes),
6974 : 0 : tdata->validCipherLenInBits.len,
6975 : 0 : tdata->validCipherOffsetInBits.len,
6976 [ # # ]: 0 : tdata->validAuthLenInBits.len,
6977 : : 0,
6978 : : op_mode, 1, verify);
6979 : :
6980 [ # # ]: 0 : if (retval < 0)
6981 : : return retval;
6982 : :
6983 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
6984 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 1,
6985 : 0 : tdata->cipher_iv.len);
6986 [ # # ]: 0 : if (retval != TEST_SUCCESS)
6987 : : return retval;
6988 : : } else
6989 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6990 : : ut_params->op);
6991 : :
6992 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6993 : :
6994 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
6995 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6996 : :
6997 [ # # ]: 0 : if (verify) {
6998 [ # # ]: 0 : if (ut_params->obuf)
6999 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7000 : : plaintext_len, buffer);
7001 : : else
7002 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7003 : : plaintext_len, buffer);
7004 : :
7005 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
7006 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
7007 : 0 : debug_hexdump(stdout, "plaintext expected:",
7008 : 0 : tdata->plaintext.data,
7009 : 0 : (tdata->plaintext.len >> 3) - tdata->digest.len);
7010 : : } else {
7011 [ # # ]: 0 : if (ut_params->obuf)
7012 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7013 : : ciphertext_len, buffer);
7014 : : else
7015 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7016 : : ciphertext_len, buffer);
7017 : :
7018 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
7019 : : ciphertext_len);
7020 : 0 : debug_hexdump(stdout, "ciphertext expected:",
7021 : 0 : tdata->ciphertext.data, tdata->ciphertext.len >> 3);
7022 : :
7023 [ # # ]: 0 : if (ut_params->obuf)
7024 : 0 : digest = rte_pktmbuf_read(ut_params->obuf,
7025 : 0 : (tdata->digest.offset_bytes == 0 ?
7026 : : plaintext_pad_len : tdata->digest.offset_bytes),
7027 [ # # ]: 0 : tdata->digest.len, digest_buffer);
7028 : : else
7029 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
7030 : 0 : (tdata->digest.offset_bytes == 0 ?
7031 : : plaintext_pad_len : tdata->digest.offset_bytes),
7032 [ # # ]: 0 : tdata->digest.len, digest_buffer);
7033 : :
7034 : 0 : debug_hexdump(stdout, "digest:", digest,
7035 : 0 : tdata->digest.len);
7036 : 0 : debug_hexdump(stdout, "digest expected:",
7037 : 0 : tdata->digest.data, tdata->digest.len);
7038 : : }
7039 : :
7040 : : /* Validate obuf */
7041 [ # # ]: 0 : if (verify) {
7042 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
7043 : : plaintext,
7044 : : tdata->plaintext.data,
7045 : : tdata->plaintext.len >> 3,
7046 : : "ZUC Plaintext data not as expected");
7047 : : } else {
7048 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
7049 : : ciphertext,
7050 : : tdata->ciphertext.data,
7051 : : tdata->validDataLenInBits.len,
7052 : : "ZUC Ciphertext data not as expected");
7053 : :
7054 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
7055 : : digest,
7056 : : tdata->digest.data,
7057 : : tdata->digest.len,
7058 : : "ZUC Generated auth tag not as expected");
7059 : : }
7060 : : return 0;
7061 : : }
7062 : :
7063 : : static int
7064 : 0 : test_kasumi_encryption_test_case_1(void)
7065 : : {
7066 : 0 : return test_kasumi_encryption(&kasumi_test_case_1);
7067 : : }
7068 : :
7069 : : static int
7070 : 0 : test_kasumi_encryption_test_case_1_sgl(void)
7071 : : {
7072 : 0 : return test_kasumi_encryption_sgl(&kasumi_test_case_1);
7073 : : }
7074 : :
7075 : : static int
7076 : 0 : test_kasumi_encryption_test_case_1_oop(void)
7077 : : {
7078 : 0 : return test_kasumi_encryption_oop(&kasumi_test_case_1);
7079 : : }
7080 : :
7081 : : static int
7082 : 0 : test_kasumi_encryption_test_case_1_oop_sgl(void)
7083 : : {
7084 : 0 : return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
7085 : : }
7086 : :
7087 : : static int
7088 : 0 : test_kasumi_encryption_test_case_2(void)
7089 : : {
7090 : 0 : return test_kasumi_encryption(&kasumi_test_case_2);
7091 : : }
7092 : :
7093 : : static int
7094 : 0 : test_kasumi_encryption_test_case_3(void)
7095 : : {
7096 : 0 : return test_kasumi_encryption(&kasumi_test_case_3);
7097 : : }
7098 : :
7099 : : static int
7100 : 0 : test_kasumi_encryption_test_case_4(void)
7101 : : {
7102 : 0 : return test_kasumi_encryption(&kasumi_test_case_4);
7103 : : }
7104 : :
7105 : : static int
7106 : 0 : test_kasumi_encryption_test_case_5(void)
7107 : : {
7108 : 0 : return test_kasumi_encryption(&kasumi_test_case_5);
7109 : : }
7110 : :
7111 : : static int
7112 : 0 : test_kasumi_decryption_test_case_1(void)
7113 : : {
7114 : 0 : return test_kasumi_decryption(&kasumi_test_case_1);
7115 : : }
7116 : :
7117 : : static int
7118 : 0 : test_kasumi_decryption_test_case_1_oop(void)
7119 : : {
7120 : 0 : return test_kasumi_decryption_oop(&kasumi_test_case_1);
7121 : : }
7122 : :
7123 : : static int
7124 : 0 : test_kasumi_decryption_test_case_2(void)
7125 : : {
7126 : 0 : return test_kasumi_decryption(&kasumi_test_case_2);
7127 : : }
7128 : :
7129 : : static int
7130 : 0 : test_kasumi_decryption_test_case_3(void)
7131 : : {
7132 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7133 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7134 : : return TEST_SKIPPED;
7135 : 0 : return test_kasumi_decryption(&kasumi_test_case_3);
7136 : : }
7137 : :
7138 : : static int
7139 : 0 : test_kasumi_decryption_test_case_4(void)
7140 : : {
7141 : 0 : return test_kasumi_decryption(&kasumi_test_case_4);
7142 : : }
7143 : :
7144 : : static int
7145 : 0 : test_kasumi_decryption_test_case_5(void)
7146 : : {
7147 : 0 : return test_kasumi_decryption(&kasumi_test_case_5);
7148 : : }
7149 : : static int
7150 : 0 : test_snow3g_encryption_test_case_1(void)
7151 : : {
7152 : 0 : return test_snow3g_encryption(&snow3g_test_case_1);
7153 : : }
7154 : :
7155 : : static int
7156 : 0 : test_snow3g_encryption_test_case_1_oop(void)
7157 : : {
7158 : 0 : return test_snow3g_encryption_oop(&snow3g_test_case_1);
7159 : : }
7160 : :
7161 : : static int
7162 : 0 : test_snow3g_encryption_test_case_1_oop_sgl(void)
7163 : : {
7164 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 1);
7165 : : }
7166 : :
7167 : : static int
7168 : 0 : test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out(void)
7169 : : {
7170 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 0, 1);
7171 : : }
7172 : :
7173 : : static int
7174 : 0 : test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out(void)
7175 : : {
7176 : 0 : return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1, 1, 0);
7177 : : }
7178 : :
7179 : : static int
7180 : 0 : test_snow3g_encryption_test_case_1_offset_oop(void)
7181 : : {
7182 : 0 : return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
7183 : : }
7184 : :
7185 : : static int
7186 : 0 : test_snow3g_encryption_test_case_2(void)
7187 : : {
7188 : 0 : return test_snow3g_encryption(&snow3g_test_case_2);
7189 : : }
7190 : :
7191 : : static int
7192 : 0 : test_snow3g_encryption_test_case_3(void)
7193 : : {
7194 : 0 : return test_snow3g_encryption(&snow3g_test_case_3);
7195 : : }
7196 : :
7197 : : static int
7198 : 0 : test_snow3g_encryption_test_case_4(void)
7199 : : {
7200 : 0 : return test_snow3g_encryption(&snow3g_test_case_4);
7201 : : }
7202 : :
7203 : : static int
7204 : 0 : test_snow3g_encryption_test_case_5(void)
7205 : : {
7206 : 0 : return test_snow3g_encryption(&snow3g_test_case_5);
7207 : : }
7208 : :
7209 : : static int
7210 : 0 : test_snow3g_decryption_test_case_1(void)
7211 : : {
7212 : 0 : return test_snow3g_decryption(&snow3g_test_case_1);
7213 : : }
7214 : :
7215 : : static int
7216 : 0 : test_snow3g_decryption_test_case_1_oop(void)
7217 : : {
7218 : 0 : return test_snow3g_decryption_oop(&snow3g_test_case_1);
7219 : : }
7220 : :
7221 : : static int
7222 : 0 : test_snow3g_decryption_test_case_2(void)
7223 : : {
7224 : 0 : return test_snow3g_decryption(&snow3g_test_case_2);
7225 : : }
7226 : :
7227 : : static int
7228 : 0 : test_snow3g_decryption_test_case_3(void)
7229 : : {
7230 : 0 : return test_snow3g_decryption(&snow3g_test_case_3);
7231 : : }
7232 : :
7233 : : static int
7234 : 0 : test_snow3g_decryption_test_case_4(void)
7235 : : {
7236 : 0 : return test_snow3g_decryption(&snow3g_test_case_4);
7237 : : }
7238 : :
7239 : : static int
7240 : 0 : test_snow3g_decryption_test_case_5(void)
7241 : : {
7242 : 0 : return test_snow3g_decryption(&snow3g_test_case_5);
7243 : : }
7244 : :
7245 : : /*
7246 : : * Function prepares snow3g_hash_test_data from snow3g_test_data.
7247 : : * Pattern digest from snow3g_test_data must be allocated as
7248 : : * 4 last bytes in plaintext.
7249 : : */
7250 : : static void
7251 : 0 : snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
7252 : : struct snow3g_hash_test_data *output)
7253 : : {
7254 [ # # ]: 0 : if ((pattern != NULL) && (output != NULL)) {
7255 : 0 : output->key.len = pattern->key.len;
7256 : :
7257 : 0 : memcpy(output->key.data,
7258 : 0 : pattern->key.data, pattern->key.len);
7259 : :
7260 : 0 : output->auth_iv.len = pattern->auth_iv.len;
7261 : :
7262 : 0 : memcpy(output->auth_iv.data,
7263 : 0 : pattern->auth_iv.data, pattern->auth_iv.len);
7264 : :
7265 : 0 : output->plaintext.len = pattern->plaintext.len;
7266 : :
7267 : 0 : memcpy(output->plaintext.data,
7268 : 0 : pattern->plaintext.data, pattern->plaintext.len >> 3);
7269 : :
7270 : 0 : output->digest.len = pattern->digest.len;
7271 : :
7272 : 0 : memcpy(output->digest.data,
7273 : 0 : &pattern->plaintext.data[pattern->digest.offset_bytes],
7274 : : pattern->digest.len);
7275 : :
7276 : 0 : output->validAuthLenInBits.len =
7277 : 0 : pattern->validAuthLenInBits.len;
7278 : : }
7279 : 0 : }
7280 : :
7281 : : /*
7282 : : * Test case verify computed cipher and digest from snow3g_test_case_7 data.
7283 : : */
7284 : : static int
7285 : 0 : test_snow3g_decryption_with_digest_test_case_1(void)
7286 : : {
7287 : : int ret;
7288 : : struct snow3g_hash_test_data snow3g_hash_data;
7289 : : struct rte_cryptodev_info dev_info;
7290 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
7291 : :
7292 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7293 : 0 : uint64_t feat_flags = dev_info.feature_flags;
7294 : :
7295 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7296 : : printf("Device doesn't support encrypted digest operations.\n");
7297 : 0 : return TEST_SKIPPED;
7298 : : }
7299 : :
7300 : : /*
7301 : : * Function prepare data for hash verification test case.
7302 : : * Digest is allocated in 4 last bytes in plaintext, pattern.
7303 : : */
7304 : 0 : snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
7305 : :
7306 : 0 : ret = test_snow3g_decryption(&snow3g_test_case_7);
7307 [ # # ]: 0 : if (ret != 0)
7308 : : return ret;
7309 : :
7310 : 0 : return test_snow3g_authentication_verify(&snow3g_hash_data);
7311 : : }
7312 : :
7313 : : static int
7314 : 0 : test_snow3g_cipher_auth_test_case_1(void)
7315 : : {
7316 : 0 : return test_snow3g_cipher_auth(&snow3g_test_case_3);
7317 : : }
7318 : :
7319 : : static int
7320 : 0 : test_snow3g_auth_cipher_test_case_1(void)
7321 : : {
7322 : 0 : return test_snow3g_auth_cipher(
7323 : : &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
7324 : : }
7325 : :
7326 : : static int
7327 : 0 : test_snow3g_auth_cipher_test_case_2(void)
7328 : : {
7329 : 0 : return test_snow3g_auth_cipher(
7330 : : &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
7331 : : }
7332 : :
7333 : : static int
7334 : 0 : test_snow3g_auth_cipher_test_case_2_oop(void)
7335 : : {
7336 : 0 : return test_snow3g_auth_cipher(
7337 : : &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7338 : : }
7339 : :
7340 : : static int
7341 : 0 : test_snow3g_auth_cipher_part_digest_enc(void)
7342 : : {
7343 : 0 : return test_snow3g_auth_cipher(
7344 : : &snow3g_auth_cipher_partial_digest_encryption,
7345 : : IN_PLACE, 0);
7346 : : }
7347 : :
7348 : : static int
7349 : 0 : test_snow3g_auth_cipher_part_digest_enc_oop(void)
7350 : : {
7351 : 0 : return test_snow3g_auth_cipher(
7352 : : &snow3g_auth_cipher_partial_digest_encryption,
7353 : : OUT_OF_PLACE, 0);
7354 : : }
7355 : :
7356 : : static int
7357 : 0 : test_snow3g_auth_cipher_test_case_3_sgl(void)
7358 : : {
7359 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7360 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7361 : : return TEST_SKIPPED;
7362 : 0 : return test_snow3g_auth_cipher_sgl(
7363 : : &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
7364 : : }
7365 : :
7366 : : static int
7367 : 0 : test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
7368 : : {
7369 : 0 : return test_snow3g_auth_cipher_sgl(
7370 : : &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
7371 : : }
7372 : :
7373 : : static int
7374 : 0 : test_snow3g_auth_cipher_part_digest_enc_sgl(void)
7375 : : {
7376 : : /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
7377 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7378 : : return TEST_SKIPPED;
7379 : 0 : return test_snow3g_auth_cipher_sgl(
7380 : : &snow3g_auth_cipher_partial_digest_encryption,
7381 : : IN_PLACE, 0);
7382 : : }
7383 : :
7384 : : static int
7385 : 0 : test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
7386 : : {
7387 : 0 : return test_snow3g_auth_cipher_sgl(
7388 : : &snow3g_auth_cipher_partial_digest_encryption,
7389 : : OUT_OF_PLACE, 0);
7390 : : }
7391 : :
7392 : : static int
7393 : 0 : test_snow3g_auth_cipher_total_digest_enc_1(void)
7394 : : {
7395 : 0 : return test_snow3g_auth_cipher(
7396 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7397 : : }
7398 : :
7399 : : static int
7400 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_oop(void)
7401 : : {
7402 : 0 : return test_snow3g_auth_cipher(
7403 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7404 : : }
7405 : :
7406 : : static int
7407 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_sgl(void)
7408 : : {
7409 : 0 : return test_snow3g_auth_cipher_sgl(
7410 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 0);
7411 : : }
7412 : :
7413 : : static int
7414 : 0 : test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl(void)
7415 : : {
7416 : 0 : return test_snow3g_auth_cipher_sgl(
7417 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 0);
7418 : : }
7419 : :
7420 : : static int
7421 : 0 : test_snow3g_auth_cipher_verify_test_case_1(void)
7422 : : {
7423 : 0 : return test_snow3g_auth_cipher(
7424 : : &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
7425 : : }
7426 : :
7427 : : static int
7428 : 0 : test_snow3g_auth_cipher_verify_test_case_2(void)
7429 : : {
7430 : 0 : return test_snow3g_auth_cipher(
7431 : : &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
7432 : : }
7433 : :
7434 : : static int
7435 : 0 : test_snow3g_auth_cipher_verify_test_case_2_oop(void)
7436 : : {
7437 : 0 : return test_snow3g_auth_cipher(
7438 : : &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7439 : : }
7440 : :
7441 : : static int
7442 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc(void)
7443 : : {
7444 : 0 : return test_snow3g_auth_cipher(
7445 : : &snow3g_auth_cipher_partial_digest_encryption,
7446 : : IN_PLACE, 1);
7447 : : }
7448 : :
7449 : : static int
7450 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
7451 : : {
7452 : 0 : return test_snow3g_auth_cipher(
7453 : : &snow3g_auth_cipher_partial_digest_encryption,
7454 : : OUT_OF_PLACE, 1);
7455 : : }
7456 : :
7457 : : static int
7458 : 0 : test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
7459 : : {
7460 : 0 : return test_snow3g_auth_cipher_sgl(
7461 : : &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
7462 : : }
7463 : :
7464 : : static int
7465 : 0 : test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
7466 : : {
7467 : 0 : return test_snow3g_auth_cipher_sgl(
7468 : : &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
7469 : : }
7470 : :
7471 : : static int
7472 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
7473 : : {
7474 : 0 : return test_snow3g_auth_cipher_sgl(
7475 : : &snow3g_auth_cipher_partial_digest_encryption,
7476 : : IN_PLACE, 1);
7477 : : }
7478 : :
7479 : : static int
7480 : 0 : test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
7481 : : {
7482 : 0 : return test_snow3g_auth_cipher_sgl(
7483 : : &snow3g_auth_cipher_partial_digest_encryption,
7484 : : OUT_OF_PLACE, 1);
7485 : : }
7486 : :
7487 : : static int
7488 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1(void)
7489 : : {
7490 : 0 : return test_snow3g_auth_cipher(
7491 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7492 : : }
7493 : :
7494 : : static int
7495 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop(void)
7496 : : {
7497 : 0 : return test_snow3g_auth_cipher(
7498 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7499 : : }
7500 : :
7501 : : static int
7502 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl(void)
7503 : : {
7504 : 0 : return test_snow3g_auth_cipher_sgl(
7505 : : &snow3g_auth_cipher_total_digest_encryption_1, IN_PLACE, 1);
7506 : : }
7507 : :
7508 : : static int
7509 : 0 : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl(void)
7510 : : {
7511 : 0 : return test_snow3g_auth_cipher_sgl(
7512 : : &snow3g_auth_cipher_total_digest_encryption_1, OUT_OF_PLACE, 1);
7513 : : }
7514 : :
7515 : : static int
7516 : 0 : test_snow3g_auth_cipher_with_digest_test_case_1(void)
7517 : : {
7518 : 0 : return test_snow3g_auth_cipher(
7519 : : &snow3g_test_case_7, IN_PLACE, 0);
7520 : : }
7521 : :
7522 : : static int
7523 : 0 : test_kasumi_auth_cipher_test_case_1(void)
7524 : : {
7525 : 0 : return test_kasumi_auth_cipher(
7526 : : &kasumi_test_case_3, IN_PLACE, 0);
7527 : : }
7528 : :
7529 : : static int
7530 : 0 : test_kasumi_auth_cipher_test_case_2(void)
7531 : : {
7532 : 0 : return test_kasumi_auth_cipher(
7533 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7534 : : }
7535 : :
7536 : : static int
7537 : 0 : test_kasumi_auth_cipher_test_case_2_oop(void)
7538 : : {
7539 : 0 : return test_kasumi_auth_cipher(
7540 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7541 : : }
7542 : :
7543 : : static int
7544 : 0 : test_kasumi_auth_cipher_test_case_2_sgl(void)
7545 : : {
7546 : 0 : return test_kasumi_auth_cipher_sgl(
7547 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7548 : : }
7549 : :
7550 : : static int
7551 : 0 : test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
7552 : : {
7553 : 0 : return test_kasumi_auth_cipher_sgl(
7554 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7555 : : }
7556 : :
7557 : : static int
7558 : 0 : test_kasumi_auth_cipher_verify_test_case_1(void)
7559 : : {
7560 : 0 : return test_kasumi_auth_cipher(
7561 : : &kasumi_test_case_3, IN_PLACE, 1);
7562 : : }
7563 : :
7564 : : static int
7565 : 0 : test_kasumi_auth_cipher_verify_test_case_2(void)
7566 : : {
7567 : 0 : return test_kasumi_auth_cipher(
7568 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7569 : : }
7570 : :
7571 : : static int
7572 : 0 : test_kasumi_auth_cipher_verify_test_case_2_oop(void)
7573 : : {
7574 : 0 : return test_kasumi_auth_cipher(
7575 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7576 : : }
7577 : :
7578 : : static int
7579 : 0 : test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
7580 : : {
7581 : 0 : return test_kasumi_auth_cipher_sgl(
7582 : : &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7583 : : }
7584 : :
7585 : : static int
7586 : 0 : test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
7587 : : {
7588 : 0 : return test_kasumi_auth_cipher_sgl(
7589 : : &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7590 : : }
7591 : :
7592 : : static int
7593 : 0 : test_kasumi_cipher_auth_test_case_1(void)
7594 : : {
7595 : 0 : return test_kasumi_cipher_auth(&kasumi_test_case_6);
7596 : : }
7597 : :
7598 : : static int
7599 : 0 : test_zuc_encryption_test_case_1(void)
7600 : : {
7601 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_193b,
7602 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7603 : : }
7604 : :
7605 : : static int
7606 : 0 : test_zuc_encryption_test_case_2(void)
7607 : : {
7608 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_800b,
7609 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7610 : : }
7611 : :
7612 : : static int
7613 : 0 : test_zuc_encryption_test_case_3(void)
7614 : : {
7615 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7616 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7617 : : }
7618 : :
7619 : : static int
7620 : 0 : test_zuc_encryption_test_case_4(void)
7621 : : {
7622 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7623 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7624 : : }
7625 : :
7626 : : static int
7627 : 0 : test_zuc_encryption_test_case_5(void)
7628 : : {
7629 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7630 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7631 : : }
7632 : :
7633 : : static int
7634 : 0 : test_zuc_encryption_test_case_6_sgl(void)
7635 : : {
7636 : 0 : return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7637 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7638 : : }
7639 : :
7640 : : static int
7641 : 0 : test_zuc_decryption_test_case_1(void)
7642 : : {
7643 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_193b,
7644 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7645 : : }
7646 : :
7647 : : static int
7648 : 0 : test_zuc_decryption_test_case_2(void)
7649 : : {
7650 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_800b,
7651 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7652 : : }
7653 : :
7654 : : static int
7655 : 0 : test_zuc_decryption_test_case_3(void)
7656 : : {
7657 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_1570b,
7658 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7659 : : }
7660 : :
7661 : : static int
7662 : 0 : test_zuc_decryption_test_case_4(void)
7663 : : {
7664 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_2798b,
7665 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7666 : : }
7667 : :
7668 : : static int
7669 : 0 : test_zuc_decryption_test_case_5(void)
7670 : : {
7671 : 0 : return test_zuc_cipher(&zuc_test_case_cipher_4019b,
7672 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7673 : : }
7674 : :
7675 : : static int
7676 : 0 : test_zuc_decryption_test_case_6_sgl(void)
7677 : : {
7678 : 0 : return test_zuc_cipher_sgl(&zuc_test_case_cipher_193b,
7679 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7680 : : }
7681 : :
7682 : : static int
7683 : 0 : test_zuc_hash_generate_test_case_1(void)
7684 : : {
7685 : 0 : return test_zuc_authentication(&zuc_test_case_auth_1b,
7686 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7687 : : }
7688 : :
7689 : : static int
7690 : 0 : test_zuc_hash_generate_test_case_2(void)
7691 : : {
7692 : 0 : return test_zuc_authentication(&zuc_test_case_auth_90b,
7693 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7694 : : }
7695 : :
7696 : : static int
7697 : 0 : test_zuc_hash_generate_test_case_3(void)
7698 : : {
7699 : 0 : return test_zuc_authentication(&zuc_test_case_auth_577b,
7700 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7701 : : }
7702 : :
7703 : : static int
7704 : 0 : test_zuc_hash_generate_test_case_4(void)
7705 : : {
7706 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2079b,
7707 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7708 : : }
7709 : :
7710 : : static int
7711 : 0 : test_zuc_hash_generate_test_case_5(void)
7712 : : {
7713 : 0 : return test_zuc_authentication(&zuc_test_auth_5670b,
7714 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7715 : : }
7716 : :
7717 : : static int
7718 : 0 : test_zuc_hash_generate_test_case_6(void)
7719 : : {
7720 : 0 : return test_zuc_authentication(&zuc_test_case_auth_128b,
7721 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7722 : : }
7723 : :
7724 : : static int
7725 : 0 : test_zuc_hash_generate_test_case_7(void)
7726 : : {
7727 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2080b,
7728 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7729 : : }
7730 : :
7731 : : static int
7732 : 0 : test_zuc_hash_generate_test_case_8(void)
7733 : : {
7734 : 0 : return test_zuc_authentication(&zuc_test_case_auth_584b,
7735 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7736 : : }
7737 : :
7738 : : static int
7739 : 0 : test_zuc_hash_verify_test_case_1(void)
7740 : : {
7741 : 0 : return test_zuc_authentication(&zuc_test_case_auth_1b,
7742 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7743 : : }
7744 : :
7745 : : static int
7746 : 0 : test_zuc_hash_verify_test_case_2(void)
7747 : : {
7748 : 0 : return test_zuc_authentication(&zuc_test_case_auth_90b,
7749 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7750 : : }
7751 : :
7752 : : static int
7753 : 0 : test_zuc_hash_verify_test_case_3(void)
7754 : : {
7755 : 0 : return test_zuc_authentication(&zuc_test_case_auth_577b,
7756 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7757 : : }
7758 : :
7759 : : static int
7760 : 0 : test_zuc_hash_verify_test_case_4(void)
7761 : : {
7762 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2079b,
7763 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7764 : : }
7765 : :
7766 : : static int
7767 : 0 : test_zuc_hash_verify_test_case_5(void)
7768 : : {
7769 : 0 : return test_zuc_authentication(&zuc_test_auth_5670b,
7770 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7771 : : }
7772 : :
7773 : : static int
7774 : 0 : test_zuc_hash_verify_test_case_6(void)
7775 : : {
7776 : 0 : return test_zuc_authentication(&zuc_test_case_auth_128b,
7777 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7778 : : }
7779 : :
7780 : : static int
7781 : 0 : test_zuc_hash_verify_test_case_7(void)
7782 : : {
7783 : 0 : return test_zuc_authentication(&zuc_test_case_auth_2080b,
7784 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7785 : : }
7786 : :
7787 : : static int
7788 : 0 : test_zuc_hash_verify_test_case_8(void)
7789 : : {
7790 : 0 : return test_zuc_authentication(&zuc_test_case_auth_584b,
7791 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7792 : : }
7793 : :
7794 : : static int
7795 : 0 : test_zuc_cipher_auth_test_case_1(void)
7796 : : {
7797 : 0 : return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7798 : : }
7799 : :
7800 : : static int
7801 : 0 : test_zuc_cipher_auth_test_case_2(void)
7802 : : {
7803 : 0 : return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7804 : : }
7805 : :
7806 : : static int
7807 : 0 : test_zuc_auth_cipher_test_case_1(void)
7808 : : {
7809 : 0 : return test_zuc_auth_cipher(
7810 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7811 : : }
7812 : :
7813 : : static int
7814 : 0 : test_zuc_auth_cipher_test_case_1_oop(void)
7815 : : {
7816 : 0 : return test_zuc_auth_cipher(
7817 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7818 : : }
7819 : :
7820 : : static int
7821 : 0 : test_zuc_auth_cipher_test_case_1_sgl(void)
7822 : : {
7823 : 0 : return test_zuc_auth_cipher_sgl(
7824 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7825 : : }
7826 : :
7827 : : static int
7828 : 0 : test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7829 : : {
7830 : 0 : return test_zuc_auth_cipher_sgl(
7831 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7832 : : }
7833 : :
7834 : : static int
7835 : 0 : test_zuc_auth_cipher_test_case_2(void)
7836 : : {
7837 : 0 : return test_zuc_auth_cipher(
7838 : : &zuc_auth_cipher_test_case_2, IN_PLACE, 0);
7839 : : }
7840 : :
7841 : : static int
7842 : 0 : test_zuc_auth_cipher_test_case_2_oop(void)
7843 : : {
7844 : 0 : return test_zuc_auth_cipher(
7845 : : &zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7846 : : }
7847 : :
7848 : : static int
7849 : 0 : test_zuc_auth_cipher_verify_test_case_1(void)
7850 : : {
7851 : 0 : return test_zuc_auth_cipher(
7852 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7853 : : }
7854 : :
7855 : : static int
7856 : 0 : test_zuc_auth_cipher_verify_test_case_1_oop(void)
7857 : : {
7858 : 0 : return test_zuc_auth_cipher(
7859 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7860 : : }
7861 : :
7862 : : static int
7863 : 0 : test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7864 : : {
7865 : 0 : return test_zuc_auth_cipher_sgl(
7866 : : &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7867 : : }
7868 : :
7869 : : static int
7870 : 0 : test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7871 : : {
7872 : 0 : return test_zuc_auth_cipher_sgl(
7873 : : &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7874 : : }
7875 : :
7876 : : static int
7877 : 0 : test_zuc_auth_cipher_verify_test_case_2(void)
7878 : : {
7879 : 0 : return test_zuc_auth_cipher(
7880 : : &zuc_auth_cipher_test_case_2, IN_PLACE, 1);
7881 : : }
7882 : :
7883 : : static int
7884 : 0 : test_zuc_auth_cipher_verify_test_case_2_oop(void)
7885 : : {
7886 : 0 : return test_zuc_auth_cipher(
7887 : : &zuc_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7888 : : }
7889 : :
7890 : : static int
7891 : 0 : test_zuc256_encryption_test_case_1(void)
7892 : : {
7893 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_1,
7894 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7895 : : }
7896 : :
7897 : : static int
7898 : 0 : test_zuc256_encryption_test_case_2(void)
7899 : : {
7900 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_2,
7901 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT);
7902 : : }
7903 : :
7904 : : static int
7905 : 0 : test_zuc256_decryption_test_case_1(void)
7906 : : {
7907 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_1,
7908 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7909 : : }
7910 : :
7911 : : static int
7912 : 0 : test_zuc256_decryption_test_case_2(void)
7913 : : {
7914 : 0 : return test_zuc_cipher(&zuc256_test_case_cipher_2,
7915 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
7916 : : }
7917 : :
7918 : : static int
7919 : 0 : test_zuc256_hash_generate_4b_tag_test_case_1(void)
7920 : : {
7921 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_1,
7922 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7923 : : }
7924 : :
7925 : : static int
7926 : 0 : test_zuc256_hash_generate_4b_tag_test_case_2(void)
7927 : : {
7928 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_2,
7929 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7930 : : }
7931 : :
7932 : : static int
7933 : 0 : test_zuc256_hash_generate_4b_tag_test_case_3(void)
7934 : : {
7935 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
7936 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7937 : : }
7938 : :
7939 : : static int
7940 : 0 : test_zuc256_hash_generate_8b_tag_test_case_1(void)
7941 : : {
7942 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
7943 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7944 : : }
7945 : :
7946 : : static int
7947 : 0 : test_zuc256_hash_generate_16b_tag_test_case_1(void)
7948 : : {
7949 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
7950 : : RTE_CRYPTO_AUTH_OP_GENERATE);
7951 : : }
7952 : :
7953 : : static int
7954 : 0 : test_zuc256_hash_verify_4b_tag_test_case_1(void)
7955 : : {
7956 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_1,
7957 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7958 : : }
7959 : :
7960 : : static int
7961 : 0 : test_zuc256_hash_verify_4b_tag_test_case_2(void)
7962 : : {
7963 : 0 : return test_zuc_authentication(&zuc256_test_case_auth_2,
7964 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7965 : : }
7966 : :
7967 : : static int
7968 : 0 : test_zuc256_hash_verify_4b_tag_test_case_3(void)
7969 : : {
7970 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b,
7971 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7972 : : }
7973 : :
7974 : : static int
7975 : 0 : test_zuc256_hash_verify_8b_tag_test_case_1(void)
7976 : : {
7977 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b,
7978 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7979 : : }
7980 : :
7981 : : static int
7982 : 0 : test_zuc256_hash_verify_16b_tag_test_case_1(void)
7983 : : {
7984 : 0 : return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b,
7985 : : RTE_CRYPTO_AUTH_OP_VERIFY);
7986 : : }
7987 : :
7988 : : static int
7989 : 0 : test_zuc256_cipher_auth_4b_tag_test_case_1(void)
7990 : : {
7991 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_1);
7992 : : }
7993 : :
7994 : : static int
7995 : 0 : test_zuc256_cipher_auth_4b_tag_test_case_2(void)
7996 : : {
7997 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_2);
7998 : : }
7999 : :
8000 : : static int
8001 : 0 : test_zuc256_cipher_auth_8b_tag_test_case_1(void)
8002 : : {
8003 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_3);
8004 : : }
8005 : :
8006 : : static int
8007 : 0 : test_zuc256_cipher_auth_16b_tag_test_case_1(void)
8008 : : {
8009 : 0 : return test_zuc_cipher_auth(&zuc256_test_case_cipher_auth_4);
8010 : : }
8011 : :
8012 : : static int
8013 : 0 : test_zuc256_auth_cipher_4b_tag_test_case_1(void)
8014 : : {
8015 : 0 : return test_zuc_auth_cipher(
8016 : : &zuc256_auth_cipher_test_case_1, IN_PLACE, 0);
8017 : : }
8018 : :
8019 : : static int
8020 : 0 : test_zuc256_auth_cipher_4b_tag_test_case_2(void)
8021 : : {
8022 : 0 : return test_zuc_auth_cipher(
8023 : : &zuc256_auth_cipher_test_case_2, IN_PLACE, 0);
8024 : : }
8025 : :
8026 : : static int
8027 : 0 : test_zuc256_auth_cipher_8b_tag_test_case_1(void)
8028 : : {
8029 : 0 : return test_zuc_auth_cipher(
8030 : : &zuc256_auth_cipher_test_case_3, IN_PLACE, 0);
8031 : : }
8032 : :
8033 : : static int
8034 : 0 : test_zuc256_auth_cipher_16b_tag_test_case_1(void)
8035 : : {
8036 : 0 : return test_zuc_auth_cipher(
8037 : : &zuc256_auth_cipher_test_case_4, IN_PLACE, 0);
8038 : : }
8039 : :
8040 : : static int
8041 : 0 : test_zuc256_auth_cipher_verify_4b_tag_test_case_1(void)
8042 : : {
8043 : 0 : return test_zuc_auth_cipher(
8044 : : &zuc256_auth_cipher_test_case_1, IN_PLACE, 1);
8045 : : }
8046 : :
8047 : : static int
8048 : 0 : test_zuc256_auth_cipher_verify_4b_tag_test_case_2(void)
8049 : : {
8050 : 0 : return test_zuc_auth_cipher(
8051 : : &zuc256_auth_cipher_test_case_2, IN_PLACE, 1);
8052 : : }
8053 : :
8054 : : static int
8055 : 0 : test_zuc256_auth_cipher_verify_8b_tag_test_case_1(void)
8056 : : {
8057 : 0 : return test_zuc_auth_cipher(
8058 : : &zuc256_auth_cipher_test_case_3, IN_PLACE, 1);
8059 : : }
8060 : :
8061 : : static int
8062 : 0 : test_zuc256_auth_cipher_verify_16b_tag_test_case_1(void)
8063 : : {
8064 : 0 : return test_zuc_auth_cipher(
8065 : : &zuc256_auth_cipher_test_case_4, IN_PLACE, 1);
8066 : : }
8067 : :
8068 : : static int
8069 : 50 : test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
8070 : : {
8071 : 50 : uint8_t dev_id = testsuite_params.valid_devs[0];
8072 : :
8073 : : struct rte_cryptodev_sym_capability_idx cap_idx;
8074 : :
8075 : : /* Check if device supports particular cipher algorithm */
8076 : 50 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8077 : 50 : cap_idx.algo.cipher = tdata->cipher_algo;
8078 [ + + ]: 50 : if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
8079 : : return TEST_SKIPPED;
8080 : :
8081 : : /* Check if device supports particular hash algorithm */
8082 : 24 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8083 : 24 : cap_idx.algo.auth = tdata->auth_algo;
8084 [ + + ]: 24 : if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
8085 : 12 : return TEST_SKIPPED;
8086 : :
8087 : : return 0;
8088 : : }
8089 : :
8090 : : static int
8091 : 44 : test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
8092 : : uint8_t op_mode, uint8_t verify)
8093 : : {
8094 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
8095 : : struct crypto_unittest_params *ut_params = &unittest_params;
8096 : :
8097 : : int retval;
8098 : :
8099 : : uint8_t *plaintext = NULL, *ciphertext = NULL;
8100 : : unsigned int plaintext_pad_len;
8101 : : unsigned int plaintext_len;
8102 : : unsigned int ciphertext_pad_len;
8103 : : unsigned int ciphertext_len;
8104 : : unsigned int digest_offset;
8105 : :
8106 : : struct rte_cryptodev_info dev_info;
8107 : : struct rte_crypto_op *op;
8108 : :
8109 : : /* Check if device supports particular algorithms separately */
8110 [ + + ]: 44 : if (test_mixed_check_if_unsupported(tdata))
8111 : : return TEST_SKIPPED;
8112 [ + - ]: 8 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8113 : : return TEST_SKIPPED;
8114 : :
8115 [ + - ]: 8 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8116 : : return TEST_SKIPPED;
8117 : :
8118 : 8 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8119 : :
8120 : 8 : uint64_t feat_flags = dev_info.feature_flags;
8121 : :
8122 [ + - ]: 8 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
8123 : : printf("Device doesn't support digest encrypted.\n");
8124 : 8 : return TEST_SKIPPED;
8125 : : }
8126 : :
8127 : : /* Create the session */
8128 [ # # ]: 0 : if (verify)
8129 : 0 : retval = create_wireless_algo_cipher_auth_session(
8130 : 0 : ts_params->valid_devs[0],
8131 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
8132 : : RTE_CRYPTO_AUTH_OP_VERIFY,
8133 : 0 : tdata->auth_algo,
8134 : 0 : tdata->cipher_algo,
8135 : 0 : tdata->auth_key.data, tdata->auth_key.len,
8136 : 0 : tdata->cipher_key.data, tdata->cipher_key.len,
8137 : 0 : tdata->auth_iv.len, tdata->digest_enc.len,
8138 : 0 : tdata->cipher_iv.len);
8139 : : else
8140 : 0 : retval = create_wireless_algo_auth_cipher_session(
8141 : 0 : ts_params->valid_devs[0],
8142 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8143 : : RTE_CRYPTO_AUTH_OP_GENERATE,
8144 : 0 : tdata->auth_algo,
8145 : 0 : tdata->cipher_algo,
8146 : 0 : tdata->auth_key.data, tdata->auth_key.len,
8147 : 0 : tdata->cipher_key.data, tdata->cipher_key.len,
8148 : 0 : tdata->auth_iv.len, tdata->digest_enc.len,
8149 : 0 : tdata->cipher_iv.len);
8150 [ # # ]: 0 : if (retval != 0)
8151 : : return retval;
8152 : :
8153 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8154 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
8155 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8156 : :
8157 : : /* clear mbuf payload */
8158 [ # # ]: 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8159 [ # # ]: 0 : rte_pktmbuf_tailroom(ut_params->ibuf));
8160 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE) {
8161 : :
8162 : 0 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8163 : 0 : rte_pktmbuf_tailroom(ut_params->obuf));
8164 : : }
8165 : :
8166 [ # # ]: 0 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8167 [ # # ]: 0 : plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8168 : 0 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8169 : 0 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8170 : :
8171 [ # # ]: 0 : if (verify) {
8172 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8173 : : ciphertext_pad_len);
8174 : 0 : memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
8175 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8176 : : ciphertext_len);
8177 : : } else {
8178 : : /* make sure enough space to cover partial digest verify case */
8179 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8180 : : ciphertext_pad_len);
8181 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8182 : 0 : debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
8183 : : }
8184 : :
8185 [ # # ]: 0 : if (op_mode == OUT_OF_PLACE)
8186 : 0 : rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
8187 : :
8188 : : /* Create the operation */
8189 : 0 : retval = create_wireless_algo_auth_cipher_operation(
8190 : 0 : tdata->digest_enc.data, tdata->digest_enc.len,
8191 : 0 : tdata->cipher_iv.data, tdata->cipher_iv.len,
8192 : 0 : tdata->auth_iv.data, tdata->auth_iv.len,
8193 : 0 : (tdata->digest_enc.offset == 0 ?
8194 : : plaintext_pad_len
8195 : : : tdata->digest_enc.offset),
8196 : 0 : tdata->validCipherLen.len_bits,
8197 : 0 : tdata->cipher.offset_bits,
8198 : 0 : tdata->validAuthLen.len_bits,
8199 [ # # ]: 0 : tdata->auth.offset_bits,
8200 : : op_mode, 0, verify);
8201 : :
8202 [ # # ]: 0 : if (retval < 0)
8203 : : return retval;
8204 : :
8205 : 0 : op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8206 : :
8207 : : /* Check if the op failed because the device doesn't */
8208 : : /* support this particular combination of algorithms */
8209 [ # # # # ]: 0 : if (op == NULL && ut_params->op->status ==
8210 : : RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8211 : : printf("Device doesn't support this mixed combination. "
8212 : : "Test Skipped.\n");
8213 : 0 : return TEST_SKIPPED;
8214 : : }
8215 : 0 : ut_params->op = op;
8216 : :
8217 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8218 : :
8219 : 0 : ut_params->obuf = (op_mode == IN_PLACE ?
8220 [ # # ]: 0 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8221 : :
8222 [ # # ]: 0 : if (verify) {
8223 [ # # ]: 0 : if (ut_params->obuf)
8224 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->obuf,
8225 : : uint8_t *);
8226 : : else
8227 : 0 : plaintext = ciphertext +
8228 : 0 : (tdata->cipher.offset_bits >> 3);
8229 : :
8230 : 0 : debug_hexdump(stdout, "plaintext:", plaintext,
8231 : 0 : tdata->plaintext.len_bits >> 3);
8232 : 0 : debug_hexdump(stdout, "plaintext expected:",
8233 : 0 : tdata->plaintext.data,
8234 : 0 : tdata->plaintext.len_bits >> 3);
8235 : : } else {
8236 [ # # ]: 0 : if (ut_params->obuf)
8237 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
8238 : : uint8_t *);
8239 : : else
8240 : : ciphertext = plaintext;
8241 : :
8242 : 0 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8243 : : ciphertext_len);
8244 : 0 : debug_hexdump(stdout, "ciphertext expected:",
8245 : 0 : tdata->ciphertext.data,
8246 : 0 : tdata->ciphertext.len_bits >> 3);
8247 : :
8248 [ # # ]: 0 : if (tdata->digest_enc.offset == 0)
8249 : : digest_offset = plaintext_pad_len;
8250 : : else
8251 : : digest_offset = tdata->digest_enc.offset;
8252 : :
8253 : 0 : ut_params->digest = rte_pktmbuf_mtod_offset(ut_params->obuf,
8254 : : uint8_t *, digest_offset);
8255 : :
8256 : 0 : debug_hexdump(stdout, "digest:", ut_params->digest,
8257 : 0 : tdata->digest_enc.len);
8258 : 0 : debug_hexdump(stdout, "digest expected:",
8259 : : tdata->digest_enc.data,
8260 : 0 : tdata->digest_enc.len);
8261 : : }
8262 : :
8263 [ # # ]: 0 : if (!verify) {
8264 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
8265 : : ut_params->digest,
8266 : : tdata->digest_enc.data,
8267 : : tdata->digest_enc.len,
8268 : : "Generated auth tag not as expected");
8269 : : }
8270 : :
8271 [ # # ]: 0 : if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8272 [ # # ]: 0 : if (verify) {
8273 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
8274 : : plaintext,
8275 : : tdata->plaintext.data,
8276 : : tdata->plaintext.len_bits >> 3,
8277 : : "Plaintext data not as expected");
8278 : : } else {
8279 [ # # # # : 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
# # ]
8280 : : ciphertext,
8281 : : tdata->ciphertext.data,
8282 : : tdata->validDataLen.len_bits,
8283 : : "Ciphertext data not as expected");
8284 : : }
8285 : : }
8286 : :
8287 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8288 : : "crypto op processing failed");
8289 : :
8290 : : return 0;
8291 : : }
8292 : :
8293 : : static int
8294 : 6 : test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
8295 : : uint8_t op_mode, uint8_t verify)
8296 : : {
8297 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
8298 : : struct crypto_unittest_params *ut_params = &unittest_params;
8299 : :
8300 : : int retval;
8301 : :
8302 : : const uint8_t *plaintext = NULL;
8303 : : const uint8_t *ciphertext = NULL;
8304 : : const uint8_t *digest = NULL;
8305 : : unsigned int plaintext_pad_len;
8306 : : unsigned int plaintext_len;
8307 : : unsigned int ciphertext_pad_len;
8308 : : unsigned int ciphertext_len;
8309 : : uint8_t buffer[10000];
8310 : : uint8_t digest_buffer[10000];
8311 : :
8312 : : struct rte_cryptodev_info dev_info;
8313 : : struct rte_crypto_op *op;
8314 : :
8315 : : /* Check if device supports particular algorithms */
8316 [ + + ]: 6 : if (test_mixed_check_if_unsupported(tdata))
8317 : : return TEST_SKIPPED;
8318 [ + - ]: 4 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8319 : : return TEST_SKIPPED;
8320 : :
8321 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8322 : :
8323 : 4 : uint64_t feat_flags = dev_info.feature_flags;
8324 : :
8325 [ + + ]: 4 : if (op_mode == IN_PLACE) {
8326 [ - + ]: 2 : if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
8327 : : printf("Device doesn't support in-place scatter-gather "
8328 : : "in both input and output mbufs.\n");
8329 : 0 : return TEST_SKIPPED;
8330 : : }
8331 : : } else {
8332 [ + - ]: 2 : if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
8333 : : printf("Device doesn't support out-of-place scatter-gather "
8334 : : "in both input and output mbufs.\n");
8335 : 2 : return TEST_SKIPPED;
8336 : : }
8337 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
8338 : : printf("Device doesn't support digest encrypted.\n");
8339 : 0 : return TEST_SKIPPED;
8340 : : }
8341 : : }
8342 : :
8343 [ + - ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8344 : : return TEST_SKIPPED;
8345 : :
8346 : : /* Create the session */
8347 [ + + ]: 2 : if (verify)
8348 : 1 : retval = create_wireless_algo_cipher_auth_session(
8349 : 1 : ts_params->valid_devs[0],
8350 : : RTE_CRYPTO_CIPHER_OP_DECRYPT,
8351 : : RTE_CRYPTO_AUTH_OP_VERIFY,
8352 : 1 : tdata->auth_algo,
8353 : 1 : tdata->cipher_algo,
8354 : 1 : tdata->auth_key.data, tdata->auth_key.len,
8355 : 1 : tdata->cipher_key.data, tdata->cipher_key.len,
8356 : 1 : tdata->auth_iv.len, tdata->digest_enc.len,
8357 : 1 : tdata->cipher_iv.len);
8358 : : else
8359 : 1 : retval = create_wireless_algo_auth_cipher_session(
8360 : 1 : ts_params->valid_devs[0],
8361 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8362 : : RTE_CRYPTO_AUTH_OP_GENERATE,
8363 : 1 : tdata->auth_algo,
8364 : 1 : tdata->cipher_algo,
8365 : 1 : tdata->auth_key.data, tdata->auth_key.len,
8366 : 1 : tdata->cipher_key.data, tdata->cipher_key.len,
8367 : 1 : tdata->auth_iv.len, tdata->digest_enc.len,
8368 : 1 : tdata->cipher_iv.len);
8369 [ + - ]: 2 : if (retval != 0)
8370 : : return retval;
8371 : :
8372 [ - + ]: 2 : ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
8373 [ - + ]: 2 : plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
8374 : 2 : ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
8375 : 2 : plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
8376 : :
8377 : 2 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
8378 : : ciphertext_pad_len, 15, 0);
8379 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8380 : : "Failed to allocate input buffer in mempool");
8381 : :
8382 [ - + ]: 2 : if (op_mode == OUT_OF_PLACE) {
8383 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
8384 : : plaintext_pad_len, 15, 0);
8385 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->obuf,
8386 : : "Failed to allocate output buffer in mempool");
8387 : : }
8388 : :
8389 [ + + ]: 2 : if (verify) {
8390 : 1 : pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
8391 : 1 : tdata->ciphertext.data);
8392 [ - + ]: 1 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8393 : : ciphertext_len, buffer);
8394 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8395 : : ciphertext_len);
8396 : : } else {
8397 : 1 : pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
8398 : 1 : tdata->plaintext.data);
8399 [ - + ]: 1 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8400 : : plaintext_len, buffer);
8401 : 1 : debug_hexdump(stdout, "plaintext:", plaintext,
8402 : : plaintext_len);
8403 : : }
8404 : : memset(buffer, 0, sizeof(buffer));
8405 : :
8406 : : /* Create the operation */
8407 : 4 : retval = create_wireless_algo_auth_cipher_operation(
8408 : 2 : tdata->digest_enc.data, tdata->digest_enc.len,
8409 : 2 : tdata->cipher_iv.data, tdata->cipher_iv.len,
8410 : 2 : tdata->auth_iv.data, tdata->auth_iv.len,
8411 : 2 : (tdata->digest_enc.offset == 0 ?
8412 : : plaintext_pad_len
8413 : : : tdata->digest_enc.offset),
8414 : 2 : tdata->validCipherLen.len_bits,
8415 : 2 : tdata->cipher.offset_bits,
8416 : 2 : tdata->validAuthLen.len_bits,
8417 [ + - ]: 2 : tdata->auth.offset_bits,
8418 : : op_mode, 1, verify);
8419 : :
8420 [ + - ]: 2 : if (retval < 0)
8421 : : return retval;
8422 : :
8423 : 2 : op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
8424 : :
8425 : : /* Check if the op failed because the device doesn't */
8426 : : /* support this particular combination of algorithms */
8427 [ - + - - ]: 2 : if (op == NULL && ut_params->op->status ==
8428 : : RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
8429 : : printf("Device doesn't support this mixed combination. "
8430 : : "Test Skipped.\n");
8431 : 0 : return TEST_SKIPPED;
8432 : : }
8433 : 2 : ut_params->op = op;
8434 : :
8435 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
8436 : :
8437 : 2 : ut_params->obuf = (op_mode == IN_PLACE ?
8438 [ + - ]: 2 : ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
8439 : :
8440 [ + + ]: 2 : if (verify) {
8441 [ + - ]: 1 : if (ut_params->obuf)
8442 : : plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
8443 : : plaintext_len, buffer);
8444 : : else
8445 [ # # ]: 0 : plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
8446 : : plaintext_len, buffer);
8447 : :
8448 : 1 : debug_hexdump(stdout, "plaintext:", plaintext,
8449 : 1 : (tdata->plaintext.len_bits >> 3) -
8450 : 1 : tdata->digest_enc.len);
8451 : 1 : debug_hexdump(stdout, "plaintext expected:",
8452 : 1 : tdata->plaintext.data,
8453 : 1 : (tdata->plaintext.len_bits >> 3) -
8454 : 1 : tdata->digest_enc.len);
8455 : : } else {
8456 [ + - ]: 1 : if (ut_params->obuf)
8457 : : ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
8458 : : ciphertext_len, buffer);
8459 : : else
8460 [ # # ]: 0 : ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
8461 : : ciphertext_len, buffer);
8462 : :
8463 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext,
8464 : : ciphertext_len);
8465 : 1 : debug_hexdump(stdout, "ciphertext expected:",
8466 : 1 : tdata->ciphertext.data,
8467 : 1 : tdata->ciphertext.len_bits >> 3);
8468 : :
8469 [ + - ]: 1 : if (ut_params->obuf)
8470 : 1 : digest = rte_pktmbuf_read(ut_params->obuf,
8471 : 1 : (tdata->digest_enc.offset == 0 ?
8472 : : plaintext_pad_len :
8473 : : tdata->digest_enc.offset),
8474 [ + - ]: 1 : tdata->digest_enc.len, digest_buffer);
8475 : : else
8476 [ # # ]: 0 : digest = rte_pktmbuf_read(ut_params->ibuf,
8477 : 0 : (tdata->digest_enc.offset == 0 ?
8478 : : plaintext_pad_len :
8479 : : tdata->digest_enc.offset),
8480 [ # # ]: 0 : tdata->digest_enc.len, digest_buffer);
8481 : :
8482 : 1 : debug_hexdump(stdout, "digest:", digest,
8483 : 1 : tdata->digest_enc.len);
8484 : 1 : debug_hexdump(stdout, "digest expected:",
8485 : 1 : tdata->digest_enc.data, tdata->digest_enc.len);
8486 : : }
8487 : :
8488 [ + + ]: 2 : if (!verify) {
8489 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
8490 : : digest,
8491 : : tdata->digest_enc.data,
8492 : : tdata->digest_enc.len,
8493 : : "Generated auth tag not as expected");
8494 : : }
8495 : :
8496 [ + - ]: 2 : if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
8497 [ + + ]: 2 : if (verify) {
8498 [ - + + - : 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
- + ]
8499 : : plaintext,
8500 : : tdata->plaintext.data,
8501 : : tdata->plaintext.len_bits >> 3,
8502 : : "Plaintext data not as expected");
8503 : : } else {
8504 [ - + - + : 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
- - ]
8505 : : ciphertext,
8506 : : tdata->ciphertext.data,
8507 : : tdata->validDataLen.len_bits,
8508 : : "Ciphertext data not as expected");
8509 : : }
8510 : : }
8511 : :
8512 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8513 : : "crypto op processing failed");
8514 : :
8515 : : return 0;
8516 : : }
8517 : :
8518 : : /** AUTH AES CMAC + CIPHER AES CTR */
8519 : :
8520 : : static int
8521 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8522 : : {
8523 : 1 : return test_mixed_auth_cipher(
8524 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8525 : : }
8526 : :
8527 : : static int
8528 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8529 : : {
8530 : 1 : return test_mixed_auth_cipher(
8531 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8532 : : }
8533 : :
8534 : : static int
8535 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8536 : : {
8537 : 1 : return test_mixed_auth_cipher_sgl(
8538 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8539 : : }
8540 : :
8541 : : static int
8542 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8543 : : {
8544 : 1 : return test_mixed_auth_cipher_sgl(
8545 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8546 : : }
8547 : :
8548 : : static int
8549 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8550 : : {
8551 : 1 : return test_mixed_auth_cipher(
8552 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 0);
8553 : : }
8554 : :
8555 : : static int
8556 : 1 : test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8557 : : {
8558 : 1 : return test_mixed_auth_cipher(
8559 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 0);
8560 : : }
8561 : :
8562 : : static int
8563 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
8564 : : {
8565 : 1 : return test_mixed_auth_cipher(
8566 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8567 : : }
8568 : :
8569 : : static int
8570 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2(void)
8571 : : {
8572 : 1 : return test_mixed_auth_cipher(
8573 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, IN_PLACE, 1);
8574 : : }
8575 : :
8576 : : static int
8577 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
8578 : : {
8579 : 1 : return test_mixed_auth_cipher(
8580 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8581 : : }
8582 : :
8583 : : static int
8584 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
8585 : : {
8586 : 1 : return test_mixed_auth_cipher_sgl(
8587 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8588 : : }
8589 : :
8590 : : static int
8591 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
8592 : : {
8593 : 1 : return test_mixed_auth_cipher_sgl(
8594 : : &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8595 : : }
8596 : :
8597 : : static int
8598 : 1 : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop(void)
8599 : : {
8600 : 1 : return test_mixed_auth_cipher(
8601 : : &auth_aes_cmac_cipher_aes_ctr_test_case_2, OUT_OF_PLACE, 1);
8602 : : }
8603 : :
8604 : : /** MIXED AUTH + CIPHER */
8605 : :
8606 : : static int
8607 : 1 : test_auth_zuc_cipher_snow_test_case_1(void)
8608 : : {
8609 : 1 : return test_mixed_auth_cipher(
8610 : : &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8611 : : }
8612 : :
8613 : : static int
8614 : 1 : test_verify_auth_zuc_cipher_snow_test_case_1(void)
8615 : : {
8616 : 1 : return test_mixed_auth_cipher(
8617 : : &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8618 : : }
8619 : :
8620 : : static int
8621 : 1 : test_auth_zuc_cipher_snow_test_case_1_inplace(void)
8622 : : {
8623 : 1 : return test_mixed_auth_cipher(
8624 : : &auth_zuc_cipher_snow_test_case_1, IN_PLACE, 0);
8625 : : }
8626 : :
8627 : : static int
8628 : 1 : test_verify_auth_zuc_cipher_snow_test_case_1_inplace(void)
8629 : : {
8630 : 1 : return test_mixed_auth_cipher(
8631 : : &auth_zuc_cipher_snow_test_case_1, IN_PLACE, 1);
8632 : : }
8633 : :
8634 : :
8635 : : static int
8636 : 1 : test_auth_aes_cmac_cipher_snow_test_case_1(void)
8637 : : {
8638 : 1 : return test_mixed_auth_cipher(
8639 : : &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8640 : : }
8641 : :
8642 : : static int
8643 : 1 : test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
8644 : : {
8645 : 1 : return test_mixed_auth_cipher(
8646 : : &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8647 : : }
8648 : :
8649 : : static int
8650 : 1 : test_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8651 : : {
8652 : 1 : return test_mixed_auth_cipher(
8653 : : &auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 0);
8654 : : }
8655 : :
8656 : : static int
8657 : 1 : test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace(void)
8658 : : {
8659 : 1 : return test_mixed_auth_cipher(
8660 : : &auth_aes_cmac_cipher_snow_test_case_1, IN_PLACE, 1);
8661 : : }
8662 : :
8663 : : static int
8664 : 1 : test_auth_zuc_cipher_aes_ctr_test_case_1(void)
8665 : : {
8666 : 1 : return test_mixed_auth_cipher(
8667 : : &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8668 : : }
8669 : :
8670 : : static int
8671 : 1 : test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
8672 : : {
8673 : 1 : return test_mixed_auth_cipher(
8674 : : &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8675 : : }
8676 : :
8677 : : static int
8678 : 1 : test_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8679 : : {
8680 : 1 : return test_mixed_auth_cipher(
8681 : : &auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8682 : : }
8683 : :
8684 : : static int
8685 : 1 : test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace(void)
8686 : : {
8687 : 1 : return test_mixed_auth_cipher(
8688 : : &auth_zuc_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8689 : : }
8690 : :
8691 : : static int
8692 : 1 : test_auth_snow_cipher_aes_ctr_test_case_1(void)
8693 : : {
8694 : 1 : return test_mixed_auth_cipher(
8695 : : &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8696 : : }
8697 : :
8698 : : static int
8699 : 1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
8700 : : {
8701 : 1 : return test_mixed_auth_cipher(
8702 : : &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8703 : : }
8704 : :
8705 : : static int
8706 : 1 : test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8707 : : {
8708 : 1 : return test_mixed_auth_cipher_sgl(
8709 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8710 : : }
8711 : :
8712 : : static int
8713 : 1 : test_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8714 : : {
8715 : 1 : return test_mixed_auth_cipher(
8716 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
8717 : : }
8718 : :
8719 : : static int
8720 : 1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl(void)
8721 : : {
8722 : 1 : return test_mixed_auth_cipher_sgl(
8723 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8724 : : }
8725 : :
8726 : : static int
8727 : 1 : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace(void)
8728 : : {
8729 : 1 : return test_mixed_auth_cipher(
8730 : : &auth_snow_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
8731 : : }
8732 : :
8733 : : static int
8734 : 1 : test_auth_snow_cipher_zuc_test_case_1(void)
8735 : : {
8736 : 1 : return test_mixed_auth_cipher(
8737 : : &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8738 : : }
8739 : :
8740 : : static int
8741 : 1 : test_verify_auth_snow_cipher_zuc_test_case_1(void)
8742 : : {
8743 : 1 : return test_mixed_auth_cipher(
8744 : : &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8745 : : }
8746 : :
8747 : : static int
8748 : 1 : test_auth_snow_cipher_zuc_test_case_1_inplace(void)
8749 : : {
8750 : 1 : return test_mixed_auth_cipher(
8751 : : &auth_snow_cipher_zuc_test_case_1, IN_PLACE, 0);
8752 : : }
8753 : :
8754 : : static int
8755 : 1 : test_verify_auth_snow_cipher_zuc_test_case_1_inplace(void)
8756 : : {
8757 : 1 : return test_mixed_auth_cipher(
8758 : : &auth_snow_cipher_zuc_test_case_1, IN_PLACE, 1);
8759 : : }
8760 : :
8761 : : static int
8762 : 1 : test_auth_aes_cmac_cipher_zuc_test_case_1(void)
8763 : : {
8764 : 1 : return test_mixed_auth_cipher(
8765 : : &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8766 : : }
8767 : :
8768 : : static int
8769 : 1 : test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
8770 : : {
8771 : 1 : return test_mixed_auth_cipher(
8772 : : &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8773 : : }
8774 : : static int
8775 : 1 : test_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
8776 : : {
8777 : 1 : return test_mixed_auth_cipher(
8778 : : &auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 0);
8779 : : }
8780 : :
8781 : : static int
8782 : 1 : test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace(void)
8783 : : {
8784 : 1 : return test_mixed_auth_cipher(
8785 : : &auth_aes_cmac_cipher_zuc_test_case_1, IN_PLACE, 1);
8786 : : }
8787 : :
8788 : : static int
8789 : 1 : test_auth_null_cipher_snow_test_case_1(void)
8790 : : {
8791 : 1 : return test_mixed_auth_cipher(
8792 : : &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
8793 : : }
8794 : :
8795 : : static int
8796 : 1 : test_verify_auth_null_cipher_snow_test_case_1(void)
8797 : : {
8798 : 1 : return test_mixed_auth_cipher(
8799 : : &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
8800 : : }
8801 : :
8802 : : static int
8803 : 1 : test_auth_null_cipher_zuc_test_case_1(void)
8804 : : {
8805 : 1 : return test_mixed_auth_cipher(
8806 : : &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
8807 : : }
8808 : :
8809 : : static int
8810 : 1 : test_verify_auth_null_cipher_zuc_test_case_1(void)
8811 : : {
8812 : 1 : return test_mixed_auth_cipher(
8813 : : &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
8814 : : }
8815 : :
8816 : : static int
8817 : 1 : test_auth_snow_cipher_null_test_case_1(void)
8818 : : {
8819 : 1 : return test_mixed_auth_cipher(
8820 : : &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8821 : : }
8822 : :
8823 : : static int
8824 : 1 : test_verify_auth_snow_cipher_null_test_case_1(void)
8825 : : {
8826 : 1 : return test_mixed_auth_cipher(
8827 : : &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8828 : : }
8829 : :
8830 : : static int
8831 : 1 : test_auth_zuc_cipher_null_test_case_1(void)
8832 : : {
8833 : 1 : return test_mixed_auth_cipher(
8834 : : &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8835 : : }
8836 : :
8837 : : static int
8838 : 1 : test_verify_auth_zuc_cipher_null_test_case_1(void)
8839 : : {
8840 : 1 : return test_mixed_auth_cipher(
8841 : : &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8842 : : }
8843 : :
8844 : : static int
8845 : 1 : test_auth_null_cipher_aes_ctr_test_case_1(void)
8846 : : {
8847 : 1 : return test_mixed_auth_cipher(
8848 : : &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
8849 : : }
8850 : :
8851 : : static int
8852 : 1 : test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
8853 : : {
8854 : 1 : return test_mixed_auth_cipher(
8855 : : &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
8856 : : }
8857 : :
8858 : : static int
8859 : 1 : test_auth_aes_cmac_cipher_null_test_case_1(void)
8860 : : {
8861 : 1 : return test_mixed_auth_cipher(
8862 : : &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
8863 : : }
8864 : :
8865 : : static int
8866 : 1 : test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
8867 : : {
8868 : 1 : return test_mixed_auth_cipher(
8869 : : &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
8870 : : }
8871 : :
8872 : : /* ***** AEAD algorithm Tests ***** */
8873 : :
8874 : : static int
8875 : 85 : create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
8876 : : enum rte_crypto_aead_operation op,
8877 : : const uint8_t *key, const uint8_t key_len,
8878 : : const uint16_t aad_len, const uint8_t auth_len,
8879 : : uint8_t iv_len)
8880 : 85 : {
8881 : 85 : uint8_t aead_key[key_len];
8882 : :
8883 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
8884 : : struct crypto_unittest_params *ut_params = &unittest_params;
8885 : :
8886 : : memcpy(aead_key, key, key_len);
8887 : :
8888 : : /* Setup AEAD Parameters */
8889 : 85 : ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8890 : 85 : ut_params->aead_xform.next = NULL;
8891 : 85 : ut_params->aead_xform.aead.algo = algo;
8892 : 85 : ut_params->aead_xform.aead.op = op;
8893 : 85 : ut_params->aead_xform.aead.key.data = aead_key;
8894 : 85 : ut_params->aead_xform.aead.key.length = key_len;
8895 : 85 : ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
8896 : 85 : ut_params->aead_xform.aead.iv.length = iv_len;
8897 : 85 : ut_params->aead_xform.aead.digest_length = auth_len;
8898 : 85 : ut_params->aead_xform.aead.aad_length = aad_len;
8899 : :
8900 : 85 : debug_hexdump(stdout, "key:", key, key_len);
8901 : :
8902 : : /* Create Crypto session*/
8903 : 85 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
8904 : : &ut_params->aead_xform, ts_params->session_mpool);
8905 [ - + - - ]: 85 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
8906 : : return TEST_SKIPPED;
8907 [ - + ]: 85 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8908 : : return 0;
8909 : : }
8910 : :
8911 : : static int
8912 : 2 : create_aead_xform(struct rte_crypto_op *op,
8913 : : enum rte_crypto_aead_algorithm algo,
8914 : : enum rte_crypto_aead_operation aead_op,
8915 : : uint8_t *key, const uint8_t key_len,
8916 : : const uint8_t aad_len, const uint8_t auth_len,
8917 : : uint8_t iv_len)
8918 : : {
8919 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
8920 : : "failed to allocate space for crypto transform");
8921 : :
8922 : : struct rte_crypto_sym_op *sym_op = op->sym;
8923 : :
8924 : : /* Setup AEAD Parameters */
8925 : 2 : sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
8926 : 2 : sym_op->xform->next = NULL;
8927 : 2 : sym_op->xform->aead.algo = algo;
8928 : 2 : sym_op->xform->aead.op = aead_op;
8929 : 2 : sym_op->xform->aead.key.data = key;
8930 : 2 : sym_op->xform->aead.key.length = key_len;
8931 : 2 : sym_op->xform->aead.iv.offset = IV_OFFSET;
8932 : 2 : sym_op->xform->aead.iv.length = iv_len;
8933 : 2 : sym_op->xform->aead.digest_length = auth_len;
8934 : 2 : sym_op->xform->aead.aad_length = aad_len;
8935 : :
8936 : 2 : debug_hexdump(stdout, "key:", key, key_len);
8937 : :
8938 : : return 0;
8939 : : }
8940 : :
8941 : : static int
8942 : 86 : create_aead_operation(enum rte_crypto_aead_operation op,
8943 : : const struct aead_test_data *tdata)
8944 : : {
8945 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
8946 : : struct crypto_unittest_params *ut_params = &unittest_params;
8947 : :
8948 : : uint8_t *plaintext, *ciphertext;
8949 : : unsigned int aad_pad_len, plaintext_pad_len;
8950 : :
8951 : : /* Generate Crypto op data structure */
8952 : 86 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8953 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8954 [ - + ]: 86 : TEST_ASSERT_NOT_NULL(ut_params->op,
8955 : : "Failed to allocate symmetric crypto operation struct");
8956 : :
8957 : : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8958 : :
8959 : : /* Append aad data */
8960 [ + + ]: 86 : if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8961 : 18 : aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
8962 : 18 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8963 : : aad_pad_len);
8964 [ - + ]: 18 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8965 : : "no room to append aad");
8966 : :
8967 : 18 : sym_op->aead.aad.phys_addr =
8968 : 18 : rte_pktmbuf_iova(ut_params->ibuf);
8969 : : /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8970 : 18 : memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
8971 : 18 : debug_hexdump(stdout, "aad:", sym_op->aead.aad.data + 18,
8972 : 18 : tdata->aad.len);
8973 : :
8974 : : /* Append IV at the end of the crypto operation*/
8975 : 18 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8976 : : uint8_t *, IV_OFFSET);
8977 : :
8978 : : /* Copy IV 1 byte after the IV pointer, according to the API */
8979 [ - + ]: 18 : rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
8980 : 18 : debug_hexdump(stdout, "iv:", iv_ptr + 1,
8981 : 18 : tdata->iv.len);
8982 : : } else {
8983 : 68 : aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
8984 : 68 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8985 : : aad_pad_len);
8986 [ - + ]: 68 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8987 : : "no room to append aad");
8988 : :
8989 : 68 : sym_op->aead.aad.phys_addr =
8990 : 68 : rte_pktmbuf_iova(ut_params->ibuf);
8991 : 68 : memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
8992 : 68 : debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
8993 : 68 : tdata->aad.len);
8994 : :
8995 : : /* Append IV at the end of the crypto operation*/
8996 : 68 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8997 : : uint8_t *, IV_OFFSET);
8998 : :
8999 [ - + ]: 68 : if (tdata->iv.len == 0) {
9000 [ # # ]: 0 : rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
9001 : 0 : debug_hexdump(stdout, "iv:", iv_ptr,
9002 : : AES_GCM_J0_LENGTH);
9003 : : } else {
9004 [ - + ]: 68 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9005 : 68 : debug_hexdump(stdout, "iv:", iv_ptr,
9006 : 68 : tdata->iv.len);
9007 : : }
9008 : : }
9009 : :
9010 : : /* Append plaintext/ciphertext */
9011 [ + + ]: 86 : if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
9012 : 43 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9013 : 43 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9014 : : plaintext_pad_len);
9015 [ - + ]: 43 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9016 : :
9017 : 43 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9018 : 43 : debug_hexdump(stdout, "plaintext:", plaintext,
9019 : 43 : tdata->plaintext.len);
9020 : :
9021 [ + + ]: 43 : if (ut_params->obuf) {
9022 : : ciphertext = (uint8_t *)rte_pktmbuf_append(
9023 : : ut_params->obuf,
9024 : 1 : plaintext_pad_len + aad_pad_len);
9025 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ciphertext,
9026 : : "no room to append ciphertext");
9027 : :
9028 : 1 : memset(ciphertext + aad_pad_len, 0,
9029 : 1 : tdata->ciphertext.len);
9030 : : }
9031 : : } else {
9032 : 43 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
9033 : 43 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9034 : : plaintext_pad_len);
9035 [ - + ]: 43 : TEST_ASSERT_NOT_NULL(ciphertext,
9036 : : "no room to append ciphertext");
9037 : :
9038 : 43 : memcpy(ciphertext, tdata->ciphertext.data,
9039 : 43 : tdata->ciphertext.len);
9040 : 43 : debug_hexdump(stdout, "ciphertext:", ciphertext,
9041 : 43 : tdata->ciphertext.len);
9042 : :
9043 [ + + ]: 43 : if (ut_params->obuf) {
9044 : : plaintext = (uint8_t *)rte_pktmbuf_append(
9045 : : ut_params->obuf,
9046 : 1 : plaintext_pad_len + aad_pad_len);
9047 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(plaintext,
9048 : : "no room to append plaintext");
9049 : :
9050 : 1 : memset(plaintext + aad_pad_len, 0,
9051 : 1 : tdata->plaintext.len);
9052 : : }
9053 : : }
9054 : :
9055 : : /* Append digest data */
9056 [ + + ]: 86 : if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
9057 : 42 : sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
9058 : 43 : ut_params->obuf ? ut_params->obuf :
9059 : : ut_params->ibuf,
9060 [ + + ]: 43 : tdata->auth_tag.len);
9061 [ - + ]: 43 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
9062 : : "no room to append digest");
9063 [ + + ]: 43 : memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
9064 [ + + ]: 43 : sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
9065 : : ut_params->obuf ? ut_params->obuf :
9066 : : ut_params->ibuf,
9067 : : plaintext_pad_len +
9068 : : aad_pad_len);
9069 : : } else {
9070 : 86 : sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
9071 : 43 : ut_params->ibuf, tdata->auth_tag.len);
9072 [ - + ]: 43 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
9073 : : "no room to append digest");
9074 [ - + ]: 43 : sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
9075 : : ut_params->ibuf,
9076 : : plaintext_pad_len + aad_pad_len);
9077 : :
9078 : 43 : rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
9079 [ - + ]: 43 : tdata->auth_tag.len);
9080 : 43 : debug_hexdump(stdout, "digest:",
9081 : 43 : sym_op->aead.digest.data,
9082 : 43 : tdata->auth_tag.len);
9083 : : }
9084 : :
9085 : 86 : sym_op->aead.data.length = tdata->plaintext.len;
9086 : 86 : sym_op->aead.data.offset = aad_pad_len;
9087 : :
9088 : 86 : return 0;
9089 : : }
9090 : :
9091 : : static int
9092 : 42 : test_authenticated_encryption_helper(const struct aead_test_data *tdata, bool use_ext_mbuf)
9093 : : {
9094 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9095 : : struct crypto_unittest_params *ut_params = &unittest_params;
9096 : :
9097 : : int retval;
9098 : : uint8_t *ciphertext, *auth_tag;
9099 : : uint16_t plaintext_pad_len;
9100 : : uint32_t i;
9101 : : struct rte_cryptodev_info dev_info;
9102 : :
9103 : 42 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9104 : 42 : uint64_t feat_flags = dev_info.feature_flags;
9105 : :
9106 [ - + ]: 42 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9107 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9108 : : printf("Device doesn't support RAW data-path APIs.\n");
9109 : 0 : return TEST_SKIPPED;
9110 : : }
9111 : :
9112 : : /* Verify the capabilities */
9113 : : struct rte_cryptodev_sym_capability_idx cap_idx;
9114 : : const struct rte_cryptodev_symmetric_capability *capability;
9115 : 42 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9116 : 42 : cap_idx.algo.aead = tdata->algo;
9117 : 42 : capability = rte_cryptodev_sym_capability_get(
9118 : 42 : ts_params->valid_devs[0], &cap_idx);
9119 [ + - ]: 42 : if (capability == NULL)
9120 : : return TEST_SKIPPED;
9121 [ + + ]: 42 : if (rte_cryptodev_sym_capability_check_aead(
9122 : 42 : capability, tdata->key.len, tdata->auth_tag.len,
9123 : 42 : tdata->aad.len, tdata->iv.len))
9124 : : return TEST_SKIPPED;
9125 : :
9126 : : /* Create AEAD session */
9127 : 41 : retval = create_aead_session(ts_params->valid_devs[0],
9128 : 41 : tdata->algo,
9129 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
9130 : 41 : tdata->key.data, tdata->key.len,
9131 : 41 : tdata->aad.len, tdata->auth_tag.len,
9132 : 41 : tdata->iv.len);
9133 [ + - ]: 41 : if (retval != TEST_SUCCESS)
9134 : : return retval;
9135 : :
9136 [ + + ]: 41 : if (tdata->aad.len > MBUF_SIZE) {
9137 [ - + ]: 2 : if (use_ext_mbuf) {
9138 : 0 : ut_params->ibuf = ext_mbuf_create(ts_params->large_mbuf_pool,
9139 : : AEAD_TEXT_MAX_LENGTH,
9140 : : 1 /* nb_segs */,
9141 : : NULL);
9142 : : } else {
9143 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9144 : : }
9145 : : /* Populate full size of add data */
9146 [ + + ]: 4096 : for (i = 32; i < MAX_AAD_LENGTH; i += 32)
9147 : 4094 : memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
9148 : : } else {
9149 [ + + ]: 39 : if (use_ext_mbuf) {
9150 : 1 : ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
9151 : : AEAD_TEXT_MAX_LENGTH,
9152 : : 1 /* nb_segs */,
9153 : : NULL);
9154 : : } else {
9155 : 38 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9156 : : }
9157 : : }
9158 : :
9159 : : /* clear mbuf payload */
9160 : 41 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9161 : 41 : rte_pktmbuf_tailroom(ut_params->ibuf));
9162 : :
9163 : : /* Create AEAD operation */
9164 : 41 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9165 [ + - ]: 41 : if (retval < 0)
9166 : : return retval;
9167 : :
9168 [ + - ]: 41 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9169 : :
9170 : 41 : ut_params->op->sym->m_src = ut_params->ibuf;
9171 : :
9172 : : /* Process crypto operation */
9173 [ - + ]: 41 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9174 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9175 [ - + ]: 41 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9176 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
9177 : : 0);
9178 [ # # ]: 0 : if (retval != TEST_SUCCESS)
9179 : : return retval;
9180 : : } else
9181 [ - + ]: 41 : TEST_ASSERT_NOT_NULL(
9182 : : process_crypto_request(ts_params->valid_devs[0],
9183 : : ut_params->op), "failed to process sym crypto op");
9184 : :
9185 [ - + ]: 41 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9186 : : "crypto op processing failed");
9187 : :
9188 : 41 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9189 : :
9190 [ - + ]: 41 : if (ut_params->op->sym->m_dst) {
9191 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9192 : : uint8_t *);
9193 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9194 : : uint8_t *, plaintext_pad_len);
9195 : : } else {
9196 : 41 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9197 : : uint8_t *,
9198 : : ut_params->op->sym->cipher.data.offset);
9199 : 41 : auth_tag = ciphertext + plaintext_pad_len;
9200 : : }
9201 : :
9202 : 41 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9203 : 41 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9204 : :
9205 : : /* Validate obuf */
9206 [ + + ]: 44 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
9207 : : ciphertext,
9208 : : tdata->ciphertext.data,
9209 : : tdata->ciphertext.len,
9210 : : "Ciphertext data not as expected");
9211 : :
9212 [ + + ]: 41 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
9213 : : auth_tag,
9214 : : tdata->auth_tag.data,
9215 : : tdata->auth_tag.len,
9216 : : "Generated auth tag not as expected");
9217 : :
9218 : : return 0;
9219 : :
9220 : : }
9221 : :
9222 : : static int
9223 : : test_authenticated_encryption(const struct aead_test_data *tdata)
9224 : : {
9225 : 41 : return test_authenticated_encryption_helper(tdata, false);
9226 : : }
9227 : :
9228 : : #ifdef RTE_LIB_SECURITY
9229 : : static int
9230 : 0 : security_proto_supported(enum rte_security_session_action_type action,
9231 : : enum rte_security_session_protocol proto)
9232 : : {
9233 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9234 : :
9235 : : const struct rte_security_capability *capabilities;
9236 : : const struct rte_security_capability *capability;
9237 : : uint16_t i = 0;
9238 : :
9239 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9240 : :
9241 : :
9242 : 0 : capabilities = rte_security_capabilities_get(ctx);
9243 : :
9244 [ # # ]: 0 : if (capabilities == NULL)
9245 : : return -ENOTSUP;
9246 : :
9247 [ # # ]: 0 : while ((capability = &capabilities[i++])->action !=
9248 : : RTE_SECURITY_ACTION_TYPE_NONE) {
9249 [ # # ]: 0 : if (capability->action == action &&
9250 [ # # ]: 0 : capability->protocol == proto)
9251 : : return 0;
9252 : : }
9253 : :
9254 : : return -ENOTSUP;
9255 : : }
9256 : :
9257 : : /* Basic algorithm run function for async inplace mode.
9258 : : * Creates a session from input parameters and runs one operation
9259 : : * on input_vec. Checks the output of the crypto operation against
9260 : : * output_vec.
9261 : : */
9262 : 0 : static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
9263 : : enum rte_crypto_auth_operation opa,
9264 : : const uint8_t *input_vec, unsigned int input_vec_len,
9265 : : const uint8_t *output_vec,
9266 : : unsigned int output_vec_len,
9267 : : enum rte_crypto_cipher_algorithm cipher_alg,
9268 : : const uint8_t *cipher_key, uint32_t cipher_key_len,
9269 : : enum rte_crypto_auth_algorithm auth_alg,
9270 : : const uint8_t *auth_key, uint32_t auth_key_len,
9271 : : uint8_t bearer, enum rte_security_pdcp_domain domain,
9272 : : uint8_t packet_direction, uint8_t sn_size,
9273 : : uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
9274 : : {
9275 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9276 : : struct crypto_unittest_params *ut_params = &unittest_params;
9277 : : uint8_t *plaintext;
9278 : : int ret = TEST_SUCCESS;
9279 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9280 : : struct rte_cryptodev_info dev_info;
9281 : : uint64_t feat_flags;
9282 : :
9283 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9284 : 0 : feat_flags = dev_info.feature_flags;
9285 : :
9286 : : /* Verify the capabilities */
9287 : : struct rte_security_capability_idx sec_cap_idx;
9288 : :
9289 : 0 : sec_cap_idx.action = ut_params->type;
9290 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9291 : 0 : sec_cap_idx.pdcp.domain = domain;
9292 [ # # ]: 0 : if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9293 : : return TEST_SKIPPED;
9294 : :
9295 : : /* Generate test mbuf data */
9296 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9297 : :
9298 : : /* clear mbuf payload */
9299 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9300 : : rte_pktmbuf_tailroom(ut_params->ibuf));
9301 : :
9302 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9303 : : input_vec_len);
9304 [ # # ]: 0 : memcpy(plaintext, input_vec, input_vec_len);
9305 : :
9306 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9307 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9308 : : printf("Device does not support RAW data-path APIs.\n");
9309 : 0 : return TEST_SKIPPED;
9310 : : }
9311 : : /* Out of place support */
9312 [ # # ]: 0 : if (oop) {
9313 : : /*
9314 : : * For out-op-place we need to alloc another mbuf
9315 : : */
9316 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9317 : 0 : rte_pktmbuf_append(ut_params->obuf, output_vec_len);
9318 : : }
9319 : :
9320 : : /* Setup Cipher Parameters */
9321 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9322 : 0 : ut_params->cipher_xform.cipher.algo = cipher_alg;
9323 : 0 : ut_params->cipher_xform.cipher.op = opc;
9324 : 0 : ut_params->cipher_xform.cipher.key.data = cipher_key;
9325 : 0 : ut_params->cipher_xform.cipher.key.length = cipher_key_len;
9326 [ # # ]: 0 : ut_params->cipher_xform.cipher.iv.length =
9327 : : packet_direction ? 4 : 0;
9328 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9329 : :
9330 : : /* Setup HMAC Parameters if ICV header is required */
9331 [ # # ]: 0 : if (auth_alg != 0) {
9332 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9333 : 0 : ut_params->auth_xform.next = NULL;
9334 : 0 : ut_params->auth_xform.auth.algo = auth_alg;
9335 : 0 : ut_params->auth_xform.auth.op = opa;
9336 : 0 : ut_params->auth_xform.auth.key.data = auth_key;
9337 : 0 : ut_params->auth_xform.auth.key.length = auth_key_len;
9338 : :
9339 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
9340 : : } else {
9341 : 0 : ut_params->cipher_xform.next = NULL;
9342 : : }
9343 : :
9344 : 0 : struct rte_security_session_conf sess_conf = {
9345 : 0 : .action_type = ut_params->type,
9346 : : .protocol = RTE_SECURITY_PROTOCOL_PDCP,
9347 : : {.pdcp = {
9348 : : .bearer = bearer,
9349 : : .domain = domain,
9350 : : .pkt_dir = packet_direction,
9351 : : .sn_size = sn_size,
9352 [ # # ]: 0 : .hfn = packet_direction ? 0 : hfn,
9353 : : /**
9354 : : * hfn can be set as pdcp_test_hfn[i]
9355 : : * if hfn_ovrd is not set. Here, PDCP
9356 : : * packet direction is just used to
9357 : : * run half of the cases with session
9358 : : * HFN and other half with per packet
9359 : : * HFN.
9360 : : */
9361 : : .hfn_threshold = hfn_threshold,
9362 : 0 : .hfn_ovrd = packet_direction ? 1 : 0,
9363 : : .sdap_enabled = sdap,
9364 : : } },
9365 : : .crypto_xform = &ut_params->cipher_xform
9366 : : };
9367 : :
9368 : : /* Create security session */
9369 : 0 : ut_params->sec_session = rte_security_session_create(ctx,
9370 : : &sess_conf, ts_params->session_mpool);
9371 : :
9372 [ # # ]: 0 : if (!ut_params->sec_session) {
9373 : : printf("TestCase %s()-%d line %d failed %s: ",
9374 : : __func__, i, __LINE__, "Failed to allocate session");
9375 : : ret = TEST_FAILED;
9376 : 0 : goto on_err;
9377 : : }
9378 : :
9379 : : /* Generate crypto op data structure */
9380 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9381 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9382 [ # # ]: 0 : if (!ut_params->op) {
9383 : : printf("TestCase %s()-%d line %d failed %s: ",
9384 : : __func__, i, __LINE__,
9385 : : "Failed to allocate symmetric crypto operation struct");
9386 : : ret = TEST_FAILED;
9387 : 0 : goto on_err;
9388 : : }
9389 : :
9390 : : uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
9391 : : uint32_t *, IV_OFFSET);
9392 [ # # ]: 0 : *per_pkt_hfn = packet_direction ? hfn : 0;
9393 : :
9394 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
9395 : :
9396 : : /* set crypto operation source mbuf */
9397 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
9398 [ # # ]: 0 : if (oop)
9399 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
9400 : :
9401 : : /* Process crypto operation */
9402 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9403 : : /* filling lengths */
9404 : 0 : ut_params->op->sym->cipher.data.length = ut_params->op->sym->m_src->pkt_len;
9405 : 0 : ut_params->op->sym->auth.data.length = ut_params->op->sym->m_src->pkt_len;
9406 : :
9407 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9408 [ # # ]: 0 : if (ret != TEST_SUCCESS)
9409 : : return ret;
9410 : : } else {
9411 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
9412 : : }
9413 [ # # ]: 0 : if (ut_params->op == NULL) {
9414 : : printf("TestCase %s()-%d line %d failed %s: ",
9415 : : __func__, i, __LINE__,
9416 : : "failed to process sym crypto op");
9417 : : ret = TEST_FAILED;
9418 : 0 : goto on_err;
9419 : : }
9420 : :
9421 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9422 : : printf("TestCase %s()-%d line %d failed %s: ",
9423 : : __func__, i, __LINE__, "crypto op processing failed");
9424 : : ret = TEST_FAILED;
9425 : 0 : goto on_err;
9426 : : }
9427 : :
9428 : : /* Validate obuf */
9429 : 0 : uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9430 : : uint8_t *);
9431 [ # # ]: 0 : if (oop) {
9432 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9433 : : uint8_t *);
9434 : : }
9435 : :
9436 [ # # ]: 0 : if (memcmp(ciphertext, output_vec, output_vec_len)) {
9437 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9438 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
9439 : 0 : rte_hexdump(stdout, "reference", output_vec, output_vec_len);
9440 : : ret = TEST_FAILED;
9441 : 0 : goto on_err;
9442 : : }
9443 : :
9444 : 0 : on_err:
9445 : 0 : rte_crypto_op_free(ut_params->op);
9446 : 0 : ut_params->op = NULL;
9447 : :
9448 [ # # ]: 0 : if (ut_params->sec_session)
9449 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
9450 : 0 : ut_params->sec_session = NULL;
9451 : :
9452 : 0 : rte_pktmbuf_free(ut_params->ibuf);
9453 : 0 : ut_params->ibuf = NULL;
9454 [ # # ]: 0 : if (oop) {
9455 : 0 : rte_pktmbuf_free(ut_params->obuf);
9456 : 0 : ut_params->obuf = NULL;
9457 : : }
9458 : :
9459 : : return ret;
9460 : : }
9461 : :
9462 : : static int
9463 : 0 : test_pdcp_proto_SGL(int i, int oop,
9464 : : enum rte_crypto_cipher_operation opc,
9465 : : enum rte_crypto_auth_operation opa,
9466 : : uint8_t *input_vec,
9467 : : unsigned int input_vec_len,
9468 : : uint8_t *output_vec,
9469 : : unsigned int output_vec_len,
9470 : : uint32_t fragsz,
9471 : : uint32_t fragsz_oop)
9472 : : {
9473 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
9474 : : struct crypto_unittest_params *ut_params = &unittest_params;
9475 : : uint8_t *plaintext;
9476 : : struct rte_mbuf *buf, *buf_oop = NULL;
9477 : : int ret = TEST_SUCCESS;
9478 : : int to_trn = 0;
9479 : : int to_trn_tbl[16];
9480 : : int segs = 1;
9481 : : unsigned int trn_data = 0;
9482 : : struct rte_cryptodev_info dev_info;
9483 : : uint64_t feat_flags;
9484 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
9485 : : struct rte_mbuf *temp_mbuf;
9486 : :
9487 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9488 : 0 : feat_flags = dev_info.feature_flags;
9489 : :
9490 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9491 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9492 : : printf("Device does not support RAW data-path APIs.\n");
9493 : 0 : return -ENOTSUP;
9494 : : }
9495 : : /* Verify the capabilities */
9496 : : struct rte_security_capability_idx sec_cap_idx;
9497 : :
9498 : 0 : sec_cap_idx.action = ut_params->type;
9499 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
9500 : 0 : sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
9501 [ # # ]: 0 : if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
9502 : : return TEST_SKIPPED;
9503 : :
9504 : : if (fragsz > input_vec_len)
9505 : : fragsz = input_vec_len;
9506 : :
9507 : 0 : uint16_t plaintext_len = fragsz;
9508 [ # # ]: 0 : uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
9509 : :
9510 [ # # ]: 0 : if (fragsz_oop > output_vec_len)
9511 : 0 : frag_size_oop = output_vec_len;
9512 : :
9513 : : int ecx = 0;
9514 [ # # ]: 0 : if (input_vec_len % fragsz != 0) {
9515 [ # # ]: 0 : if (input_vec_len / fragsz + 1 > 16)
9516 : : return 1;
9517 [ # # ]: 0 : } else if (input_vec_len / fragsz > 16)
9518 : : return 1;
9519 : :
9520 : : /* Out of place support */
9521 [ # # ]: 0 : if (oop) {
9522 : : /*
9523 : : * For out-op-place we need to alloc another mbuf
9524 : : */
9525 : 0 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9526 : : rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
9527 : 0 : buf_oop = ut_params->obuf;
9528 : : }
9529 : :
9530 : : /* Generate test mbuf data */
9531 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9532 : :
9533 : : /* clear mbuf payload */
9534 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9535 : : rte_pktmbuf_tailroom(ut_params->ibuf));
9536 : :
9537 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9538 : : plaintext_len);
9539 : 0 : memcpy(plaintext, input_vec, plaintext_len);
9540 : : trn_data += plaintext_len;
9541 : :
9542 : 0 : buf = ut_params->ibuf;
9543 : :
9544 : : /*
9545 : : * Loop until no more fragments
9546 : : */
9547 : :
9548 [ # # ]: 0 : while (trn_data < input_vec_len) {
9549 : 0 : ++segs;
9550 : 0 : to_trn = (input_vec_len - trn_data < fragsz) ?
9551 : 0 : (input_vec_len - trn_data) : fragsz;
9552 : :
9553 : 0 : to_trn_tbl[ecx++] = to_trn;
9554 : :
9555 [ # # ]: 0 : buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9556 : : buf = buf->next;
9557 : :
9558 [ # # ]: 0 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
9559 : : rte_pktmbuf_tailroom(buf));
9560 : :
9561 : : /* OOP */
9562 [ # # ]: 0 : if (oop && !fragsz_oop) {
9563 : 0 : buf_oop->next =
9564 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
9565 : : buf_oop = buf_oop->next;
9566 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9567 : : 0, rte_pktmbuf_tailroom(buf_oop));
9568 : 0 : rte_pktmbuf_append(buf_oop, to_trn);
9569 : : }
9570 : :
9571 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(buf,
9572 : : to_trn);
9573 : :
9574 : 0 : memcpy(plaintext, input_vec + trn_data, to_trn);
9575 : 0 : trn_data += to_trn;
9576 : : }
9577 : :
9578 : 0 : ut_params->ibuf->nb_segs = segs;
9579 : :
9580 : : segs = 1;
9581 [ # # ]: 0 : if (fragsz_oop && oop) {
9582 : : to_trn = 0;
9583 : : ecx = 0;
9584 : :
9585 : 0 : trn_data = frag_size_oop;
9586 [ # # ]: 0 : while (trn_data < output_vec_len) {
9587 : 0 : ++segs;
9588 : 0 : to_trn =
9589 : 0 : (output_vec_len - trn_data <
9590 : : frag_size_oop) ?
9591 : 0 : (output_vec_len - trn_data) :
9592 : : frag_size_oop;
9593 : :
9594 : 0 : to_trn_tbl[ecx++] = to_trn;
9595 : :
9596 : 0 : buf_oop->next =
9597 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
9598 : : buf_oop = buf_oop->next;
9599 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9600 : : 0, rte_pktmbuf_tailroom(buf_oop));
9601 : 0 : rte_pktmbuf_append(buf_oop, to_trn);
9602 : :
9603 : 0 : trn_data += to_trn;
9604 : : }
9605 : 0 : ut_params->obuf->nb_segs = segs;
9606 : : }
9607 : :
9608 : : /* Setup Cipher Parameters */
9609 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9610 : 0 : ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
9611 : 0 : ut_params->cipher_xform.cipher.op = opc;
9612 : 0 : ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
9613 : 0 : ut_params->cipher_xform.cipher.key.length =
9614 : 0 : pdcp_test_params[i].cipher_key_len;
9615 : 0 : ut_params->cipher_xform.cipher.iv.length = 0;
9616 : :
9617 : : /* Setup HMAC Parameters if ICV header is required */
9618 [ # # ]: 0 : if (pdcp_test_params[i].auth_alg != 0) {
9619 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9620 : 0 : ut_params->auth_xform.next = NULL;
9621 : 0 : ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
9622 : 0 : ut_params->auth_xform.auth.op = opa;
9623 : 0 : ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
9624 : 0 : ut_params->auth_xform.auth.key.length =
9625 : 0 : pdcp_test_params[i].auth_key_len;
9626 : :
9627 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
9628 : : } else {
9629 : 0 : ut_params->cipher_xform.next = NULL;
9630 : : }
9631 : :
9632 : 0 : struct rte_security_session_conf sess_conf = {
9633 : 0 : .action_type = ut_params->type,
9634 : : .protocol = RTE_SECURITY_PROTOCOL_PDCP,
9635 : : {.pdcp = {
9636 : 0 : .bearer = pdcp_test_bearer[i],
9637 : 0 : .domain = pdcp_test_params[i].domain,
9638 : 0 : .pkt_dir = pdcp_test_packet_direction[i],
9639 : 0 : .sn_size = pdcp_test_data_sn_size[i],
9640 : 0 : .hfn = pdcp_test_hfn[i],
9641 : 0 : .hfn_threshold = pdcp_test_hfn_threshold[i],
9642 : : .hfn_ovrd = 0,
9643 : : } },
9644 : : .crypto_xform = &ut_params->cipher_xform
9645 : : };
9646 : :
9647 : : /* Create security session */
9648 : 0 : ut_params->sec_session = rte_security_session_create(ctx,
9649 : : &sess_conf, ts_params->session_mpool);
9650 : :
9651 [ # # ]: 0 : if (!ut_params->sec_session) {
9652 : : printf("TestCase %s()-%d line %d failed %s: ",
9653 : : __func__, i, __LINE__, "Failed to allocate session");
9654 : : ret = TEST_FAILED;
9655 : 0 : goto on_err;
9656 : : }
9657 : :
9658 : : /* Generate crypto op data structure */
9659 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9660 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9661 [ # # ]: 0 : if (!ut_params->op) {
9662 : : printf("TestCase %s()-%d line %d failed %s: ",
9663 : : __func__, i, __LINE__,
9664 : : "Failed to allocate symmetric crypto operation struct");
9665 : : ret = TEST_FAILED;
9666 : 0 : goto on_err;
9667 : : }
9668 : :
9669 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
9670 : :
9671 : : /* set crypto operation source mbuf */
9672 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
9673 [ # # ]: 0 : if (oop)
9674 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
9675 : :
9676 : : /* Process crypto operation */
9677 : 0 : temp_mbuf = ut_params->op->sym->m_src;
9678 [ # # ]: 0 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
9679 : : /* filling lengths */
9680 [ # # ]: 0 : while (temp_mbuf) {
9681 : 0 : ut_params->op->sym->cipher.data.length
9682 : 0 : += temp_mbuf->pkt_len;
9683 : 0 : ut_params->op->sym->auth.data.length
9684 : 0 : += temp_mbuf->pkt_len;
9685 : 0 : temp_mbuf = temp_mbuf->next;
9686 : : }
9687 : :
9688 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0, 0);
9689 [ # # ]: 0 : if (ret != TEST_SUCCESS)
9690 : : return ret;
9691 : : } else {
9692 : 0 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9693 : : ut_params->op);
9694 : : }
9695 [ # # ]: 0 : if (ut_params->op == NULL) {
9696 : : printf("TestCase %s()-%d line %d failed %s: ",
9697 : : __func__, i, __LINE__,
9698 : : "failed to process sym crypto op");
9699 : : ret = TEST_FAILED;
9700 : 0 : goto on_err;
9701 : : }
9702 : :
9703 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9704 : : printf("TestCase %s()-%d line %d failed %s: ",
9705 : : __func__, i, __LINE__, "crypto op processing failed");
9706 : : ret = TEST_FAILED;
9707 : 0 : goto on_err;
9708 : : }
9709 : :
9710 : : /* Validate obuf */
9711 : 0 : uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
9712 : : uint8_t *);
9713 [ # # ]: 0 : if (oop) {
9714 : 0 : ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9715 : : uint8_t *);
9716 : : }
9717 [ # # ]: 0 : if (fragsz_oop)
9718 : 0 : fragsz = frag_size_oop;
9719 [ # # ]: 0 : if (memcmp(ciphertext, output_vec, fragsz)) {
9720 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9721 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
9722 : 0 : rte_hexdump(stdout, "reference", output_vec, fragsz);
9723 : : ret = TEST_FAILED;
9724 : 0 : goto on_err;
9725 : : }
9726 : :
9727 : 0 : buf = ut_params->op->sym->m_src->next;
9728 [ # # ]: 0 : if (oop)
9729 : 0 : buf = ut_params->op->sym->m_dst->next;
9730 : :
9731 : : unsigned int off = fragsz;
9732 : :
9733 : : ecx = 0;
9734 [ # # ]: 0 : while (buf) {
9735 : 0 : ciphertext = rte_pktmbuf_mtod(buf,
9736 : : uint8_t *);
9737 [ # # ]: 0 : if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
9738 : : printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
9739 : 0 : rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
9740 : 0 : rte_hexdump(stdout, "reference", output_vec + off,
9741 : : to_trn_tbl[ecx]);
9742 : : ret = TEST_FAILED;
9743 : 0 : goto on_err;
9744 : : }
9745 : 0 : off += to_trn_tbl[ecx++];
9746 : 0 : buf = buf->next;
9747 : : }
9748 : 0 : on_err:
9749 : 0 : rte_crypto_op_free(ut_params->op);
9750 : 0 : ut_params->op = NULL;
9751 : :
9752 [ # # ]: 0 : if (ut_params->sec_session)
9753 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
9754 : 0 : ut_params->sec_session = NULL;
9755 : :
9756 : 0 : rte_pktmbuf_free(ut_params->ibuf);
9757 : 0 : ut_params->ibuf = NULL;
9758 [ # # ]: 0 : if (oop) {
9759 : 0 : rte_pktmbuf_free(ut_params->obuf);
9760 : 0 : ut_params->obuf = NULL;
9761 : : }
9762 : :
9763 : : return ret;
9764 : : }
9765 : :
9766 : : int
9767 : 0 : test_pdcp_proto_cplane_encap(int i)
9768 : : {
9769 : 0 : return test_pdcp_proto(
9770 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9771 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9772 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9773 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9774 : 0 : pdcp_test_params[i].cipher_key_len,
9775 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9776 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9777 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9778 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9779 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9780 : : }
9781 : :
9782 : : int
9783 : 0 : test_pdcp_proto_uplane_encap(int i)
9784 : : {
9785 : 0 : return test_pdcp_proto(
9786 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9787 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9788 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i],
9789 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9790 : 0 : pdcp_test_params[i].cipher_key_len,
9791 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9792 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9793 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9794 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9795 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9796 : : }
9797 : :
9798 : : int
9799 : 0 : test_pdcp_proto_uplane_encap_with_int(int i)
9800 : : {
9801 : 0 : return test_pdcp_proto(
9802 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
9803 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9804 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9805 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9806 : 0 : pdcp_test_params[i].cipher_key_len,
9807 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9808 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9809 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9810 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9811 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9812 : : }
9813 : :
9814 : : int
9815 : 0 : test_pdcp_proto_cplane_decap(int i)
9816 : : {
9817 : 0 : return test_pdcp_proto(
9818 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9819 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9820 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9821 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9822 : 0 : pdcp_test_params[i].cipher_key_len,
9823 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9824 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9825 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9826 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9827 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9828 : : }
9829 : :
9830 : : int
9831 : 0 : test_pdcp_proto_uplane_decap(int i)
9832 : : {
9833 : 0 : return test_pdcp_proto(
9834 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9835 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i],
9836 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9837 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9838 : 0 : pdcp_test_params[i].cipher_key_len,
9839 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9840 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9841 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9842 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9843 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9844 : : }
9845 : :
9846 : : int
9847 : 0 : test_pdcp_proto_uplane_decap_with_int(int i)
9848 : : {
9849 : 0 : return test_pdcp_proto(
9850 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
9851 : 0 : pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
9852 : 0 : pdcp_test_data_in[i], pdcp_test_data_in_len[i],
9853 : 0 : pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
9854 : 0 : pdcp_test_params[i].cipher_key_len,
9855 : 0 : pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
9856 : 0 : pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
9857 : 0 : pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
9858 : 0 : pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
9859 : : pdcp_test_hfn_threshold[i], SDAP_DISABLED);
9860 : : }
9861 : :
9862 : : static int
9863 : 0 : test_PDCP_PROTO_SGL_in_place_32B(void)
9864 : : {
9865 : : /* i can be used for running any PDCP case
9866 : : * In this case it is uplane 12-bit AES-SNOW DL encap
9867 : : */
9868 : : int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
9869 : 0 : return test_pdcp_proto_SGL(i, IN_PLACE,
9870 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9871 : : RTE_CRYPTO_AUTH_OP_GENERATE,
9872 : : pdcp_test_data_in[i],
9873 : : pdcp_test_data_in_len[i],
9874 : : pdcp_test_data_out[i],
9875 : 0 : pdcp_test_data_in_len[i]+4,
9876 : : 32, 0);
9877 : : }
9878 : : static int
9879 : 0 : test_PDCP_PROTO_SGL_oop_32B_128B(void)
9880 : : {
9881 : : /* i can be used for running any PDCP case
9882 : : * In this case it is uplane 18-bit NULL-NULL DL encap
9883 : : */
9884 : : int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
9885 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
9886 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9887 : : RTE_CRYPTO_AUTH_OP_GENERATE,
9888 : : pdcp_test_data_in[i],
9889 : : pdcp_test_data_in_len[i],
9890 : : pdcp_test_data_out[i],
9891 : 0 : pdcp_test_data_in_len[i]+4,
9892 : : 32, 128);
9893 : : }
9894 : : static int
9895 : 0 : test_PDCP_PROTO_SGL_oop_32B_40B(void)
9896 : : {
9897 : : /* i can be used for running any PDCP case
9898 : : * In this case it is uplane 18-bit AES DL encap
9899 : : */
9900 : : int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
9901 : : + DOWNLINK;
9902 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
9903 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9904 : : RTE_CRYPTO_AUTH_OP_GENERATE,
9905 : : pdcp_test_data_in[i],
9906 : : pdcp_test_data_in_len[i],
9907 : : pdcp_test_data_out[i],
9908 : : pdcp_test_data_in_len[i],
9909 : : 32, 40);
9910 : : }
9911 : : static int
9912 : 0 : test_PDCP_PROTO_SGL_oop_128B_32B(void)
9913 : : {
9914 : : /* i can be used for running any PDCP case
9915 : : * In this case it is cplane 12-bit AES-ZUC DL encap
9916 : : */
9917 : : int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
9918 : 0 : return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
9919 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9920 : : RTE_CRYPTO_AUTH_OP_GENERATE,
9921 : : pdcp_test_data_in[i],
9922 : : pdcp_test_data_in_len[i],
9923 : : pdcp_test_data_out[i],
9924 : 0 : pdcp_test_data_in_len[i]+4,
9925 : : 128, 32);
9926 : : }
9927 : :
9928 : : static int
9929 : 0 : test_PDCP_SDAP_PROTO_encap_all(void)
9930 : : {
9931 : : int i = 0, size = 0;
9932 : : int err, all_err = TEST_SUCCESS;
9933 : : const struct pdcp_sdap_test *cur_test;
9934 : :
9935 : : size = RTE_DIM(list_pdcp_sdap_tests);
9936 : :
9937 [ # # ]: 0 : for (i = 0; i < size; i++) {
9938 : : cur_test = &list_pdcp_sdap_tests[i];
9939 : 0 : err = test_pdcp_proto(
9940 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9941 : 0 : RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9942 : 0 : cur_test->in_len, cur_test->data_out,
9943 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9944 : 0 : cur_test->param.cipher_alg, cur_test->cipher_key,
9945 : 0 : cur_test->param.cipher_key_len,
9946 : 0 : cur_test->param.auth_alg,
9947 : 0 : cur_test->auth_key, cur_test->param.auth_key_len,
9948 : 0 : cur_test->bearer, cur_test->param.domain,
9949 : 0 : cur_test->packet_direction, cur_test->sn_size,
9950 : 0 : cur_test->hfn,
9951 [ # # ]: 0 : cur_test->hfn_threshold, SDAP_ENABLED);
9952 [ # # ]: 0 : if (err) {
9953 : : printf("\t%d) %s: Encapsulation failed\n",
9954 : 0 : cur_test->test_idx,
9955 : 0 : cur_test->param.name);
9956 : : err = TEST_FAILED;
9957 : : } else {
9958 : 0 : printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
9959 : 0 : cur_test->param.name);
9960 : : err = TEST_SUCCESS;
9961 : : }
9962 : 0 : all_err += err;
9963 : : }
9964 : :
9965 : 0 : printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9966 : :
9967 [ # # ]: 0 : return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9968 : : }
9969 : :
9970 : : static int
9971 : 0 : test_PDCP_PROTO_short_mac(void)
9972 : : {
9973 : : int i = 0, size = 0;
9974 : : int err, all_err = TEST_SUCCESS;
9975 : : const struct pdcp_short_mac_test *cur_test;
9976 : :
9977 : : size = RTE_DIM(list_pdcp_smac_tests);
9978 : :
9979 [ # # ]: 0 : for (i = 0; i < size; i++) {
9980 : : cur_test = &list_pdcp_smac_tests[i];
9981 : 0 : err = test_pdcp_proto(
9982 : : i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9983 : 0 : RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9984 : 0 : cur_test->in_len, cur_test->data_out,
9985 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9986 : : RTE_CRYPTO_CIPHER_NULL, NULL,
9987 : 0 : 0, cur_test->param.auth_alg,
9988 : 0 : cur_test->auth_key, cur_test->param.auth_key_len,
9989 [ # # ]: 0 : 0, cur_test->param.domain, 0, 0,
9990 : : 0, 0, 0);
9991 [ # # ]: 0 : if (err) {
9992 : : printf("\t%d) %s: Short MAC test failed\n",
9993 : 0 : cur_test->test_idx,
9994 : 0 : cur_test->param.name);
9995 : : err = TEST_FAILED;
9996 : : } else {
9997 : : printf("\t%d) %s: Short MAC test PASS\n",
9998 : 0 : cur_test->test_idx,
9999 : 0 : cur_test->param.name);
10000 : 0 : rte_hexdump(stdout, "MAC I",
10001 : 0 : cur_test->data_out + cur_test->in_len + 2,
10002 : : 2);
10003 : : err = TEST_SUCCESS;
10004 : : }
10005 : 0 : all_err += err;
10006 : : }
10007 : :
10008 : 0 : printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10009 : :
10010 [ # # ]: 0 : return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10011 : :
10012 : : }
10013 : :
10014 : : static int
10015 : 0 : test_PDCP_SDAP_PROTO_decap_all(void)
10016 : : {
10017 : : int i = 0, size = 0;
10018 : : int err, all_err = TEST_SUCCESS;
10019 : : const struct pdcp_sdap_test *cur_test;
10020 : :
10021 : : size = RTE_DIM(list_pdcp_sdap_tests);
10022 : :
10023 [ # # ]: 0 : for (i = 0; i < size; i++) {
10024 : : cur_test = &list_pdcp_sdap_tests[i];
10025 : 0 : err = test_pdcp_proto(
10026 : : i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
10027 : : RTE_CRYPTO_AUTH_OP_VERIFY,
10028 : 0 : cur_test->data_out,
10029 : 0 : cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
10030 : 0 : cur_test->data_in, cur_test->in_len,
10031 : 0 : cur_test->param.cipher_alg,
10032 : 0 : cur_test->cipher_key, cur_test->param.cipher_key_len,
10033 : 0 : cur_test->param.auth_alg, cur_test->auth_key,
10034 : 0 : cur_test->param.auth_key_len, cur_test->bearer,
10035 : 0 : cur_test->param.domain, cur_test->packet_direction,
10036 : 0 : cur_test->sn_size, cur_test->hfn,
10037 [ # # ]: 0 : cur_test->hfn_threshold, SDAP_ENABLED);
10038 [ # # ]: 0 : if (err) {
10039 : : printf("\t%d) %s: Decapsulation failed\n",
10040 : 0 : cur_test->test_idx,
10041 : 0 : cur_test->param.name);
10042 : : err = TEST_FAILED;
10043 : : } else {
10044 : 0 : printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
10045 : 0 : cur_test->param.name);
10046 : : err = TEST_SUCCESS;
10047 : : }
10048 : 0 : all_err += err;
10049 : : }
10050 : :
10051 : 0 : printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
10052 : :
10053 [ # # ]: 0 : return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
10054 : : }
10055 : :
10056 : : static int
10057 : 0 : test_ipsec_proto_crypto_op_enq(struct crypto_testsuite_params *ts_params,
10058 : : struct crypto_unittest_params *ut_params,
10059 : : struct rte_security_ipsec_xform *ipsec_xform,
10060 : : const struct ipsec_test_data *td,
10061 : : const struct ipsec_test_flags *flags,
10062 : : int pkt_num)
10063 : : {
10064 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
10065 : : enum rte_security_ipsec_sa_direction dir;
10066 : : int ret;
10067 : :
10068 : 0 : dir = ipsec_xform->direction;
10069 : :
10070 : : /* Generate crypto op data structure */
10071 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10072 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10073 [ # # ]: 0 : if (!ut_params->op) {
10074 : : printf("Could not allocate crypto op");
10075 : 0 : return TEST_FAILED;
10076 : : }
10077 : :
10078 : : /* Attach session to operation */
10079 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
10080 : :
10081 : : /* Set crypto operation mbufs */
10082 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
10083 : 0 : ut_params->op->sym->m_dst = NULL;
10084 : :
10085 : : /* Copy IV in crypto operation when IV generation is disabled */
10086 [ # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
10087 [ # # ]: 0 : ipsec_xform->options.iv_gen_disable == 1) {
10088 : 0 : uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
10089 : : uint8_t *,
10090 : : IV_OFFSET);
10091 : : int len;
10092 : :
10093 [ # # ]: 0 : if (td->aead)
10094 : 0 : len = td->xform.aead.aead.iv.length;
10095 [ # # ]: 0 : else if (td->aes_gmac)
10096 : 0 : len = td->xform.chain.auth.auth.iv.length;
10097 : : else
10098 : 0 : len = td->xform.chain.cipher.cipher.iv.length;
10099 : :
10100 : 0 : memcpy(iv, td->iv.data, len);
10101 : : }
10102 : :
10103 : : /* Process crypto operation */
10104 : 0 : process_crypto_request(dev_id, ut_params->op);
10105 : :
10106 : 0 : ret = test_ipsec_status_check(td, ut_params->op, flags, dir, pkt_num);
10107 : :
10108 : 0 : rte_crypto_op_free(ut_params->op);
10109 : 0 : ut_params->op = NULL;
10110 : :
10111 : 0 : return ret;
10112 : : }
10113 : :
10114 : : static int
10115 : 0 : test_ipsec_proto_mbuf_enq(struct crypto_testsuite_params *ts_params,
10116 : : struct crypto_unittest_params *ut_params,
10117 : : void *ctx)
10118 : : {
10119 : : uint64_t timeout, userdata;
10120 : : struct rte_ether_hdr *hdr;
10121 : : struct rte_mbuf *m;
10122 : : void **sec_sess;
10123 : : int ret;
10124 : :
10125 : : RTE_SET_USED(ts_params);
10126 : :
10127 [ # # ]: 0 : hdr = (void *)rte_pktmbuf_prepend(ut_params->ibuf, sizeof(struct rte_ether_hdr));
10128 : 0 : hdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
10129 : :
10130 : 0 : ut_params->ibuf->l2_len = sizeof(struct rte_ether_hdr);
10131 : 0 : ut_params->ibuf->port = 0;
10132 : :
10133 : 0 : sec_sess = &ut_params->sec_session;
10134 : 0 : ret = rte_security_inb_pkt_rx_inject(ctx, &ut_params->ibuf, sec_sess, 1);
10135 : :
10136 [ # # ]: 0 : if (ret != 1)
10137 : : return TEST_FAILED;
10138 : :
10139 : 0 : ut_params->ibuf = NULL;
10140 : :
10141 : : /* Add a timeout for 1 s */
10142 : 0 : timeout = rte_get_tsc_cycles() + rte_get_tsc_hz();
10143 : :
10144 : : do {
10145 : : /* Get packet from port 0, queue 0 */
10146 : 0 : ret = rte_eth_rx_burst(0, 0, &m, 1);
10147 [ # # # # ]: 0 : } while ((ret == 0) && (rte_get_tsc_cycles() < timeout));
10148 : :
10149 [ # # ]: 0 : if (ret == 0) {
10150 : : printf("Could not receive packets from ethdev\n");
10151 : 0 : return TEST_FAILED;
10152 : : }
10153 : :
10154 [ # # ]: 0 : if (m == NULL) {
10155 : : printf("Received mbuf is NULL\n");
10156 : 0 : return TEST_FAILED;
10157 : : }
10158 : :
10159 : 0 : ut_params->ibuf = m;
10160 : :
10161 [ # # ]: 0 : if (!(m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD)) {
10162 : : printf("Received packet is not Rx security processed\n");
10163 : 0 : return TEST_FAILED;
10164 : : }
10165 : :
10166 [ # # ]: 0 : if (m->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED) {
10167 : : printf("Received packet has failed Rx security processing\n");
10168 : 0 : return TEST_FAILED;
10169 : : }
10170 : :
10171 : : /*
10172 : : * 'ut_params' is set as userdata. Verify that the field is returned
10173 : : * correctly.
10174 : : */
10175 : 0 : userdata = *(uint64_t *)rte_security_dynfield(m);
10176 [ # # ]: 0 : if (userdata != (uint64_t)ut_params) {
10177 : : printf("Userdata retrieved not matching expected\n");
10178 : 0 : return TEST_FAILED;
10179 : : }
10180 : :
10181 : : /* Trim L2 header */
10182 : : rte_pktmbuf_adj(m, sizeof(struct rte_ether_hdr));
10183 : :
10184 : : return TEST_SUCCESS;
10185 : : }
10186 : :
10187 : : static int
10188 : 0 : test_ipsec_proto_process(const struct ipsec_test_data td[],
10189 : : struct ipsec_test_data res_d[],
10190 : : int nb_td,
10191 : : bool silent,
10192 : : const struct ipsec_test_flags *flags)
10193 : : {
10194 : : uint16_t v6_src[8] = {0x2607, 0xf8b0, 0x400c, 0x0c03, 0x0000, 0x0000,
10195 : : 0x0000, 0x001a};
10196 : : uint16_t v6_dst[8] = {0x2001, 0x0470, 0xe5bf, 0xdead, 0x4957, 0x2174,
10197 : : 0xe82c, 0x4887};
10198 : : const struct rte_ipv4_hdr *ipv4 =
10199 : : (const struct rte_ipv4_hdr *)td[0].output_text.data;
10200 [ # # ]: 0 : int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
10201 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
10202 : : struct crypto_unittest_params *ut_params = &unittest_params;
10203 : : struct rte_security_capability_idx sec_cap_idx;
10204 : : const struct rte_security_capability *sec_cap;
10205 : : struct rte_security_ipsec_xform ipsec_xform;
10206 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
10207 : : enum rte_security_ipsec_sa_direction dir;
10208 : : struct ipsec_test_data *res_d_tmp = NULL;
10209 : : uint8_t input_text[IPSEC_TEXT_MAX_LEN];
10210 : : int salt_len, i, ret = TEST_SUCCESS;
10211 : : void *ctx;
10212 : : uint32_t src, dst;
10213 : : uint32_t verify;
10214 : :
10215 : 0 : ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10216 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
10217 : :
10218 : : /* Use first test data to create session */
10219 : :
10220 : : /* Copy IPsec xform */
10221 [ # # ]: 0 : memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
10222 : :
10223 : 0 : dir = ipsec_xform.direction;
10224 : 0 : verify = flags->tunnel_hdr_verify;
10225 : :
10226 : : memcpy(&src, &ipv4->src_addr, sizeof(ipv4->src_addr));
10227 : : memcpy(&dst, &ipv4->dst_addr, sizeof(ipv4->dst_addr));
10228 : :
10229 [ # # ]: 0 : if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
10230 [ # # ]: 0 : if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
10231 : 0 : src += 1;
10232 [ # # ]: 0 : else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
10233 : 0 : dst += 1;
10234 : : }
10235 : :
10236 [ # # ]: 0 : if (td->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) {
10237 [ # # ]: 0 : if (td->ipsec_xform.tunnel.type ==
10238 : : RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
10239 : : memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src,
10240 : : sizeof(src));
10241 : : memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst,
10242 : : sizeof(dst));
10243 : :
10244 [ # # ]: 0 : if (flags->df == TEST_IPSEC_SET_DF_0_INNER_1)
10245 : 0 : ipsec_xform.tunnel.ipv4.df = 0;
10246 : :
10247 [ # # ]: 0 : if (flags->df == TEST_IPSEC_SET_DF_1_INNER_0)
10248 : 0 : ipsec_xform.tunnel.ipv4.df = 1;
10249 : :
10250 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10251 : 0 : ipsec_xform.tunnel.ipv4.dscp = 0;
10252 : :
10253 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10254 : 0 : ipsec_xform.tunnel.ipv4.dscp =
10255 : : TEST_IPSEC_DSCP_VAL;
10256 : :
10257 : : } else {
10258 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
10259 : 0 : ipsec_xform.tunnel.ipv6.dscp = 0;
10260 : :
10261 [ # # ]: 0 : if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
10262 : 0 : ipsec_xform.tunnel.ipv6.dscp =
10263 : : TEST_IPSEC_DSCP_VAL;
10264 : :
10265 : : memcpy(&ipsec_xform.tunnel.ipv6.src_addr, &v6_src,
10266 : : sizeof(v6_src));
10267 : : memcpy(&ipsec_xform.tunnel.ipv6.dst_addr, &v6_dst,
10268 : : sizeof(v6_dst));
10269 : : }
10270 : : }
10271 : :
10272 : 0 : ctx = rte_cryptodev_get_sec_ctx(dev_id);
10273 : :
10274 : 0 : sec_cap_idx.action = ut_params->type;
10275 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
10276 : 0 : sec_cap_idx.ipsec.proto = ipsec_xform.proto;
10277 : 0 : sec_cap_idx.ipsec.mode = ipsec_xform.mode;
10278 : 0 : sec_cap_idx.ipsec.direction = ipsec_xform.direction;
10279 : :
10280 [ # # ]: 0 : if (flags->udp_encap)
10281 : 0 : ipsec_xform.options.udp_encap = 1;
10282 : :
10283 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
10284 [ # # ]: 0 : if (sec_cap == NULL)
10285 : : return TEST_SKIPPED;
10286 : :
10287 : : /* Copy cipher session parameters */
10288 [ # # ]: 0 : if (td[0].aead) {
10289 : 0 : memcpy(&ut_params->aead_xform, &td[0].xform.aead,
10290 : : sizeof(ut_params->aead_xform));
10291 : 0 : ut_params->aead_xform.aead.key.data = td[0].key.data;
10292 : 0 : ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
10293 : :
10294 : : /* Verify crypto capabilities */
10295 [ # # ]: 0 : if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
10296 [ # # ]: 0 : if (!silent)
10297 : 0 : RTE_LOG(INFO, USER1,
10298 : : "Crypto capabilities not supported\n");
10299 : 0 : return TEST_SKIPPED;
10300 : : }
10301 [ # # ]: 0 : } else if (td[0].auth_only) {
10302 : 0 : memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10303 : : sizeof(ut_params->auth_xform));
10304 : 0 : ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10305 : :
10306 [ # # ]: 0 : if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
10307 [ # # ]: 0 : if (!silent)
10308 : 0 : RTE_LOG(INFO, USER1,
10309 : : "Auth crypto capabilities not supported\n");
10310 : 0 : return TEST_SKIPPED;
10311 : : }
10312 : : } else {
10313 : 0 : memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
10314 : : sizeof(ut_params->cipher_xform));
10315 : 0 : memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
10316 : : sizeof(ut_params->auth_xform));
10317 : 0 : ut_params->cipher_xform.cipher.key.data = td[0].key.data;
10318 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10319 : 0 : ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
10320 : :
10321 : : /* Verify crypto capabilities */
10322 : :
10323 [ # # ]: 0 : if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
10324 [ # # ]: 0 : if (!silent)
10325 : 0 : RTE_LOG(INFO, USER1,
10326 : : "Cipher crypto capabilities not supported\n");
10327 : 0 : return TEST_SKIPPED;
10328 : : }
10329 : :
10330 [ # # ]: 0 : if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
10331 [ # # ]: 0 : if (!silent)
10332 : 0 : RTE_LOG(INFO, USER1,
10333 : : "Auth crypto capabilities not supported\n");
10334 : 0 : return TEST_SKIPPED;
10335 : : }
10336 : : }
10337 : :
10338 [ # # ]: 0 : if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
10339 : : return TEST_SKIPPED;
10340 : :
10341 : 0 : struct rte_security_session_conf sess_conf = {
10342 : 0 : .action_type = ut_params->type,
10343 : : .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
10344 : : };
10345 : :
10346 [ # # ]: 0 : if (td[0].aead || td[0].aes_gmac) {
10347 : 0 : salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
10348 : 0 : memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
10349 : : }
10350 : :
10351 [ # # ]: 0 : if (td[0].aead) {
10352 : 0 : sess_conf.ipsec = ipsec_xform;
10353 : 0 : sess_conf.crypto_xform = &ut_params->aead_xform;
10354 [ # # ]: 0 : } else if (td[0].auth_only) {
10355 : 0 : sess_conf.ipsec = ipsec_xform;
10356 : 0 : sess_conf.crypto_xform = &ut_params->auth_xform;
10357 : : } else {
10358 : 0 : sess_conf.ipsec = ipsec_xform;
10359 [ # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
10360 : 0 : sess_conf.crypto_xform = &ut_params->cipher_xform;
10361 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
10362 : : } else {
10363 : 0 : sess_conf.crypto_xform = &ut_params->auth_xform;
10364 : 0 : ut_params->auth_xform.next = &ut_params->cipher_xform;
10365 : : }
10366 : : }
10367 : :
10368 [ # # # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10369 : 0 : sess_conf.userdata = ut_params;
10370 : :
10371 : : /* Create security session */
10372 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
10373 : : ts_params->session_mpool);
10374 : :
10375 [ # # ]: 0 : if (ut_params->sec_session == NULL)
10376 : : return TEST_SKIPPED;
10377 : :
10378 [ # # ]: 0 : for (i = 0; i < nb_td; i++) {
10379 [ # # # # ]: 0 : if (flags->antireplay &&
10380 : : (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)) {
10381 : 0 : sess_conf.ipsec.esn.value = td[i].ipsec_xform.esn.value;
10382 : 0 : ret = rte_security_session_update(ctx,
10383 : : ut_params->sec_session, &sess_conf);
10384 [ # # ]: 0 : if (ret) {
10385 : : printf("Could not update sequence number in "
10386 : : "session\n");
10387 : 0 : return TEST_SKIPPED;
10388 : : }
10389 : : }
10390 : :
10391 : : /* Copy test data before modification */
10392 : 0 : memcpy(input_text, td[i].input_text.data, td[i].input_text.len);
10393 [ # # ]: 0 : if (test_ipsec_pkt_update(input_text, flags)) {
10394 : : ret = TEST_FAILED;
10395 : 0 : goto mbuf_free;
10396 : : }
10397 : :
10398 : : /* Setup source mbuf payload */
10399 [ # # ]: 0 : if (flags->use_ext_mbuf) {
10400 : 0 : ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
10401 : 0 : td[i].input_text.len, nb_segs, input_text);
10402 : : } else {
10403 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
10404 : 0 : td[i].input_text.len, nb_segs, 0);
10405 : 0 : pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, input_text);
10406 : : }
10407 : :
10408 [ # # # # ]: 0 : if (dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS && flags->rx_inject)
10409 : 0 : ret = test_ipsec_proto_mbuf_enq(ts_params, ut_params,
10410 : : ctx);
10411 : : else
10412 : 0 : ret = test_ipsec_proto_crypto_op_enq(ts_params,
10413 : : ut_params,
10414 : : &ipsec_xform,
10415 : : &td[i], flags,
10416 : : i + 1);
10417 : :
10418 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10419 : 0 : goto mbuf_free;
10420 : :
10421 [ # # ]: 0 : if (res_d != NULL)
10422 : 0 : res_d_tmp = &res_d[i];
10423 : :
10424 : 0 : ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
10425 : : res_d_tmp, silent, flags);
10426 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10427 : 0 : goto mbuf_free;
10428 : :
10429 : 0 : ret = test_ipsec_stats_verify(ctx, ut_params->sec_session,
10430 : : flags, dir);
10431 [ # # ]: 0 : if (ret != TEST_SUCCESS)
10432 : 0 : goto mbuf_free;
10433 : :
10434 : 0 : rte_pktmbuf_free(ut_params->ibuf);
10435 : 0 : ut_params->ibuf = NULL;
10436 : : }
10437 : :
10438 : 0 : mbuf_free:
10439 [ # # ]: 0 : if (flags->use_ext_mbuf)
10440 : 0 : ext_mbuf_memzone_free(nb_segs);
10441 : :
10442 : 0 : rte_pktmbuf_free(ut_params->ibuf);
10443 : 0 : ut_params->ibuf = NULL;
10444 : :
10445 [ # # ]: 0 : if (ut_params->sec_session)
10446 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
10447 : 0 : ut_params->sec_session = NULL;
10448 : :
10449 : 0 : return ret;
10450 : : }
10451 : :
10452 : : static int
10453 [ # # ]: 0 : test_ipsec_proto_known_vec(const void *test_data)
10454 : : {
10455 : : struct ipsec_test_data td_outb;
10456 : : struct ipsec_test_flags flags;
10457 : :
10458 : : memset(&flags, 0, sizeof(flags));
10459 : :
10460 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10461 : :
10462 [ # # ]: 0 : if (td_outb.aes_gmac || td_outb.aead ||
10463 [ # # ]: 0 : ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10464 [ # # ]: 0 : (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10465 : : /* Disable IV gen to be able to test with known vectors */
10466 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10467 : : }
10468 : :
10469 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10470 : : }
10471 : :
10472 : : static int
10473 [ # # ]: 0 : test_ipsec_proto_known_vec_ext_mbuf(const void *test_data)
10474 : : {
10475 : : struct ipsec_test_data td_outb;
10476 : : struct ipsec_test_flags flags;
10477 : :
10478 : : memset(&flags, 0, sizeof(flags));
10479 [ # # ]: 0 : flags.use_ext_mbuf = true;
10480 : :
10481 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10482 : :
10483 [ # # ]: 0 : if (td_outb.aes_gmac || td_outb.aead ||
10484 [ # # ]: 0 : ((td_outb.ipsec_xform.proto != RTE_SECURITY_IPSEC_SA_PROTO_AH) &&
10485 [ # # ]: 0 : (td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL))) {
10486 : : /* Disable IV gen to be able to test with known vectors */
10487 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10488 : : }
10489 : :
10490 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10491 : : }
10492 : :
10493 : : static int
10494 [ # # ]: 0 : test_ipsec_proto_known_vec_inb(const void *test_data)
10495 : : {
10496 : : const struct ipsec_test_data *td = test_data;
10497 : : struct ipsec_test_flags flags;
10498 : : struct ipsec_test_data td_inb;
10499 : :
10500 : : memset(&flags, 0, sizeof(flags));
10501 : :
10502 [ # # ]: 0 : if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10503 : 0 : test_ipsec_td_in_from_out(td, &td_inb);
10504 : : else
10505 : : memcpy(&td_inb, td, sizeof(td_inb));
10506 : :
10507 : 0 : return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10508 : : }
10509 : :
10510 : : static int
10511 : 0 : test_ipsec_proto_known_vec_fragmented(const void *test_data)
10512 : : {
10513 : : struct ipsec_test_data td_outb;
10514 : : struct ipsec_test_flags flags;
10515 : :
10516 : : memset(&flags, 0, sizeof(flags));
10517 : 0 : flags.fragment = true;
10518 : :
10519 : : memcpy(&td_outb, test_data, sizeof(td_outb));
10520 : :
10521 : : /* Disable IV gen to be able to test with known vectors */
10522 : 0 : td_outb.ipsec_xform.options.iv_gen_disable = 1;
10523 : :
10524 : 0 : return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
10525 : : }
10526 : :
10527 : : static int
10528 [ # # ]: 0 : test_ipsec_proto_known_vec_inb_rx_inject(const void *test_data)
10529 : : {
10530 : : const struct ipsec_test_data *td = test_data;
10531 : : struct ipsec_test_flags flags;
10532 : : struct ipsec_test_data td_inb;
10533 : :
10534 : : memset(&flags, 0, sizeof(flags));
10535 : 0 : flags.rx_inject = true;
10536 : :
10537 [ # # ]: 0 : if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
10538 : 0 : test_ipsec_td_in_from_out(td, &td_inb);
10539 : : else
10540 : : memcpy(&td_inb, td, sizeof(td_inb));
10541 : :
10542 : 0 : return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
10543 : : }
10544 : :
10545 : : static int
10546 : 0 : test_ipsec_proto_all(const struct ipsec_test_flags *flags)
10547 : : {
10548 : : struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
10549 : : struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
10550 : : unsigned int i, nb_pkts = 1, pass_cnt = 0;
10551 : : int ret;
10552 : :
10553 [ # # ]: 0 : if (flags->iv_gen ||
10554 [ # # ]: 0 : flags->sa_expiry_pkts_soft ||
10555 : : flags->sa_expiry_pkts_hard)
10556 : : nb_pkts = TEST_SEC_PKTS_MAX;
10557 : :
10558 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
10559 : 0 : test_ipsec_td_prepare(sec_alg_list[i].param1,
10560 : : sec_alg_list[i].param2,
10561 : : flags,
10562 : : td_outb,
10563 : : nb_pkts);
10564 : :
10565 [ # # ]: 0 : if (!td_outb->aead) {
10566 : : enum rte_crypto_cipher_algorithm cipher_alg;
10567 : : enum rte_crypto_auth_algorithm auth_alg;
10568 : :
10569 : 0 : cipher_alg = td_outb->xform.chain.cipher.cipher.algo;
10570 : 0 : auth_alg = td_outb->xform.chain.auth.auth.algo;
10571 : :
10572 [ # # # # ]: 0 : if (td_outb->aes_gmac && cipher_alg != RTE_CRYPTO_CIPHER_NULL)
10573 : 0 : continue;
10574 : :
10575 : : /* ICV is not applicable for NULL auth */
10576 [ # # # # ]: 0 : if (flags->icv_corrupt &&
10577 : : auth_alg == RTE_CRYPTO_AUTH_NULL)
10578 : 0 : continue;
10579 : :
10580 : : /* IV is not applicable for NULL cipher */
10581 [ # # # # ]: 0 : if (flags->iv_gen &&
10582 : : cipher_alg == RTE_CRYPTO_CIPHER_NULL)
10583 : 0 : continue;
10584 : : }
10585 : :
10586 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10587 : : flags);
10588 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10589 : 0 : continue;
10590 : :
10591 [ # # ]: 0 : if (ret == TEST_FAILED)
10592 : : return TEST_FAILED;
10593 : :
10594 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10595 : :
10596 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10597 : : flags);
10598 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10599 : 0 : continue;
10600 : :
10601 [ # # ]: 0 : if (ret == TEST_FAILED)
10602 : : return TEST_FAILED;
10603 : :
10604 [ # # ]: 0 : if (flags->display_alg)
10605 : 0 : test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
10606 : :
10607 : 0 : pass_cnt++;
10608 : : }
10609 : :
10610 [ # # ]: 0 : if (pass_cnt > 0)
10611 : : return TEST_SUCCESS;
10612 : : else
10613 : 0 : return TEST_SKIPPED;
10614 : : }
10615 : :
10616 : : static int
10617 : 0 : test_ipsec_ah_proto_all(const struct ipsec_test_flags *flags)
10618 : : {
10619 : : struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
10620 : : struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
10621 : : unsigned int i, nb_pkts = 1, pass_cnt = 0;
10622 : : int ret;
10623 : :
10624 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_auth_only_alg_list); i++) {
10625 : 0 : test_ipsec_td_prepare(sec_auth_only_alg_list[i].param1,
10626 : : sec_auth_only_alg_list[i].param2,
10627 : : flags,
10628 : : td_outb,
10629 : : nb_pkts);
10630 : :
10631 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
10632 : : flags);
10633 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10634 : 0 : continue;
10635 : :
10636 [ # # ]: 0 : if (ret == TEST_FAILED)
10637 : : return TEST_FAILED;
10638 : :
10639 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
10640 : :
10641 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
10642 : : flags);
10643 [ # # ]: 0 : if (ret == TEST_SKIPPED)
10644 : 0 : continue;
10645 : :
10646 [ # # ]: 0 : if (ret == TEST_FAILED)
10647 : : return TEST_FAILED;
10648 : :
10649 [ # # ]: 0 : if (flags->display_alg)
10650 : 0 : test_sec_alg_display(sec_auth_only_alg_list[i].param1,
10651 : : sec_auth_only_alg_list[i].param2);
10652 : :
10653 : 0 : pass_cnt++;
10654 : : }
10655 : :
10656 [ # # ]: 0 : if (pass_cnt > 0)
10657 : : return TEST_SUCCESS;
10658 : : else
10659 : 0 : return TEST_SKIPPED;
10660 : : }
10661 : :
10662 : : static int
10663 : 0 : test_ipsec_proto_display_list(void)
10664 : : {
10665 : : struct ipsec_test_flags flags;
10666 : :
10667 : : memset(&flags, 0, sizeof(flags));
10668 : :
10669 : 0 : flags.display_alg = true;
10670 : :
10671 : 0 : return test_ipsec_proto_all(&flags);
10672 : : }
10673 : :
10674 : : static int
10675 : 0 : test_ipsec_proto_ah_tunnel_ipv4(void)
10676 : : {
10677 : : struct ipsec_test_flags flags;
10678 : :
10679 : : memset(&flags, 0, sizeof(flags));
10680 : :
10681 : 0 : flags.ah = true;
10682 : 0 : flags.display_alg = true;
10683 : :
10684 : 0 : return test_ipsec_ah_proto_all(&flags);
10685 : : }
10686 : :
10687 : : static int
10688 : 0 : test_ipsec_proto_ah_transport_ipv4(void)
10689 : : {
10690 : : struct ipsec_test_flags flags;
10691 : :
10692 : : memset(&flags, 0, sizeof(flags));
10693 : :
10694 : 0 : flags.ah = true;
10695 : 0 : flags.transport = true;
10696 : :
10697 : 0 : return test_ipsec_ah_proto_all(&flags);
10698 : : }
10699 : :
10700 : : static int
10701 : 0 : test_ipsec_proto_iv_gen(void)
10702 : : {
10703 : : struct ipsec_test_flags flags;
10704 : :
10705 : : memset(&flags, 0, sizeof(flags));
10706 : :
10707 : 0 : flags.iv_gen = true;
10708 : :
10709 : 0 : return test_ipsec_proto_all(&flags);
10710 : : }
10711 : :
10712 : : static int
10713 : 0 : test_ipsec_proto_sa_exp_pkts_soft(void)
10714 : : {
10715 : : struct ipsec_test_flags flags;
10716 : :
10717 : : memset(&flags, 0, sizeof(flags));
10718 : :
10719 : 0 : flags.sa_expiry_pkts_soft = true;
10720 : :
10721 : 0 : return test_ipsec_proto_all(&flags);
10722 : : }
10723 : :
10724 : : static int
10725 : 0 : test_ipsec_proto_sa_exp_pkts_hard(void)
10726 : : {
10727 : : struct ipsec_test_flags flags;
10728 : :
10729 : : memset(&flags, 0, sizeof(flags));
10730 : :
10731 : 0 : flags.sa_expiry_pkts_hard = true;
10732 : :
10733 : 0 : return test_ipsec_proto_all(&flags);
10734 : : }
10735 : :
10736 : : static int
10737 : 0 : test_ipsec_proto_err_icv_corrupt(void)
10738 : : {
10739 : : struct ipsec_test_flags flags;
10740 : :
10741 : : memset(&flags, 0, sizeof(flags));
10742 : :
10743 : 0 : flags.icv_corrupt = true;
10744 : :
10745 : 0 : return test_ipsec_proto_all(&flags);
10746 : : }
10747 : :
10748 : : static int
10749 : 0 : test_ipsec_proto_udp_encap_custom_ports(void)
10750 : : {
10751 : : struct ipsec_test_flags flags;
10752 : :
10753 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
10754 : : RTE_STR(CRYPTODEV_NAME_CN10K_PMD)))
10755 : : return TEST_SKIPPED;
10756 : :
10757 : : memset(&flags, 0, sizeof(flags));
10758 : :
10759 : 0 : flags.udp_encap = true;
10760 : 0 : flags.udp_encap_custom_ports = true;
10761 : :
10762 : 0 : return test_ipsec_proto_all(&flags);
10763 : : }
10764 : :
10765 : : static int
10766 : 0 : test_ipsec_proto_udp_encap(void)
10767 : : {
10768 : : struct ipsec_test_flags flags;
10769 : :
10770 : : memset(&flags, 0, sizeof(flags));
10771 : :
10772 : 0 : flags.udp_encap = true;
10773 : :
10774 : 0 : return test_ipsec_proto_all(&flags);
10775 : : }
10776 : :
10777 : : static int
10778 : 0 : test_ipsec_proto_tunnel_src_dst_addr_verify(void)
10779 : : {
10780 : : struct ipsec_test_flags flags;
10781 : :
10782 : : memset(&flags, 0, sizeof(flags));
10783 : :
10784 : 0 : flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
10785 : :
10786 : 0 : return test_ipsec_proto_all(&flags);
10787 : : }
10788 : :
10789 : : static int
10790 : 0 : test_ipsec_proto_tunnel_dst_addr_verify(void)
10791 : : {
10792 : : struct ipsec_test_flags flags;
10793 : :
10794 : : memset(&flags, 0, sizeof(flags));
10795 : :
10796 : 0 : flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
10797 : :
10798 : 0 : return test_ipsec_proto_all(&flags);
10799 : : }
10800 : :
10801 : : static int
10802 : 0 : test_ipsec_proto_udp_ports_verify(void)
10803 : : {
10804 : : struct ipsec_test_flags flags;
10805 : :
10806 : : memset(&flags, 0, sizeof(flags));
10807 : :
10808 : 0 : flags.udp_encap = true;
10809 : 0 : flags.udp_ports_verify = true;
10810 : :
10811 : 0 : return test_ipsec_proto_all(&flags);
10812 : : }
10813 : :
10814 : : static int
10815 : 0 : test_ipsec_proto_inner_ip_csum(void)
10816 : : {
10817 : : struct ipsec_test_flags flags;
10818 : :
10819 : : memset(&flags, 0, sizeof(flags));
10820 : :
10821 : 0 : flags.ip_csum = true;
10822 : :
10823 : 0 : return test_ipsec_proto_all(&flags);
10824 : : }
10825 : :
10826 : : static int
10827 : 0 : test_ipsec_proto_inner_l4_csum(void)
10828 : : {
10829 : : struct ipsec_test_flags flags;
10830 : :
10831 : : memset(&flags, 0, sizeof(flags));
10832 : :
10833 : 0 : flags.l4_csum = true;
10834 : :
10835 : 0 : return test_ipsec_proto_all(&flags);
10836 : : }
10837 : :
10838 : : static int
10839 : 0 : test_ipsec_proto_tunnel_v4_in_v4(void)
10840 : : {
10841 : : struct ipsec_test_flags flags;
10842 : :
10843 : : memset(&flags, 0, sizeof(flags));
10844 : :
10845 : : flags.ipv6 = false;
10846 : : flags.tunnel_ipv6 = false;
10847 : :
10848 : 0 : return test_ipsec_proto_all(&flags);
10849 : : }
10850 : :
10851 : : static int
10852 : 0 : test_ipsec_proto_tunnel_v6_in_v6(void)
10853 : : {
10854 : : struct ipsec_test_flags flags;
10855 : :
10856 : : memset(&flags, 0, sizeof(flags));
10857 : :
10858 : 0 : flags.ipv6 = true;
10859 : 0 : flags.tunnel_ipv6 = true;
10860 : :
10861 : 0 : return test_ipsec_proto_all(&flags);
10862 : : }
10863 : :
10864 : : static int
10865 : 0 : test_ipsec_proto_tunnel_v4_in_v6(void)
10866 : : {
10867 : : struct ipsec_test_flags flags;
10868 : :
10869 : : memset(&flags, 0, sizeof(flags));
10870 : :
10871 : : flags.ipv6 = false;
10872 : 0 : flags.tunnel_ipv6 = true;
10873 : :
10874 : 0 : return test_ipsec_proto_all(&flags);
10875 : : }
10876 : :
10877 : : static int
10878 : 0 : test_ipsec_proto_tunnel_v6_in_v4(void)
10879 : : {
10880 : : struct ipsec_test_flags flags;
10881 : :
10882 : : memset(&flags, 0, sizeof(flags));
10883 : :
10884 : 0 : flags.ipv6 = true;
10885 : : flags.tunnel_ipv6 = false;
10886 : :
10887 : 0 : return test_ipsec_proto_all(&flags);
10888 : : }
10889 : :
10890 : : static int
10891 : 0 : test_ipsec_proto_transport_v4(void)
10892 : : {
10893 : : struct ipsec_test_flags flags;
10894 : :
10895 : : memset(&flags, 0, sizeof(flags));
10896 : :
10897 : : flags.ipv6 = false;
10898 : 0 : flags.transport = true;
10899 : :
10900 : 0 : return test_ipsec_proto_all(&flags);
10901 : : }
10902 : :
10903 : : static int
10904 : 0 : test_ipsec_proto_transport_l4_csum(void)
10905 : : {
10906 : 0 : struct ipsec_test_flags flags = {
10907 : : .l4_csum = true,
10908 : : .transport = true,
10909 : : };
10910 : :
10911 : 0 : return test_ipsec_proto_all(&flags);
10912 : : }
10913 : :
10914 : : static int
10915 : 0 : test_ipsec_proto_stats(void)
10916 : : {
10917 : : struct ipsec_test_flags flags;
10918 : :
10919 : : memset(&flags, 0, sizeof(flags));
10920 : :
10921 : 0 : flags.stats_success = true;
10922 : :
10923 : 0 : return test_ipsec_proto_all(&flags);
10924 : : }
10925 : :
10926 : : static int
10927 : 0 : test_ipsec_proto_pkt_fragment(void)
10928 : : {
10929 : : struct ipsec_test_flags flags;
10930 : :
10931 : : memset(&flags, 0, sizeof(flags));
10932 : :
10933 : 0 : flags.fragment = true;
10934 : :
10935 : 0 : return test_ipsec_proto_all(&flags);
10936 : :
10937 : : }
10938 : :
10939 : : static int
10940 : 0 : test_ipsec_proto_copy_df_inner_0(void)
10941 : : {
10942 : : struct ipsec_test_flags flags;
10943 : :
10944 : : memset(&flags, 0, sizeof(flags));
10945 : :
10946 : 0 : flags.df = TEST_IPSEC_COPY_DF_INNER_0;
10947 : :
10948 : 0 : return test_ipsec_proto_all(&flags);
10949 : : }
10950 : :
10951 : : static int
10952 : 0 : test_ipsec_proto_copy_df_inner_1(void)
10953 : : {
10954 : : struct ipsec_test_flags flags;
10955 : :
10956 : : memset(&flags, 0, sizeof(flags));
10957 : :
10958 : 0 : flags.df = TEST_IPSEC_COPY_DF_INNER_1;
10959 : :
10960 : 0 : return test_ipsec_proto_all(&flags);
10961 : : }
10962 : :
10963 : : static int
10964 : 0 : test_ipsec_proto_set_df_0_inner_1(void)
10965 : : {
10966 : : struct ipsec_test_flags flags;
10967 : :
10968 : : memset(&flags, 0, sizeof(flags));
10969 : :
10970 : 0 : flags.df = TEST_IPSEC_SET_DF_0_INNER_1;
10971 : :
10972 : 0 : return test_ipsec_proto_all(&flags);
10973 : : }
10974 : :
10975 : : static int
10976 : 0 : test_ipsec_proto_set_df_1_inner_0(void)
10977 : : {
10978 : : struct ipsec_test_flags flags;
10979 : :
10980 : : memset(&flags, 0, sizeof(flags));
10981 : :
10982 : 0 : flags.df = TEST_IPSEC_SET_DF_1_INNER_0;
10983 : :
10984 : 0 : return test_ipsec_proto_all(&flags);
10985 : : }
10986 : :
10987 : : static int
10988 : 0 : test_ipsec_proto_ipv4_copy_dscp_inner_0(void)
10989 : : {
10990 : : struct ipsec_test_flags flags;
10991 : :
10992 : : memset(&flags, 0, sizeof(flags));
10993 : :
10994 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
10995 : :
10996 : 0 : return test_ipsec_proto_all(&flags);
10997 : : }
10998 : :
10999 : : static int
11000 : 0 : test_ipsec_proto_ipv4_copy_dscp_inner_1(void)
11001 : : {
11002 : : struct ipsec_test_flags flags;
11003 : :
11004 : : memset(&flags, 0, sizeof(flags));
11005 : :
11006 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
11007 : :
11008 : 0 : return test_ipsec_proto_all(&flags);
11009 : : }
11010 : :
11011 : : static int
11012 : 0 : test_ipsec_proto_ipv4_set_dscp_0_inner_1(void)
11013 : : {
11014 : : struct ipsec_test_flags flags;
11015 : :
11016 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11017 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11018 : : return TEST_SKIPPED;
11019 : :
11020 : : memset(&flags, 0, sizeof(flags));
11021 : :
11022 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
11023 : :
11024 : 0 : return test_ipsec_proto_all(&flags);
11025 : : }
11026 : :
11027 : : static int
11028 : 0 : test_ipsec_proto_ipv4_set_dscp_1_inner_0(void)
11029 : : {
11030 : : struct ipsec_test_flags flags;
11031 : :
11032 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11033 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11034 : : return TEST_SKIPPED;
11035 : :
11036 : : memset(&flags, 0, sizeof(flags));
11037 : :
11038 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11039 : :
11040 : 0 : return test_ipsec_proto_all(&flags);
11041 : : }
11042 : :
11043 : : static int
11044 : 0 : test_ipsec_proto_ipv6_copy_dscp_inner_0(void)
11045 : : {
11046 : : struct ipsec_test_flags flags;
11047 : :
11048 : : memset(&flags, 0, sizeof(flags));
11049 : :
11050 : 0 : flags.ipv6 = true;
11051 : 0 : flags.tunnel_ipv6 = true;
11052 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
11053 : :
11054 : 0 : return test_ipsec_proto_all(&flags);
11055 : : }
11056 : :
11057 : : static int
11058 : 0 : test_ipsec_proto_ipv6_copy_dscp_inner_1(void)
11059 : : {
11060 : : struct ipsec_test_flags flags;
11061 : :
11062 : : memset(&flags, 0, sizeof(flags));
11063 : :
11064 : 0 : flags.ipv6 = true;
11065 : 0 : flags.tunnel_ipv6 = true;
11066 : 0 : flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
11067 : :
11068 : 0 : return test_ipsec_proto_all(&flags);
11069 : : }
11070 : :
11071 : : static int
11072 : 0 : test_ipsec_proto_ipv6_set_dscp_0_inner_1(void)
11073 : : {
11074 : : struct ipsec_test_flags flags;
11075 : :
11076 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11077 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11078 : : return TEST_SKIPPED;
11079 : :
11080 : : memset(&flags, 0, sizeof(flags));
11081 : :
11082 : 0 : flags.ipv6 = true;
11083 : 0 : flags.tunnel_ipv6 = true;
11084 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
11085 : :
11086 : 0 : return test_ipsec_proto_all(&flags);
11087 : : }
11088 : :
11089 : : static int
11090 : 0 : test_ipsec_proto_ipv6_set_dscp_1_inner_0(void)
11091 : : {
11092 : : struct ipsec_test_flags flags;
11093 : :
11094 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
11095 : : RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
11096 : : return TEST_SKIPPED;
11097 : :
11098 : : memset(&flags, 0, sizeof(flags));
11099 : :
11100 : 0 : flags.ipv6 = true;
11101 : 0 : flags.tunnel_ipv6 = true;
11102 : 0 : flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
11103 : :
11104 : 0 : return test_ipsec_proto_all(&flags);
11105 : : }
11106 : :
11107 : : static int
11108 : 0 : test_ipsec_proto_sgl(void)
11109 : : {
11110 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11111 : : struct rte_cryptodev_info dev_info;
11112 : :
11113 : 0 : struct ipsec_test_flags flags = {
11114 : : .nb_segs_in_mbuf = 5
11115 : : };
11116 : :
11117 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11118 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11119 : : printf("Device doesn't support in-place scatter-gather. "
11120 : : "Test Skipped.\n");
11121 : 0 : return TEST_SKIPPED;
11122 : : }
11123 : :
11124 : 0 : return test_ipsec_proto_all(&flags);
11125 : : }
11126 : :
11127 : : static int
11128 : 0 : test_ipsec_proto_sgl_ext_mbuf(void)
11129 : : {
11130 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11131 : : struct rte_cryptodev_info dev_info;
11132 : :
11133 : 0 : struct ipsec_test_flags flags = {
11134 : : .nb_segs_in_mbuf = 5,
11135 : : .use_ext_mbuf = 1
11136 : : };
11137 : :
11138 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11139 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
11140 : : printf("Device doesn't support in-place scatter-gather. "
11141 : : "Test Skipped.\n");
11142 : 0 : return TEST_SKIPPED;
11143 : : }
11144 : :
11145 : 0 : return test_ipsec_proto_all(&flags);
11146 : : }
11147 : :
11148 : : static int
11149 : 0 : test_ipsec_pkt_replay(const void *test_data, const uint64_t esn[],
11150 : : bool replayed_pkt[], uint32_t nb_pkts, bool esn_en,
11151 : : uint64_t winsz)
11152 : : {
11153 : : struct ipsec_test_data td_outb[TEST_SEC_PKTS_MAX];
11154 : : struct ipsec_test_data td_inb[TEST_SEC_PKTS_MAX];
11155 : : struct ipsec_test_flags flags;
11156 : : uint32_t i = 0, ret = 0;
11157 : :
11158 [ # # ]: 0 : if (nb_pkts == 0)
11159 : : return TEST_FAILED;
11160 : :
11161 : : memset(&flags, 0, sizeof(flags));
11162 : 0 : flags.antireplay = true;
11163 : :
11164 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
11165 : 0 : memcpy(&td_outb[i], test_data, sizeof(td_outb[i]));
11166 : 0 : td_outb[i].ipsec_xform.options.iv_gen_disable = 1;
11167 : 0 : td_outb[i].ipsec_xform.replay_win_sz = winsz;
11168 : 0 : td_outb[i].ipsec_xform.options.esn = esn_en;
11169 : : }
11170 : :
11171 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++)
11172 : 0 : td_outb[i].ipsec_xform.esn.value = esn[i];
11173 : :
11174 : 0 : ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
11175 : : &flags);
11176 [ # # ]: 0 : if (ret != TEST_SUCCESS)
11177 : : return ret;
11178 : :
11179 : 0 : test_ipsec_td_update(td_inb, td_outb, nb_pkts, &flags);
11180 : :
11181 [ # # ]: 0 : for (i = 0; i < nb_pkts; i++) {
11182 : 0 : td_inb[i].ipsec_xform.options.esn = esn_en;
11183 : : /* Set antireplay flag for packets to be dropped */
11184 : 0 : td_inb[i].ar_packet = replayed_pkt[i];
11185 : : }
11186 : :
11187 : 0 : ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
11188 : : &flags);
11189 : :
11190 : 0 : return ret;
11191 : : }
11192 : :
11193 : : static int
11194 : 0 : test_ipsec_proto_pkt_antireplay(const void *test_data, uint64_t winsz)
11195 : : {
11196 : :
11197 : : uint32_t nb_pkts = 5;
11198 : : bool replayed_pkt[5];
11199 : : uint64_t esn[5];
11200 : :
11201 : : /* 1. Advance the TOP of the window to WS * 2 */
11202 : 0 : esn[0] = winsz * 2;
11203 : : /* 2. Test sequence number within the new window(WS + 1) */
11204 : 0 : esn[1] = winsz + 1;
11205 : : /* 3. Test sequence number less than the window BOTTOM */
11206 : 0 : esn[2] = winsz;
11207 : : /* 4. Test sequence number in the middle of the window */
11208 : 0 : esn[3] = winsz + (winsz / 2);
11209 : : /* 5. Test replay of the packet in the middle of the window */
11210 : 0 : esn[4] = winsz + (winsz / 2);
11211 : :
11212 : 0 : replayed_pkt[0] = false;
11213 : 0 : replayed_pkt[1] = false;
11214 : 0 : replayed_pkt[2] = true;
11215 : 0 : replayed_pkt[3] = false;
11216 : 0 : replayed_pkt[4] = true;
11217 : :
11218 : 0 : return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11219 : : false, winsz);
11220 : : }
11221 : :
11222 : : static int
11223 : 0 : test_ipsec_proto_pkt_antireplay1024(const void *test_data)
11224 : : {
11225 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 1024);
11226 : : }
11227 : :
11228 : : static int
11229 : 0 : test_ipsec_proto_pkt_antireplay2048(const void *test_data)
11230 : : {
11231 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 2048);
11232 : : }
11233 : :
11234 : : static int
11235 : 0 : test_ipsec_proto_pkt_antireplay4096(const void *test_data)
11236 : : {
11237 : 0 : return test_ipsec_proto_pkt_antireplay(test_data, 4096);
11238 : : }
11239 : :
11240 : : static int
11241 : 0 : test_ipsec_proto_pkt_esn_antireplay(const void *test_data, uint64_t winsz)
11242 : : {
11243 : :
11244 : : uint32_t nb_pkts = 7;
11245 : : bool replayed_pkt[7];
11246 : : uint64_t esn[7];
11247 : :
11248 : : /* Set the initial sequence number */
11249 : 0 : esn[0] = (uint64_t)(0xFFFFFFFF - winsz);
11250 : : /* 1. Advance the TOP of the window to (1<<32 + WS/2) */
11251 : 0 : esn[1] = (uint64_t)((1ULL << 32) + (winsz / 2));
11252 : : /* 2. Test sequence number within new window (1<<32 + WS/2 + 1) */
11253 : 0 : esn[2] = (uint64_t)((1ULL << 32) - (winsz / 2) + 1);
11254 : : /* 3. Test with sequence number within window (1<<32 - 1) */
11255 : 0 : esn[3] = (uint64_t)((1ULL << 32) - 1);
11256 : : /* 4. Test with sequence number within window (1<<32 - 1) */
11257 : 0 : esn[4] = (uint64_t)(1ULL << 32);
11258 : : /* 5. Test with duplicate sequence number within
11259 : : * new window (1<<32 - 1)
11260 : : */
11261 : 0 : esn[5] = (uint64_t)((1ULL << 32) - 1);
11262 : : /* 6. Test with duplicate sequence number within new window (1<<32) */
11263 : 0 : esn[6] = (uint64_t)(1ULL << 32);
11264 : :
11265 : 0 : replayed_pkt[0] = false;
11266 : 0 : replayed_pkt[1] = false;
11267 : 0 : replayed_pkt[2] = false;
11268 : 0 : replayed_pkt[3] = false;
11269 : 0 : replayed_pkt[4] = false;
11270 : 0 : replayed_pkt[5] = true;
11271 : 0 : replayed_pkt[6] = true;
11272 : :
11273 : 0 : return test_ipsec_pkt_replay(test_data, esn, replayed_pkt, nb_pkts,
11274 : : true, winsz);
11275 : : }
11276 : :
11277 : : static int
11278 : 0 : test_ipsec_proto_pkt_esn_antireplay1024(const void *test_data)
11279 : : {
11280 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 1024);
11281 : : }
11282 : :
11283 : : static int
11284 : 0 : test_ipsec_proto_pkt_esn_antireplay2048(const void *test_data)
11285 : : {
11286 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 2048);
11287 : : }
11288 : :
11289 : : static int
11290 : 0 : test_ipsec_proto_pkt_esn_antireplay4096(const void *test_data)
11291 : : {
11292 : 0 : return test_ipsec_proto_pkt_esn_antireplay(test_data, 4096);
11293 : : }
11294 : :
11295 : : static int
11296 : 0 : test_PDCP_PROTO_all(void)
11297 : : {
11298 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11299 : : struct crypto_unittest_params *ut_params = &unittest_params;
11300 : : struct rte_cryptodev_info dev_info;
11301 : : int status;
11302 : :
11303 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11304 : 0 : uint64_t feat_flags = dev_info.feature_flags;
11305 : :
11306 [ # # ]: 0 : if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
11307 : : return TEST_SKIPPED;
11308 : :
11309 : : /* Set action type */
11310 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11311 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11312 : : gbl_action_type;
11313 : :
11314 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11315 : : RTE_SECURITY_PROTOCOL_PDCP) < 0)
11316 : : return TEST_SKIPPED;
11317 : :
11318 : 0 : status = test_PDCP_PROTO_cplane_encap_all();
11319 : 0 : status += test_PDCP_PROTO_cplane_decap_all();
11320 : 0 : status += test_PDCP_PROTO_uplane_encap_all();
11321 : 0 : status += test_PDCP_PROTO_uplane_decap_all();
11322 : 0 : status += test_PDCP_PROTO_SGL_in_place_32B();
11323 : 0 : status += test_PDCP_PROTO_SGL_oop_32B_128B();
11324 : 0 : status += test_PDCP_PROTO_SGL_oop_32B_40B();
11325 : 0 : status += test_PDCP_PROTO_SGL_oop_128B_32B();
11326 : 0 : status += test_PDCP_SDAP_PROTO_encap_all();
11327 : 0 : status += test_PDCP_SDAP_PROTO_decap_all();
11328 : 0 : status += test_PDCP_PROTO_short_mac();
11329 : :
11330 [ # # ]: 0 : if (status)
11331 : : return TEST_FAILED;
11332 : : else
11333 : 0 : return TEST_SUCCESS;
11334 : : }
11335 : :
11336 : : static int
11337 : 0 : test_ipsec_proto_ipv4_ttl_decrement(void)
11338 : : {
11339 : 0 : struct ipsec_test_flags flags = {
11340 : : .dec_ttl_or_hop_limit = true
11341 : : };
11342 : :
11343 : 0 : return test_ipsec_proto_all(&flags);
11344 : : }
11345 : :
11346 : : static int
11347 : 0 : test_ipsec_proto_ipv6_hop_limit_decrement(void)
11348 : : {
11349 : 0 : struct ipsec_test_flags flags = {
11350 : : .ipv6 = true,
11351 : : .dec_ttl_or_hop_limit = true
11352 : : };
11353 : :
11354 : 0 : return test_ipsec_proto_all(&flags);
11355 : : }
11356 : :
11357 : : static int
11358 : 0 : test_docsis_proto_uplink(const void *data)
11359 : : {
11360 : : const struct docsis_test_data *d_td = data;
11361 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11362 : : struct crypto_unittest_params *ut_params = &unittest_params;
11363 : : uint8_t *plaintext = NULL;
11364 : : uint8_t *ciphertext = NULL;
11365 : : uint8_t *iv_ptr;
11366 : : int32_t cipher_len, crc_len;
11367 : : uint32_t crc_data_len;
11368 : : int ret = TEST_SUCCESS;
11369 : :
11370 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11371 : :
11372 : : /* Verify the capabilities */
11373 : : struct rte_security_capability_idx sec_cap_idx;
11374 : : const struct rte_security_capability *sec_cap;
11375 : : const struct rte_cryptodev_capabilities *crypto_cap;
11376 : : const struct rte_cryptodev_symmetric_capability *sym_cap;
11377 : : int j = 0;
11378 : :
11379 : : /* Set action type */
11380 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11381 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11382 : : gbl_action_type;
11383 : :
11384 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11385 : : RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11386 : : return TEST_SKIPPED;
11387 : :
11388 : 0 : sec_cap_idx.action = ut_params->type;
11389 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11390 : 0 : sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
11391 : :
11392 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11393 [ # # ]: 0 : if (sec_cap == NULL)
11394 : : return TEST_SKIPPED;
11395 : :
11396 [ # # ]: 0 : while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11397 : : RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11398 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11399 : : crypto_cap->sym.xform_type ==
11400 [ # # ]: 0 : RTE_CRYPTO_SYM_XFORM_CIPHER &&
11401 : : crypto_cap->sym.cipher.algo ==
11402 : : RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11403 : 0 : sym_cap = &crypto_cap->sym;
11404 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11405 : 0 : d_td->key.len,
11406 : 0 : d_td->iv.len) == 0)
11407 : : break;
11408 : : }
11409 : : }
11410 : :
11411 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11412 : : return TEST_SKIPPED;
11413 : :
11414 : : /* Setup source mbuf payload */
11415 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11416 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11417 : : rte_pktmbuf_tailroom(ut_params->ibuf));
11418 : :
11419 : 0 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11420 : 0 : d_td->ciphertext.len);
11421 : :
11422 : 0 : memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
11423 : :
11424 : : /* Setup cipher session parameters */
11425 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11426 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11427 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
11428 : 0 : ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11429 : 0 : ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11430 : 0 : ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11431 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11432 : 0 : ut_params->cipher_xform.next = NULL;
11433 : :
11434 : : /* Setup DOCSIS session parameters */
11435 : 0 : ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
11436 : :
11437 : 0 : struct rte_security_session_conf sess_conf = {
11438 : 0 : .action_type = ut_params->type,
11439 : : .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11440 : : .docsis = ut_params->docsis_xform,
11441 : : .crypto_xform = &ut_params->cipher_xform,
11442 : : };
11443 : :
11444 : : /* Create security session */
11445 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11446 : : ts_params->session_mpool);
11447 : :
11448 [ # # ]: 0 : if (!ut_params->sec_session) {
11449 : : printf("Test function %s line %u: failed to allocate session\n",
11450 : : __func__, __LINE__);
11451 : : ret = TEST_FAILED;
11452 : 0 : goto on_err;
11453 : : }
11454 : :
11455 : : /* Generate crypto op data structure */
11456 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11457 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11458 [ # # ]: 0 : if (!ut_params->op) {
11459 : : printf("Test function %s line %u: failed to allocate symmetric "
11460 : : "crypto operation\n", __func__, __LINE__);
11461 : : ret = TEST_FAILED;
11462 : 0 : goto on_err;
11463 : : }
11464 : :
11465 : : /* Setup CRC operation parameters */
11466 : 0 : crc_len = d_td->ciphertext.no_crc == false ?
11467 : 0 : (d_td->ciphertext.len -
11468 : 0 : d_td->ciphertext.crc_offset -
11469 [ # # ]: 0 : RTE_ETHER_CRC_LEN) :
11470 : : 0;
11471 : 0 : crc_len = crc_len > 0 ? crc_len : 0;
11472 [ # # ]: 0 : crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
11473 : 0 : ut_params->op->sym->auth.data.length = crc_len;
11474 : 0 : ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
11475 : :
11476 : : /* Setup cipher operation parameters */
11477 : 0 : cipher_len = d_td->ciphertext.no_cipher == false ?
11478 : 0 : (d_td->ciphertext.len -
11479 [ # # ]: 0 : d_td->ciphertext.cipher_offset) :
11480 : : 0;
11481 : 0 : cipher_len = cipher_len > 0 ? cipher_len : 0;
11482 : 0 : ut_params->op->sym->cipher.data.length = cipher_len;
11483 : 0 : ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
11484 : :
11485 : : /* Setup cipher IV */
11486 : 0 : iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11487 [ # # ]: 0 : rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11488 : :
11489 : : /* Attach session to operation */
11490 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
11491 : :
11492 : : /* Set crypto operation mbufs */
11493 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
11494 : 0 : ut_params->op->sym->m_dst = NULL;
11495 : :
11496 : : /* Process crypto operation */
11497 [ # # ]: 0 : if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11498 : : NULL) {
11499 : : printf("Test function %s line %u: failed to process security "
11500 : : "crypto op\n", __func__, __LINE__);
11501 : : ret = TEST_FAILED;
11502 : 0 : goto on_err;
11503 : : }
11504 : :
11505 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11506 : : printf("Test function %s line %u: failed to process crypto op\n",
11507 : : __func__, __LINE__);
11508 : : ret = TEST_FAILED;
11509 : 0 : goto on_err;
11510 : : }
11511 : :
11512 : : /* Validate plaintext */
11513 : : plaintext = ciphertext;
11514 : :
11515 : 0 : if (memcmp(plaintext, d_td->plaintext.data,
11516 [ # # ]: 0 : d_td->plaintext.len - crc_data_len)) {
11517 : : printf("Test function %s line %u: plaintext not as expected\n",
11518 : : __func__, __LINE__);
11519 : 0 : rte_hexdump(stdout, "expected", d_td->plaintext.data,
11520 : 0 : d_td->plaintext.len);
11521 : 0 : rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
11522 : : ret = TEST_FAILED;
11523 : 0 : goto on_err;
11524 : : }
11525 : :
11526 : 0 : on_err:
11527 : 0 : rte_crypto_op_free(ut_params->op);
11528 : 0 : ut_params->op = NULL;
11529 : :
11530 [ # # ]: 0 : if (ut_params->sec_session)
11531 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
11532 : 0 : ut_params->sec_session = NULL;
11533 : :
11534 : 0 : rte_pktmbuf_free(ut_params->ibuf);
11535 : 0 : ut_params->ibuf = NULL;
11536 : :
11537 : 0 : return ret;
11538 : : }
11539 : :
11540 : : static int
11541 : 0 : test_docsis_proto_downlink(const void *data)
11542 : : {
11543 : : const struct docsis_test_data *d_td = data;
11544 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11545 : : struct crypto_unittest_params *ut_params = &unittest_params;
11546 : : uint8_t *plaintext = NULL;
11547 : : uint8_t *ciphertext = NULL;
11548 : : uint8_t *iv_ptr;
11549 : : int32_t cipher_len, crc_len;
11550 : : int ret = TEST_SUCCESS;
11551 : :
11552 : 0 : void *ctx = rte_cryptodev_get_sec_ctx(ts_params->valid_devs[0]);
11553 : :
11554 : : /* Verify the capabilities */
11555 : : struct rte_security_capability_idx sec_cap_idx;
11556 : : const struct rte_security_capability *sec_cap;
11557 : : const struct rte_cryptodev_capabilities *crypto_cap;
11558 : : const struct rte_cryptodev_symmetric_capability *sym_cap;
11559 : : int j = 0;
11560 : :
11561 : : /* Set action type */
11562 : 0 : ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
11563 [ # # ]: 0 : RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
11564 : : gbl_action_type;
11565 : :
11566 [ # # ]: 0 : if (security_proto_supported(ut_params->type,
11567 : : RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
11568 : : return TEST_SKIPPED;
11569 : :
11570 : 0 : sec_cap_idx.action = ut_params->type;
11571 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
11572 : 0 : sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11573 : :
11574 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11575 [ # # ]: 0 : if (sec_cap == NULL)
11576 : : return TEST_SKIPPED;
11577 : :
11578 [ # # ]: 0 : while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
11579 : : RTE_CRYPTO_OP_TYPE_UNDEFINED) {
11580 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
11581 : : crypto_cap->sym.xform_type ==
11582 [ # # ]: 0 : RTE_CRYPTO_SYM_XFORM_CIPHER &&
11583 : : crypto_cap->sym.cipher.algo ==
11584 : : RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
11585 : 0 : sym_cap = &crypto_cap->sym;
11586 [ # # ]: 0 : if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
11587 : 0 : d_td->key.len,
11588 : 0 : d_td->iv.len) == 0)
11589 : : break;
11590 : : }
11591 : : }
11592 : :
11593 [ # # ]: 0 : if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
11594 : : return TEST_SKIPPED;
11595 : :
11596 : : /* Setup source mbuf payload */
11597 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11598 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11599 : : rte_pktmbuf_tailroom(ut_params->ibuf));
11600 : :
11601 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11602 : 0 : d_td->plaintext.len);
11603 : :
11604 : 0 : memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
11605 : :
11606 : : /* Setup cipher session parameters */
11607 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11608 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
11609 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11610 : 0 : ut_params->cipher_xform.cipher.key.data = d_td->key.data;
11611 : 0 : ut_params->cipher_xform.cipher.key.length = d_td->key.len;
11612 : 0 : ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
11613 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11614 : 0 : ut_params->cipher_xform.next = NULL;
11615 : :
11616 : : /* Setup DOCSIS session parameters */
11617 : 0 : ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
11618 : :
11619 : 0 : struct rte_security_session_conf sess_conf = {
11620 : 0 : .action_type = ut_params->type,
11621 : : .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
11622 : : .docsis = ut_params->docsis_xform,
11623 : : .crypto_xform = &ut_params->cipher_xform,
11624 : : };
11625 : :
11626 : : /* Create security session */
11627 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11628 : : ts_params->session_mpool);
11629 : :
11630 [ # # ]: 0 : if (!ut_params->sec_session) {
11631 : : printf("Test function %s line %u: failed to allocate session\n",
11632 : : __func__, __LINE__);
11633 : : ret = TEST_FAILED;
11634 : 0 : goto on_err;
11635 : : }
11636 : :
11637 : : /* Generate crypto op data structure */
11638 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11639 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11640 [ # # ]: 0 : if (!ut_params->op) {
11641 : : printf("Test function %s line %u: failed to allocate symmetric "
11642 : : "crypto operation\n", __func__, __LINE__);
11643 : : ret = TEST_FAILED;
11644 : 0 : goto on_err;
11645 : : }
11646 : :
11647 : : /* Setup CRC operation parameters */
11648 : 0 : crc_len = d_td->plaintext.no_crc == false ?
11649 : 0 : (d_td->plaintext.len -
11650 : 0 : d_td->plaintext.crc_offset -
11651 [ # # ]: 0 : RTE_ETHER_CRC_LEN) :
11652 : : 0;
11653 : 0 : crc_len = crc_len > 0 ? crc_len : 0;
11654 : 0 : ut_params->op->sym->auth.data.length = crc_len;
11655 : 0 : ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
11656 : :
11657 : : /* Setup cipher operation parameters */
11658 : 0 : cipher_len = d_td->plaintext.no_cipher == false ?
11659 : 0 : (d_td->plaintext.len -
11660 [ # # ]: 0 : d_td->plaintext.cipher_offset) :
11661 : : 0;
11662 : 0 : cipher_len = cipher_len > 0 ? cipher_len : 0;
11663 : 0 : ut_params->op->sym->cipher.data.length = cipher_len;
11664 : 0 : ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
11665 : :
11666 : : /* Setup cipher IV */
11667 : 0 : iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
11668 [ # # ]: 0 : rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
11669 : :
11670 : : /* Attach session to operation */
11671 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
11672 : :
11673 : : /* Set crypto operation mbufs */
11674 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
11675 : 0 : ut_params->op->sym->m_dst = NULL;
11676 : :
11677 : : /* Process crypto operation */
11678 [ # # ]: 0 : if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
11679 : : NULL) {
11680 : : printf("Test function %s line %u: failed to process crypto op\n",
11681 : : __func__, __LINE__);
11682 : : ret = TEST_FAILED;
11683 : 0 : goto on_err;
11684 : : }
11685 : :
11686 [ # # ]: 0 : if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
11687 : : printf("Test function %s line %u: crypto op processing failed\n",
11688 : : __func__, __LINE__);
11689 : : ret = TEST_FAILED;
11690 : 0 : goto on_err;
11691 : : }
11692 : :
11693 : : /* Validate ciphertext */
11694 : : ciphertext = plaintext;
11695 : :
11696 [ # # ]: 0 : if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
11697 : : printf("Test function %s line %u: plaintext not as expected\n",
11698 : : __func__, __LINE__);
11699 : 0 : rte_hexdump(stdout, "expected", d_td->ciphertext.data,
11700 : 0 : d_td->ciphertext.len);
11701 : 0 : rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
11702 : : ret = TEST_FAILED;
11703 : 0 : goto on_err;
11704 : : }
11705 : :
11706 : 0 : on_err:
11707 : 0 : rte_crypto_op_free(ut_params->op);
11708 : 0 : ut_params->op = NULL;
11709 : :
11710 [ # # ]: 0 : if (ut_params->sec_session)
11711 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
11712 : 0 : ut_params->sec_session = NULL;
11713 : :
11714 : 0 : rte_pktmbuf_free(ut_params->ibuf);
11715 : 0 : ut_params->ibuf = NULL;
11716 : :
11717 : 0 : return ret;
11718 : : }
11719 : :
11720 : : static void
11721 : 0 : test_tls_record_imp_nonce_update(const struct tls_record_test_data *td,
11722 : : struct rte_security_tls_record_xform *tls_record_xform)
11723 : : {
11724 : : unsigned int imp_nonce_len;
11725 : : uint8_t *imp_nonce;
11726 : :
11727 [ # # # # ]: 0 : switch (tls_record_xform->ver) {
11728 : 0 : case RTE_SECURITY_VERSION_TLS_1_2:
11729 : : imp_nonce_len = RTE_SECURITY_TLS_1_2_IMP_NONCE_LEN;
11730 : 0 : imp_nonce = tls_record_xform->tls_1_2.imp_nonce;
11731 : 0 : break;
11732 : 0 : case RTE_SECURITY_VERSION_DTLS_1_2:
11733 : : imp_nonce_len = RTE_SECURITY_DTLS_1_2_IMP_NONCE_LEN;
11734 : 0 : imp_nonce = tls_record_xform->dtls_1_2.imp_nonce;
11735 : 0 : break;
11736 : 0 : case RTE_SECURITY_VERSION_TLS_1_3:
11737 : : imp_nonce_len = RTE_SECURITY_TLS_1_3_IMP_NONCE_LEN;
11738 : 0 : imp_nonce = tls_record_xform->tls_1_3.imp_nonce;
11739 : 0 : break;
11740 : : default:
11741 : : return;
11742 : : }
11743 : :
11744 : 0 : imp_nonce_len = RTE_MIN(imp_nonce_len, td[0].imp_nonce.len);
11745 : 0 : memcpy(imp_nonce, td[0].imp_nonce.data, imp_nonce_len);
11746 : : }
11747 : :
11748 : : static int
11749 : 0 : test_tls_record_proto_process(const struct tls_record_test_data td[],
11750 : : struct tls_record_test_data res_d[], int nb_td, bool silent,
11751 : : const struct tls_record_test_flags *flags)
11752 : : {
11753 : 0 : int nb_segs = flags->nb_segs_in_mbuf ? flags->nb_segs_in_mbuf : 1;
11754 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
11755 : : struct crypto_unittest_params *ut_params = &unittest_params;
11756 : : struct rte_security_tls_record_xform tls_record_xform;
11757 : : struct rte_security_capability_idx sec_cap_idx;
11758 : : const struct rte_security_capability *sec_cap;
11759 : : struct tls_record_test_data *res_d_tmp = NULL;
11760 : : enum rte_security_tls_sess_type sess_type;
11761 : 0 : uint8_t dev_id = ts_params->valid_devs[0];
11762 : : struct rte_security_ctx *ctx;
11763 : : int i, ret = TEST_SUCCESS;
11764 : :
11765 : 0 : ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
11766 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
11767 : :
11768 : : /* Use first test data to create session */
11769 : :
11770 : : /* Copy TLS record xform */
11771 : 0 : memcpy(&tls_record_xform, &td[0].tls_record_xform, sizeof(tls_record_xform));
11772 : :
11773 : 0 : sess_type = tls_record_xform.type;
11774 : :
11775 : 0 : ctx = rte_cryptodev_get_sec_ctx(dev_id);
11776 : :
11777 : 0 : sec_cap_idx.action = ut_params->type;
11778 : 0 : sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD;
11779 : 0 : sec_cap_idx.tls_record.type = tls_record_xform.type;
11780 : 0 : sec_cap_idx.tls_record.ver = tls_record_xform.ver;
11781 : :
11782 : 0 : sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
11783 [ # # ]: 0 : if (sec_cap == NULL)
11784 : : return TEST_SKIPPED;
11785 : :
11786 : : /* Copy cipher session parameters */
11787 [ # # ]: 0 : if (td[0].aead) {
11788 : 0 : memcpy(&ut_params->aead_xform, &td[0].xform.aead, sizeof(ut_params->aead_xform));
11789 : 0 : ut_params->aead_xform.aead.key.data = td[0].key.data;
11790 : 0 : ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
11791 : :
11792 : : /* Verify crypto capabilities */
11793 [ # # ]: 0 : if (test_sec_crypto_caps_aead_verify(sec_cap, &ut_params->aead_xform) != 0) {
11794 [ # # ]: 0 : if (!silent)
11795 : 0 : RTE_LOG(INFO, USER1, "Crypto capabilities not supported\n");
11796 : 0 : return TEST_SKIPPED;
11797 : : }
11798 : : } else {
11799 : 0 : memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
11800 : : sizeof(ut_params->cipher_xform));
11801 : 0 : memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
11802 : : sizeof(ut_params->auth_xform));
11803 : 0 : ut_params->cipher_xform.cipher.key.data = td[0].key.data;
11804 : 0 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11805 : 0 : ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
11806 : :
11807 : : /* Verify crypto capabilities */
11808 : :
11809 [ # # ]: 0 : if (test_sec_crypto_caps_cipher_verify(sec_cap, &ut_params->cipher_xform) != 0) {
11810 [ # # ]: 0 : if (!silent)
11811 : 0 : RTE_LOG(INFO, USER1, "Cipher crypto capabilities not supported\n");
11812 : 0 : return TEST_SKIPPED;
11813 : : }
11814 : :
11815 [ # # ]: 0 : if (test_sec_crypto_caps_auth_verify(sec_cap, &ut_params->auth_xform) != 0) {
11816 [ # # ]: 0 : if (!silent)
11817 : 0 : RTE_LOG(INFO, USER1, "Auth crypto capabilities not supported\n");
11818 : 0 : return TEST_SKIPPED;
11819 : : }
11820 : : }
11821 : :
11822 [ # # ]: 0 : if (test_tls_record_sec_caps_verify(&tls_record_xform, sec_cap, silent) != 0)
11823 : : return TEST_SKIPPED;
11824 : :
11825 : 0 : struct rte_security_session_conf sess_conf = {
11826 : 0 : .action_type = ut_params->type,
11827 : : .protocol = RTE_SECURITY_PROTOCOL_TLS_RECORD,
11828 : : };
11829 : :
11830 : : if ((tls_record_xform.ver == RTE_SECURITY_VERSION_DTLS_1_2) &&
11831 : : (sess_type == RTE_SECURITY_TLS_SESS_TYPE_READ))
11832 : : sess_conf.tls_record.dtls_1_2.ar_win_sz = flags->ar_win_size;
11833 : :
11834 [ # # ]: 0 : if (td[0].aead)
11835 : 0 : test_tls_record_imp_nonce_update(&td[0], &tls_record_xform);
11836 : :
11837 [ # # ]: 0 : if (flags->opt_padding)
11838 : 0 : tls_record_xform.options.extra_padding_enable = 1;
11839 : :
11840 : 0 : sess_conf.tls_record = tls_record_xform;
11841 : :
11842 [ # # ]: 0 : if (td[0].aead) {
11843 : 0 : sess_conf.crypto_xform = &ut_params->aead_xform;
11844 : : } else {
11845 [ # # ]: 0 : if (sess_type == RTE_SECURITY_TLS_SESS_TYPE_READ) {
11846 : 0 : sess_conf.crypto_xform = &ut_params->cipher_xform;
11847 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
11848 : : } else {
11849 : 0 : sess_conf.crypto_xform = &ut_params->auth_xform;
11850 : 0 : ut_params->auth_xform.next = &ut_params->cipher_xform;
11851 : : }
11852 : : }
11853 : :
11854 : : /* Create security session */
11855 : 0 : ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
11856 : : ts_params->session_mpool);
11857 [ # # ]: 0 : if (ut_params->sec_session == NULL)
11858 : : return TEST_SKIPPED;
11859 : :
11860 [ # # ]: 0 : for (i = 0; i < nb_td; i++) {
11861 [ # # # # ]: 0 : if (flags->ar_win_size &&
11862 : : (sess_type == RTE_SECURITY_TLS_SESS_TYPE_WRITE)) {
11863 : 0 : sess_conf.tls_record.dtls_1_2.seq_no =
11864 : 0 : td[i].tls_record_xform.dtls_1_2.seq_no;
11865 : 0 : ret = rte_security_session_update(ctx, ut_params->sec_session, &sess_conf);
11866 [ # # ]: 0 : if (ret) {
11867 : : printf("Could not update sequence number in session\n");
11868 : 0 : return TEST_SKIPPED;
11869 : : }
11870 : : }
11871 : :
11872 : : /* Setup source mbuf payload */
11873 : 0 : ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool, td[i].input_text.len,
11874 : : nb_segs, 0);
11875 : 0 : pktmbuf_write(ut_params->ibuf, 0, td[i].input_text.len, td[i].input_text.data);
11876 [ # # ]: 0 : if (flags->out_of_place)
11877 : 0 : ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
11878 : 0 : td[i].output_text.len, nb_segs, 0);
11879 : : else
11880 : 0 : ut_params->obuf = NULL;
11881 : :
11882 : : /* Generate crypto op data structure */
11883 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11884 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11885 [ # # ]: 0 : if (ut_params->op == NULL) {
11886 : : printf("Could not allocate crypto op");
11887 : : ret = TEST_FAILED;
11888 : 0 : goto crypto_op_free;
11889 : : }
11890 : :
11891 : : /* Attach session to operation */
11892 [ # # ]: 0 : rte_security_attach_session(ut_params->op, ut_params->sec_session);
11893 : :
11894 : : /* Set crypto operation mbufs */
11895 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
11896 : 0 : ut_params->op->sym->m_dst = ut_params->obuf;
11897 : 0 : ut_params->op->param1.tls_record.content_type = td[i].app_type;
11898 : :
11899 [ # # ]: 0 : if (flags->opt_padding)
11900 : 0 : ut_params->op->aux_flags = flags->opt_padding;
11901 : :
11902 : : /* Copy IV in crypto operation when IV generation is disabled */
11903 [ # # ]: 0 : if ((sess_type == RTE_SECURITY_TLS_SESS_TYPE_WRITE) &&
11904 [ # # ]: 0 : (tls_record_xform.ver != RTE_SECURITY_VERSION_TLS_1_3) &&
11905 [ # # ]: 0 : (tls_record_xform.options.iv_gen_disable == 1)) {
11906 : : uint8_t *iv;
11907 : : int len;
11908 : :
11909 : 0 : iv = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET);
11910 [ # # ]: 0 : if (td[i].aead)
11911 : 0 : len = td[i].xform.aead.aead.iv.length - 4;
11912 : : else
11913 : 0 : len = td[i].xform.chain.cipher.cipher.iv.length;
11914 : 0 : memcpy(iv, td[i].iv.data, len);
11915 : : }
11916 : :
11917 : : /* Process crypto operation */
11918 : 0 : process_crypto_request(dev_id, ut_params->op);
11919 : :
11920 : 0 : ret = test_tls_record_status_check(ut_params->op, &td[i]);
11921 [ # # ]: 0 : if (ret != TEST_SUCCESS)
11922 : 0 : goto crypto_op_free;
11923 : :
11924 [ # # ]: 0 : if (res_d != NULL)
11925 : 0 : res_d_tmp = &res_d[i];
11926 : :
11927 [ # # ]: 0 : if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS) {
11928 [ # # ]: 0 : struct rte_mbuf *buf = flags->out_of_place ? ut_params->obuf :
11929 : : ut_params->ibuf;
11930 : :
11931 : 0 : ret = test_tls_record_post_process(buf, &td[i], res_d_tmp,
11932 : : silent, flags);
11933 [ # # ]: 0 : if (ret != TEST_SUCCESS)
11934 : 0 : goto crypto_op_free;
11935 : : }
11936 : :
11937 : 0 : rte_crypto_op_free(ut_params->op);
11938 : 0 : ut_params->op = NULL;
11939 : :
11940 [ # # ]: 0 : if (flags->out_of_place) {
11941 : 0 : rte_pktmbuf_free(ut_params->obuf);
11942 : 0 : ut_params->obuf = NULL;
11943 : : }
11944 : :
11945 : 0 : rte_pktmbuf_free(ut_params->ibuf);
11946 : 0 : ut_params->ibuf = NULL;
11947 : : }
11948 : :
11949 : 0 : crypto_op_free:
11950 : 0 : rte_crypto_op_free(ut_params->op);
11951 : 0 : ut_params->op = NULL;
11952 : :
11953 [ # # ]: 0 : if (flags->out_of_place) {
11954 : 0 : rte_pktmbuf_free(ut_params->obuf);
11955 : 0 : ut_params->obuf = NULL;
11956 : : }
11957 : :
11958 : 0 : rte_pktmbuf_free(ut_params->ibuf);
11959 : 0 : ut_params->ibuf = NULL;
11960 : :
11961 [ # # ]: 0 : if (ut_params->sec_session)
11962 : 0 : rte_security_session_destroy(ctx, ut_params->sec_session);
11963 : 0 : ut_params->sec_session = NULL;
11964 : :
11965 : : RTE_SET_USED(flags);
11966 : :
11967 : 0 : return ret;
11968 : : }
11969 : :
11970 : : static int
11971 : 0 : test_tls_record_proto_known_vec(const void *test_data)
11972 : : {
11973 : : struct tls_record_test_data td_write;
11974 : : struct tls_record_test_flags flags;
11975 : :
11976 : : memset(&flags, 0, sizeof(flags));
11977 : :
11978 : : memcpy(&td_write, test_data, sizeof(td_write));
11979 : :
11980 : : /* Disable IV gen to be able to test with known vectors */
11981 : 0 : td_write.tls_record_xform.options.iv_gen_disable = 1;
11982 : :
11983 : 0 : return test_tls_record_proto_process(&td_write, NULL, 1, false, &flags);
11984 : : }
11985 : :
11986 : : static int
11987 [ # # ]: 0 : test_tls_record_proto_known_vec_read(const void *test_data)
11988 : : {
11989 : : const struct tls_record_test_data *td = test_data;
11990 : : struct tls_record_test_flags flags;
11991 : : struct tls_record_test_data td_inb;
11992 : :
11993 : : memset(&flags, 0, sizeof(flags));
11994 : :
11995 [ # # ]: 0 : if (td->tls_record_xform.type == RTE_SECURITY_TLS_SESS_TYPE_WRITE)
11996 : 0 : test_tls_record_td_read_from_write(td, &td_inb);
11997 : : else
11998 : : memcpy(&td_inb, td, sizeof(td_inb));
11999 : :
12000 : 0 : return test_tls_record_proto_process(&td_inb, NULL, 1, false, &flags);
12001 : : }
12002 : :
12003 : : static int
12004 : 0 : test_tls_record_proto_all(const struct tls_record_test_flags *flags)
12005 : : {
12006 : : unsigned int i, nb_pkts = 1, pass_cnt = 0, payload_len, max_payload_len;
12007 : : struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
12008 : : struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
12009 : : int ret;
12010 : :
12011 [ # # ]: 0 : switch (flags->tls_version) {
12012 : : case RTE_SECURITY_VERSION_TLS_1_2:
12013 : : max_payload_len = TLS_1_2_RECORD_PLAINTEXT_MAX_LEN;
12014 : : break;
12015 : : case RTE_SECURITY_VERSION_TLS_1_3:
12016 : : max_payload_len = TLS_1_3_RECORD_PLAINTEXT_MAX_LEN;
12017 : : break;
12018 : : case RTE_SECURITY_VERSION_DTLS_1_2:
12019 : : max_payload_len = DTLS_1_2_RECORD_PLAINTEXT_MAX_LEN;
12020 : : break;
12021 : 0 : default:
12022 : : max_payload_len = 0;
12023 : : }
12024 : :
12025 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
12026 : : payload_len = TLS_RECORD_PLAINTEXT_MIN_LEN;
12027 [ # # ]: 0 : if (flags->nb_segs_in_mbuf)
12028 : 0 : payload_len = RTE_MAX(payload_len, flags->nb_segs_in_mbuf);
12029 : :
12030 [ # # ]: 0 : if (flags->zero_len)
12031 : : payload_len = 0;
12032 : 0 : again:
12033 : 0 : ret = test_tls_record_td_prepare(sec_alg_list[i].param1, sec_alg_list[i].param2,
12034 : : flags, td_outb, nb_pkts, payload_len);
12035 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12036 : 0 : continue;
12037 : :
12038 : 0 : ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, true, flags);
12039 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12040 : 0 : continue;
12041 : :
12042 [ # # ]: 0 : if (flags->zero_len &&
12043 [ # # ]: 0 : ((flags->content_type == TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE) ||
12044 : : (flags->content_type == TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE) ||
12045 : : (flags->content_type == TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE))) {
12046 [ # # ]: 0 : if (ret == TEST_SUCCESS)
12047 : : return TEST_FAILED;
12048 : 0 : goto skip_decrypt;
12049 [ # # ]: 0 : } else if (ret == TEST_FAILED) {
12050 : : return TEST_FAILED;
12051 : : }
12052 : :
12053 : 0 : test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
12054 : :
12055 : 0 : ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, true, flags);
12056 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12057 : 0 : continue;
12058 : :
12059 [ # # ]: 0 : if (flags->pkt_corruption) {
12060 [ # # ]: 0 : if (ret == TEST_SUCCESS)
12061 : : return TEST_FAILED;
12062 : : } else {
12063 [ # # ]: 0 : if (ret == TEST_FAILED)
12064 : : return TEST_FAILED;
12065 : : }
12066 : :
12067 : 0 : skip_decrypt:
12068 [ # # # # ]: 0 : if (flags->data_walkthrough && (++payload_len <= max_payload_len))
12069 : 0 : goto again;
12070 : :
12071 [ # # ]: 0 : if (flags->display_alg)
12072 : 0 : test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
12073 : :
12074 : 0 : pass_cnt++;
12075 : : }
12076 : :
12077 [ # # ]: 0 : if (pass_cnt > 0)
12078 : : return TEST_SUCCESS;
12079 : : else
12080 : 0 : return TEST_SKIPPED;
12081 : : }
12082 : :
12083 : : static int
12084 : 0 : test_tls_1_2_record_proto_data_walkthrough(void)
12085 : : {
12086 : : struct tls_record_test_flags flags;
12087 : :
12088 : : memset(&flags, 0, sizeof(flags));
12089 : :
12090 : 0 : flags.data_walkthrough = true;
12091 : : flags.tls_version = RTE_SECURITY_VERSION_TLS_1_2;
12092 : :
12093 : 0 : return test_tls_record_proto_all(&flags);
12094 : : }
12095 : :
12096 : : static int
12097 : 0 : test_tls_1_2_record_proto_display_list(void)
12098 : : {
12099 : : struct tls_record_test_flags flags;
12100 : :
12101 : : memset(&flags, 0, sizeof(flags));
12102 : :
12103 : 0 : flags.display_alg = true;
12104 : : flags.tls_version = RTE_SECURITY_VERSION_TLS_1_2;
12105 : :
12106 : 0 : return test_tls_record_proto_all(&flags);
12107 : : }
12108 : :
12109 : : static int
12110 : 0 : test_tls_1_2_record_proto_sgl(void)
12111 : : {
12112 : 0 : struct tls_record_test_flags flags = {
12113 : : .nb_segs_in_mbuf = 5,
12114 : : .tls_version = RTE_SECURITY_VERSION_TLS_1_2
12115 : : };
12116 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12117 : : struct rte_cryptodev_info dev_info;
12118 : :
12119 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12120 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12121 : : printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12122 : 0 : return TEST_SKIPPED;
12123 : : }
12124 : :
12125 : 0 : return test_tls_record_proto_all(&flags);
12126 : : }
12127 : :
12128 : : static int
12129 : 0 : test_tls_record_proto_sgl_data_walkthrough(enum rte_security_tls_version tls_version)
12130 : : {
12131 : 0 : struct tls_record_test_flags flags = {
12132 : : .nb_segs_in_mbuf = 5,
12133 : : .tls_version = tls_version,
12134 : : .data_walkthrough = true
12135 : : };
12136 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12137 : : struct rte_cryptodev_info dev_info;
12138 : :
12139 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12140 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12141 : : printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12142 : 0 : return TEST_SKIPPED;
12143 : : }
12144 : :
12145 : 0 : return test_tls_record_proto_all(&flags);
12146 : : }
12147 : :
12148 : : static int
12149 : 0 : test_tls_record_proto_sgl_oop(enum rte_security_tls_version tls_version)
12150 : : {
12151 : 0 : struct tls_record_test_flags flags = {
12152 : : .nb_segs_in_mbuf = 5,
12153 : : .out_of_place = true,
12154 : : .tls_version = tls_version
12155 : : };
12156 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12157 : : struct rte_cryptodev_info dev_info;
12158 : :
12159 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12160 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12161 : : printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12162 : 0 : return TEST_SKIPPED;
12163 : : }
12164 : :
12165 : 0 : return test_tls_record_proto_all(&flags);
12166 : : }
12167 : :
12168 : : static int
12169 : 0 : test_tls_1_2_record_proto_sgl_oop(void)
12170 : : {
12171 : 0 : return test_tls_record_proto_sgl_oop(RTE_SECURITY_VERSION_TLS_1_2);
12172 : : }
12173 : :
12174 : : static int
12175 : 0 : test_tls_1_2_record_proto_sgl_data_walkthrough(void)
12176 : : {
12177 : 0 : return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_TLS_1_2);
12178 : : }
12179 : :
12180 : : static int
12181 : 0 : test_tls_record_proto_corrupt_pkt(void)
12182 : : {
12183 : 0 : struct tls_record_test_flags flags = {
12184 : : .pkt_corruption = 1
12185 : : };
12186 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12187 : : struct rte_cryptodev_info dev_info;
12188 : :
12189 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12190 : :
12191 : 0 : return test_tls_record_proto_all(&flags);
12192 : : }
12193 : :
12194 : : static int
12195 : 0 : test_tls_record_proto_custom_content_type(void)
12196 : : {
12197 : 0 : struct tls_record_test_flags flags = {
12198 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM
12199 : : };
12200 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12201 : : struct rte_cryptodev_info dev_info;
12202 : :
12203 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12204 : :
12205 : 0 : return test_tls_record_proto_all(&flags);
12206 : : }
12207 : :
12208 : : static int
12209 : 0 : test_tls_record_proto_zero_len(void)
12210 : : {
12211 : 0 : struct tls_record_test_flags flags = {
12212 : : .zero_len = 1
12213 : : };
12214 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12215 : : struct rte_cryptodev_info dev_info;
12216 : :
12217 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12218 : :
12219 : 0 : return test_tls_record_proto_all(&flags);
12220 : : }
12221 : :
12222 : : static int
12223 : 0 : test_tls_record_proto_zero_len_non_app(void)
12224 : : {
12225 : 0 : struct tls_record_test_flags flags = {
12226 : : .zero_len = 1,
12227 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12228 : : };
12229 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12230 : : struct rte_cryptodev_info dev_info;
12231 : :
12232 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12233 : :
12234 : 0 : return test_tls_record_proto_all(&flags);
12235 : : }
12236 : :
12237 : : static int
12238 : 0 : test_tls_record_proto_opt_padding(uint8_t padding, uint8_t num_segs,
12239 : : enum rte_security_tls_version tls_version)
12240 : : {
12241 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12242 : : struct rte_cryptodev_info dev_info;
12243 : 0 : struct tls_record_test_flags flags = {
12244 : : .nb_segs_in_mbuf = num_segs,
12245 : : .tls_version = tls_version,
12246 : : .opt_padding = padding
12247 : : };
12248 : :
12249 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12250 : :
12251 : 0 : return test_tls_record_proto_all(&flags);
12252 : : }
12253 : :
12254 : : static int
12255 : 0 : test_tls_record_proto_dm_opt_padding(void)
12256 : : {
12257 : 0 : return test_tls_record_proto_opt_padding(1, 0, RTE_SECURITY_VERSION_TLS_1_2);
12258 : : }
12259 : :
12260 : : static int
12261 : 0 : test_tls_record_proto_dm_opt_padding_1(void)
12262 : : {
12263 : 0 : return test_tls_record_proto_opt_padding(25, 0, RTE_SECURITY_VERSION_TLS_1_2);
12264 : : }
12265 : :
12266 : : static int
12267 : 0 : test_tls_record_proto_sg_opt_padding(void)
12268 : : {
12269 : 0 : return test_tls_record_proto_opt_padding(1, 2, RTE_SECURITY_VERSION_TLS_1_2);
12270 : : }
12271 : :
12272 : : static int
12273 : 0 : test_tls_record_proto_sg_opt_padding_1(void)
12274 : : {
12275 : 0 : return test_tls_record_proto_opt_padding(8, 4, RTE_SECURITY_VERSION_TLS_1_2);
12276 : : }
12277 : :
12278 : : static int
12279 : 0 : test_tls_record_proto_sg_opt_padding_2(void)
12280 : : {
12281 : 0 : return test_tls_record_proto_opt_padding(8, 5, RTE_SECURITY_VERSION_TLS_1_2);
12282 : : }
12283 : :
12284 : : static int
12285 : 0 : test_tls_record_proto_sg_opt_padding_max(void)
12286 : : {
12287 : 0 : return test_tls_record_proto_opt_padding(33, 4, RTE_SECURITY_VERSION_TLS_1_2);
12288 : : }
12289 : :
12290 : : static int
12291 : 0 : test_dtls_1_2_record_proto_data_walkthrough(void)
12292 : : {
12293 : : struct tls_record_test_flags flags;
12294 : :
12295 : : memset(&flags, 0, sizeof(flags));
12296 : :
12297 : 0 : flags.data_walkthrough = true;
12298 : 0 : flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12299 : :
12300 : 0 : return test_tls_record_proto_all(&flags);
12301 : : }
12302 : :
12303 : : static int
12304 : 0 : test_dtls_1_2_record_proto_display_list(void)
12305 : : {
12306 : : struct tls_record_test_flags flags;
12307 : :
12308 : : memset(&flags, 0, sizeof(flags));
12309 : :
12310 : 0 : flags.display_alg = true;
12311 : 0 : flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12312 : :
12313 : 0 : return test_tls_record_proto_all(&flags);
12314 : : }
12315 : :
12316 : : static int
12317 : 0 : test_dtls_pkt_replay(const uint64_t seq_no[],
12318 : : bool replayed_pkt[], uint32_t nb_pkts,
12319 : : struct tls_record_test_flags *flags)
12320 : : {
12321 : : struct tls_record_test_data td_outb[TEST_SEC_PKTS_MAX];
12322 : : struct tls_record_test_data td_inb[TEST_SEC_PKTS_MAX];
12323 : : unsigned int i, idx, pass_cnt = 0;
12324 : : int ret;
12325 : :
12326 [ # # ]: 0 : for (i = 0; i < RTE_DIM(sec_alg_list); i++) {
12327 : 0 : ret = test_tls_record_td_prepare(sec_alg_list[i].param1, sec_alg_list[i].param2,
12328 : : flags, td_outb, nb_pkts, 0);
12329 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12330 : 0 : continue;
12331 : :
12332 [ # # ]: 0 : for (idx = 0; idx < nb_pkts; idx++)
12333 : 0 : td_outb[idx].tls_record_xform.dtls_1_2.seq_no = seq_no[idx];
12334 : :
12335 : 0 : ret = test_tls_record_proto_process(td_outb, td_inb, nb_pkts, true, flags);
12336 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12337 : 0 : continue;
12338 : :
12339 [ # # ]: 0 : if (ret == TEST_FAILED)
12340 : : return TEST_FAILED;
12341 : :
12342 : 0 : test_tls_record_td_update(td_inb, td_outb, nb_pkts, flags);
12343 : :
12344 [ # # ]: 0 : for (idx = 0; idx < nb_pkts; idx++) {
12345 : 0 : td_inb[idx].tls_record_xform.dtls_1_2.ar_win_sz = flags->ar_win_size;
12346 : : /* Set antireplay flag for packets to be dropped */
12347 : 0 : td_inb[idx].ar_packet = replayed_pkt[idx];
12348 : : }
12349 : :
12350 : 0 : ret = test_tls_record_proto_process(td_inb, NULL, nb_pkts, true, flags);
12351 [ # # ]: 0 : if (ret == TEST_SKIPPED)
12352 : 0 : continue;
12353 : :
12354 [ # # ]: 0 : if (ret == TEST_FAILED)
12355 : : return TEST_FAILED;
12356 : :
12357 [ # # ]: 0 : if (flags->display_alg)
12358 : 0 : test_sec_alg_display(sec_alg_list[i].param1, sec_alg_list[i].param2);
12359 : :
12360 : 0 : pass_cnt++;
12361 : : }
12362 : :
12363 [ # # ]: 0 : if (pass_cnt > 0)
12364 : : return TEST_SUCCESS;
12365 : : else
12366 : 0 : return TEST_SKIPPED;
12367 : : }
12368 : :
12369 : : static int
12370 : 0 : test_dtls_1_2_record_proto_antireplay(uint64_t winsz)
12371 : : {
12372 : : struct tls_record_test_flags flags;
12373 : : uint32_t nb_pkts = 5;
12374 : : bool replayed_pkt[5];
12375 : : uint64_t seq_no[5];
12376 : :
12377 : : memset(&flags, 0, sizeof(flags));
12378 : :
12379 : 0 : flags.tls_version = RTE_SECURITY_VERSION_DTLS_1_2;
12380 : 0 : flags.ar_win_size = winsz;
12381 : :
12382 : : /* 1. Advance the TOP of the window to WS * 2 */
12383 : 0 : seq_no[0] = winsz * 2;
12384 : : /* 2. Test sequence number within the new window(WS + 1) */
12385 : 0 : seq_no[1] = winsz + 1;
12386 : : /* 3. Test sequence number less than the window BOTTOM */
12387 : 0 : seq_no[2] = winsz;
12388 : : /* 4. Test sequence number in the middle of the window */
12389 : 0 : seq_no[3] = winsz + (winsz / 2);
12390 : : /* 5. Test replay of the packet in the middle of the window */
12391 : 0 : seq_no[4] = winsz + (winsz / 2);
12392 : :
12393 : 0 : replayed_pkt[0] = false;
12394 : 0 : replayed_pkt[1] = false;
12395 : 0 : replayed_pkt[2] = true;
12396 : 0 : replayed_pkt[3] = false;
12397 : 0 : replayed_pkt[4] = true;
12398 : :
12399 : 0 : return test_dtls_pkt_replay(seq_no, replayed_pkt, nb_pkts, &flags);
12400 : : }
12401 : :
12402 : : static int
12403 : 0 : test_dtls_1_2_record_proto_antireplay64(void)
12404 : : {
12405 : 0 : return test_dtls_1_2_record_proto_antireplay(64);
12406 : : }
12407 : :
12408 : : static int
12409 : 0 : test_dtls_1_2_record_proto_antireplay128(void)
12410 : : {
12411 : 0 : return test_dtls_1_2_record_proto_antireplay(128);
12412 : : }
12413 : :
12414 : : static int
12415 : 0 : test_dtls_1_2_record_proto_antireplay256(void)
12416 : : {
12417 : 0 : return test_dtls_1_2_record_proto_antireplay(256);
12418 : : }
12419 : :
12420 : : static int
12421 : 0 : test_dtls_1_2_record_proto_antireplay512(void)
12422 : : {
12423 : 0 : return test_dtls_1_2_record_proto_antireplay(512);
12424 : : }
12425 : :
12426 : : static int
12427 : 0 : test_dtls_1_2_record_proto_antireplay1024(void)
12428 : : {
12429 : 0 : return test_dtls_1_2_record_proto_antireplay(1024);
12430 : : }
12431 : :
12432 : : static int
12433 : 0 : test_dtls_1_2_record_proto_antireplay2048(void)
12434 : : {
12435 : 0 : return test_dtls_1_2_record_proto_antireplay(2048);
12436 : : }
12437 : :
12438 : : static int
12439 : 0 : test_dtls_1_2_record_proto_antireplay4096(void)
12440 : : {
12441 : 0 : return test_dtls_1_2_record_proto_antireplay(4096);
12442 : : }
12443 : :
12444 : : static int
12445 : 0 : test_dtls_1_2_record_proto_sgl(void)
12446 : : {
12447 : 0 : struct tls_record_test_flags flags = {
12448 : : .nb_segs_in_mbuf = 5,
12449 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12450 : : };
12451 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12452 : : struct rte_cryptodev_info dev_info;
12453 : :
12454 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12455 [ # # ]: 0 : if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
12456 : : printf("Device doesn't support in-place scatter-gather. Test Skipped.\n");
12457 : 0 : return TEST_SKIPPED;
12458 : : }
12459 : :
12460 : 0 : return test_tls_record_proto_all(&flags);
12461 : : }
12462 : :
12463 : : static int
12464 : 0 : test_dtls_1_2_record_proto_sgl_data_walkthrough(void)
12465 : : {
12466 : 0 : return test_tls_record_proto_sgl_data_walkthrough(RTE_SECURITY_VERSION_DTLS_1_2);
12467 : : }
12468 : :
12469 : : static int
12470 : 0 : test_dtls_1_2_record_proto_corrupt_pkt(void)
12471 : : {
12472 : 0 : struct tls_record_test_flags flags = {
12473 : : .pkt_corruption = 1,
12474 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12475 : : };
12476 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12477 : : struct rte_cryptodev_info dev_info;
12478 : :
12479 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12480 : :
12481 : 0 : return test_tls_record_proto_all(&flags);
12482 : : }
12483 : :
12484 : : static int
12485 : 0 : test_dtls_1_2_record_proto_custom_content_type(void)
12486 : : {
12487 : 0 : struct tls_record_test_flags flags = {
12488 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM,
12489 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12490 : : };
12491 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12492 : : struct rte_cryptodev_info dev_info;
12493 : :
12494 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12495 : :
12496 : 0 : return test_tls_record_proto_all(&flags);
12497 : : }
12498 : :
12499 : : static int
12500 : 0 : test_dtls_1_2_record_proto_zero_len(void)
12501 : : {
12502 : 0 : struct tls_record_test_flags flags = {
12503 : : .zero_len = 1,
12504 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12505 : : };
12506 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12507 : : struct rte_cryptodev_info dev_info;
12508 : :
12509 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12510 : :
12511 : 0 : return test_tls_record_proto_all(&flags);
12512 : : }
12513 : :
12514 : : static int
12515 : 0 : test_dtls_1_2_record_proto_zero_len_non_app(void)
12516 : : {
12517 : 0 : struct tls_record_test_flags flags = {
12518 : : .zero_len = 1,
12519 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12520 : : .tls_version = RTE_SECURITY_VERSION_DTLS_1_2
12521 : : };
12522 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12523 : : struct rte_cryptodev_info dev_info;
12524 : :
12525 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12526 : :
12527 : 0 : return test_tls_record_proto_all(&flags);
12528 : : }
12529 : :
12530 : : static int
12531 : 0 : test_dtls_1_2_record_proto_dm_opt_padding(void)
12532 : : {
12533 : 0 : return test_tls_record_proto_opt_padding(1, 0, RTE_SECURITY_VERSION_DTLS_1_2);
12534 : : }
12535 : :
12536 : : static int
12537 : 0 : test_dtls_1_2_record_proto_dm_opt_padding_1(void)
12538 : : {
12539 : 0 : return test_tls_record_proto_opt_padding(25, 0, RTE_SECURITY_VERSION_DTLS_1_2);
12540 : : }
12541 : :
12542 : : static int
12543 : 0 : test_dtls_1_2_record_proto_sg_opt_padding(void)
12544 : : {
12545 : 0 : return test_tls_record_proto_opt_padding(1, 5, RTE_SECURITY_VERSION_DTLS_1_2);
12546 : : }
12547 : :
12548 : : static int
12549 : 0 : test_dtls_1_2_record_proto_sg_opt_padding_1(void)
12550 : : {
12551 : 0 : return test_tls_record_proto_opt_padding(8, 4, RTE_SECURITY_VERSION_DTLS_1_2);
12552 : : }
12553 : :
12554 : : static int
12555 : 0 : test_dtls_1_2_record_proto_sg_opt_padding_2(void)
12556 : : {
12557 : 0 : return test_tls_record_proto_opt_padding(8, 5, RTE_SECURITY_VERSION_DTLS_1_2);
12558 : : }
12559 : :
12560 : : static int
12561 : 0 : test_dtls_1_2_record_proto_sg_opt_padding_max(void)
12562 : : {
12563 : 0 : return test_tls_record_proto_opt_padding(33, 4, RTE_SECURITY_VERSION_DTLS_1_2);
12564 : : }
12565 : :
12566 : : static int
12567 : 0 : test_tls_1_3_record_proto_corrupt_pkt(void)
12568 : : {
12569 : 0 : struct tls_record_test_flags flags = {
12570 : : .pkt_corruption = 1,
12571 : : .tls_version = RTE_SECURITY_VERSION_TLS_1_3
12572 : : };
12573 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12574 : : struct rte_cryptodev_info dev_info;
12575 : :
12576 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12577 : :
12578 : 0 : return test_tls_record_proto_all(&flags);
12579 : : }
12580 : :
12581 : : static int
12582 : 0 : test_tls_1_3_record_proto_custom_content_type(void)
12583 : : {
12584 : 0 : struct tls_record_test_flags flags = {
12585 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_CUSTOM,
12586 : : .tls_version = RTE_SECURITY_VERSION_TLS_1_3
12587 : : };
12588 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12589 : : struct rte_cryptodev_info dev_info;
12590 : :
12591 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12592 : :
12593 : 0 : return test_tls_record_proto_all(&flags);
12594 : : }
12595 : :
12596 : : static int
12597 : 0 : test_tls_1_3_record_proto_zero_len(void)
12598 : : {
12599 : 0 : struct tls_record_test_flags flags = {
12600 : : .zero_len = 1,
12601 : : .tls_version = RTE_SECURITY_VERSION_TLS_1_3
12602 : : };
12603 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12604 : : struct rte_cryptodev_info dev_info;
12605 : :
12606 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12607 : :
12608 : 0 : return test_tls_record_proto_all(&flags);
12609 : : }
12610 : :
12611 : : static int
12612 : 0 : test_tls_1_3_record_proto_zero_len_non_app(void)
12613 : : {
12614 : 0 : struct tls_record_test_flags flags = {
12615 : : .zero_len = 1,
12616 : : .content_type = TLS_RECORD_TEST_CONTENT_TYPE_HANDSHAKE,
12617 : : .tls_version = RTE_SECURITY_VERSION_TLS_1_3
12618 : : };
12619 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12620 : : struct rte_cryptodev_info dev_info;
12621 : :
12622 : 0 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12623 : :
12624 : 0 : return test_tls_record_proto_all(&flags);
12625 : : }
12626 : : #endif
12627 : :
12628 : : static int
12629 : 1 : test_AES_GCM_authenticated_encryption_test_case_1(void)
12630 : : {
12631 : 1 : return test_authenticated_encryption(&gcm_test_case_1);
12632 : : }
12633 : :
12634 : : static int
12635 : 1 : test_AES_GCM_authenticated_encryption_test_case_2(void)
12636 : : {
12637 : 1 : return test_authenticated_encryption(&gcm_test_case_2);
12638 : : }
12639 : :
12640 : : static int
12641 : 1 : test_AES_GCM_authenticated_encryption_test_case_3(void)
12642 : : {
12643 : 1 : return test_authenticated_encryption(&gcm_test_case_3);
12644 : : }
12645 : :
12646 : : static int
12647 : 1 : test_AES_GCM_authenticated_encryption_test_case_3_ext_mbuf(void)
12648 : : {
12649 : 1 : return test_authenticated_encryption_helper(&gcm_test_case_3, true);
12650 : : }
12651 : :
12652 : : static int
12653 : 1 : test_AES_GCM_authenticated_encryption_test_case_4(void)
12654 : : {
12655 : 1 : return test_authenticated_encryption(&gcm_test_case_4);
12656 : : }
12657 : :
12658 : : static int
12659 : 1 : test_AES_GCM_authenticated_encryption_test_case_5(void)
12660 : : {
12661 : 1 : return test_authenticated_encryption(&gcm_test_case_5);
12662 : : }
12663 : :
12664 : : static int
12665 : 1 : test_AES_GCM_authenticated_encryption_test_case_6(void)
12666 : : {
12667 : 1 : return test_authenticated_encryption(&gcm_test_case_6);
12668 : : }
12669 : :
12670 : : static int
12671 : 1 : test_AES_GCM_authenticated_encryption_test_case_7(void)
12672 : : {
12673 : 1 : return test_authenticated_encryption(&gcm_test_case_7);
12674 : : }
12675 : :
12676 : : static int
12677 : 1 : test_AES_GCM_authenticated_encryption_test_case_8(void)
12678 : : {
12679 : 1 : return test_authenticated_encryption(&gcm_test_case_8);
12680 : : }
12681 : :
12682 : : static int
12683 : 1 : test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
12684 : : {
12685 : 1 : return test_authenticated_encryption(&gcm_J0_test_case_1);
12686 : : }
12687 : :
12688 : : static int
12689 : 1 : test_AES_GCM_auth_encryption_test_case_192_1(void)
12690 : : {
12691 : 1 : return test_authenticated_encryption(&gcm_test_case_192_1);
12692 : : }
12693 : :
12694 : : static int
12695 : 1 : test_AES_GCM_auth_encryption_test_case_192_2(void)
12696 : : {
12697 : 1 : return test_authenticated_encryption(&gcm_test_case_192_2);
12698 : : }
12699 : :
12700 : : static int
12701 : 1 : test_AES_GCM_auth_encryption_test_case_192_3(void)
12702 : : {
12703 : 1 : return test_authenticated_encryption(&gcm_test_case_192_3);
12704 : : }
12705 : :
12706 : : static int
12707 : 1 : test_AES_GCM_auth_encryption_test_case_192_4(void)
12708 : : {
12709 : 1 : return test_authenticated_encryption(&gcm_test_case_192_4);
12710 : : }
12711 : :
12712 : : static int
12713 : 1 : test_AES_GCM_auth_encryption_test_case_192_5(void)
12714 : : {
12715 : 1 : return test_authenticated_encryption(&gcm_test_case_192_5);
12716 : : }
12717 : :
12718 : : static int
12719 : 1 : test_AES_GCM_auth_encryption_test_case_192_6(void)
12720 : : {
12721 : 1 : return test_authenticated_encryption(&gcm_test_case_192_6);
12722 : : }
12723 : :
12724 : : static int
12725 : 1 : test_AES_GCM_auth_encryption_test_case_192_7(void)
12726 : : {
12727 : 1 : return test_authenticated_encryption(&gcm_test_case_192_7);
12728 : : }
12729 : :
12730 : : static int
12731 : 1 : test_AES_GCM_auth_encryption_test_case_256_1(void)
12732 : : {
12733 : 1 : return test_authenticated_encryption(&gcm_test_case_256_1);
12734 : : }
12735 : :
12736 : : static int
12737 : 1 : test_AES_GCM_auth_encryption_test_case_256_2(void)
12738 : : {
12739 : 1 : return test_authenticated_encryption(&gcm_test_case_256_2);
12740 : : }
12741 : :
12742 : : static int
12743 : 1 : test_AES_GCM_auth_encryption_test_case_256_3(void)
12744 : : {
12745 : 1 : return test_authenticated_encryption(&gcm_test_case_256_3);
12746 : : }
12747 : :
12748 : : static int
12749 : 1 : test_AES_GCM_auth_encryption_test_case_256_4(void)
12750 : : {
12751 : 1 : return test_authenticated_encryption(&gcm_test_case_256_4);
12752 : : }
12753 : :
12754 : : static int
12755 : 1 : test_AES_GCM_auth_encryption_test_case_256_5(void)
12756 : : {
12757 : 1 : return test_authenticated_encryption(&gcm_test_case_256_5);
12758 : : }
12759 : :
12760 : : static int
12761 : 1 : test_AES_GCM_auth_encryption_test_case_256_6(void)
12762 : : {
12763 : 1 : return test_authenticated_encryption(&gcm_test_case_256_6);
12764 : : }
12765 : :
12766 : : static int
12767 : 1 : test_AES_GCM_auth_encryption_test_case_256_7(void)
12768 : : {
12769 : 1 : return test_authenticated_encryption(&gcm_test_case_256_7);
12770 : : }
12771 : :
12772 : : static int
12773 : 1 : test_AES_GCM_auth_encryption_test_case_aad_1(void)
12774 : : {
12775 : 1 : return test_authenticated_encryption(&gcm_test_case_aad_1);
12776 : : }
12777 : :
12778 : : static int
12779 : 1 : test_AES_GCM_auth_encryption_test_case_aad_2(void)
12780 : : {
12781 : 1 : return test_authenticated_encryption(&gcm_test_case_aad_2);
12782 : : }
12783 : :
12784 : : static int
12785 : 1 : test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
12786 : : {
12787 : : struct aead_test_data tdata;
12788 : : int res;
12789 : :
12790 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12791 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12792 : 1 : tdata.iv.data[0] += 1;
12793 : : res = test_authenticated_encryption(&tdata);
12794 [ + - ]: 1 : if (res == TEST_SKIPPED)
12795 : : return res;
12796 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12797 : : return TEST_SUCCESS;
12798 : : }
12799 : :
12800 : : static int
12801 : 1 : test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
12802 : : {
12803 : : struct aead_test_data tdata;
12804 : : int res;
12805 : :
12806 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12807 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12808 : 1 : tdata.plaintext.data[0] += 1;
12809 : : res = test_authenticated_encryption(&tdata);
12810 [ + - ]: 1 : if (res == TEST_SKIPPED)
12811 : : return res;
12812 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12813 : : return TEST_SUCCESS;
12814 : : }
12815 : :
12816 : : static int
12817 : 1 : test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
12818 : : {
12819 : : struct aead_test_data tdata;
12820 : : int res;
12821 : :
12822 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12823 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12824 : 1 : tdata.ciphertext.data[0] += 1;
12825 : : res = test_authenticated_encryption(&tdata);
12826 [ + - ]: 1 : if (res == TEST_SKIPPED)
12827 : : return res;
12828 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12829 : : return TEST_SUCCESS;
12830 : : }
12831 : :
12832 : : static int
12833 : 1 : test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
12834 : : {
12835 : : struct aead_test_data tdata;
12836 : : int res;
12837 : :
12838 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12839 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12840 : 1 : tdata.aad.len += 1;
12841 : : res = test_authenticated_encryption(&tdata);
12842 [ + - ]: 1 : if (res == TEST_SKIPPED)
12843 : : return res;
12844 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12845 : : return TEST_SUCCESS;
12846 : : }
12847 : :
12848 : : static int
12849 : 1 : test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
12850 : 1 : {
12851 : : struct aead_test_data tdata;
12852 : : uint8_t aad[gcm_test_case_7.aad.len];
12853 : : int res;
12854 : :
12855 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12856 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12857 : : memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
12858 : 1 : aad[0] += 1;
12859 : 1 : tdata.aad.data = aad;
12860 : : res = test_authenticated_encryption(&tdata);
12861 [ + - ]: 1 : if (res == TEST_SKIPPED)
12862 : : return res;
12863 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12864 : : return TEST_SUCCESS;
12865 : : }
12866 : :
12867 : : static int
12868 : 1 : test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
12869 : : {
12870 : : struct aead_test_data tdata;
12871 : : int res;
12872 : :
12873 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
12874 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
12875 : 1 : tdata.auth_tag.data[0] += 1;
12876 : : res = test_authenticated_encryption(&tdata);
12877 [ + - ]: 1 : if (res == TEST_SKIPPED)
12878 : : return res;
12879 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
12880 : : return TEST_SUCCESS;
12881 : : }
12882 : :
12883 : : static int
12884 : 42 : test_authenticated_decryption_helper(const struct aead_test_data *tdata, bool use_ext_mbuf)
12885 : : {
12886 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
12887 : : struct crypto_unittest_params *ut_params = &unittest_params;
12888 : :
12889 : : int retval;
12890 : : uint8_t *plaintext;
12891 : : uint32_t i;
12892 : : struct rte_cryptodev_info dev_info;
12893 : :
12894 : 42 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12895 : 42 : uint64_t feat_flags = dev_info.feature_flags;
12896 : :
12897 [ - + ]: 42 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12898 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12899 : : printf("Device doesn't support RAW data-path APIs.\n");
12900 : 0 : return TEST_SKIPPED;
12901 : : }
12902 : :
12903 : : /* Verify the capabilities */
12904 : : struct rte_cryptodev_sym_capability_idx cap_idx;
12905 : : const struct rte_cryptodev_symmetric_capability *capability;
12906 : 42 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12907 : 42 : cap_idx.algo.aead = tdata->algo;
12908 : 42 : capability = rte_cryptodev_sym_capability_get(
12909 : 42 : ts_params->valid_devs[0], &cap_idx);
12910 [ + - ]: 42 : if (capability == NULL)
12911 : : return TEST_SKIPPED;
12912 [ + + ]: 42 : if (rte_cryptodev_sym_capability_check_aead(
12913 : 42 : capability, tdata->key.len, tdata->auth_tag.len,
12914 : 42 : tdata->aad.len, tdata->iv.len))
12915 : : return TEST_SKIPPED;
12916 : :
12917 : : /* Create AEAD session */
12918 : 41 : retval = create_aead_session(ts_params->valid_devs[0],
12919 : 41 : tdata->algo,
12920 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
12921 : 41 : tdata->key.data, tdata->key.len,
12922 : 41 : tdata->aad.len, tdata->auth_tag.len,
12923 : 41 : tdata->iv.len);
12924 [ + - ]: 41 : if (retval != TEST_SUCCESS)
12925 : : return retval;
12926 : :
12927 : : /* alloc mbuf and set payload */
12928 [ + + ]: 41 : if (tdata->aad.len > MBUF_SIZE) {
12929 [ - + ]: 2 : if (use_ext_mbuf) {
12930 : 0 : ut_params->ibuf = ext_mbuf_create(ts_params->large_mbuf_pool,
12931 : : AEAD_TEXT_MAX_LENGTH,
12932 : : 1 /* nb_segs */,
12933 : : NULL);
12934 : : } else {
12935 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12936 : : }
12937 : : /* Populate full size of add data */
12938 [ + + ]: 4096 : for (i = 32; i < MAX_AAD_LENGTH; i += 32)
12939 : 4094 : memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
12940 : : } else {
12941 [ + + ]: 39 : if (use_ext_mbuf) {
12942 : 1 : ut_params->ibuf = ext_mbuf_create(ts_params->mbuf_pool,
12943 : : AEAD_TEXT_MAX_LENGTH,
12944 : : 1 /* nb_segs */,
12945 : : NULL);
12946 : : } else {
12947 : 38 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12948 : : }
12949 : : }
12950 : 41 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12951 : 41 : rte_pktmbuf_tailroom(ut_params->ibuf));
12952 : :
12953 : : /* Create AEAD operation */
12954 : 41 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
12955 [ + - ]: 41 : if (retval < 0)
12956 : : return retval;
12957 : :
12958 [ + - ]: 41 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12959 : :
12960 : 41 : ut_params->op->sym->m_src = ut_params->ibuf;
12961 : :
12962 : : /* Process crypto operation */
12963 [ - + ]: 41 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12964 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
12965 [ - + ]: 41 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
12966 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
12967 : : 0);
12968 [ # # ]: 0 : if (retval != TEST_SUCCESS)
12969 : : return retval;
12970 : : } else
12971 [ + + ]: 41 : TEST_ASSERT_NOT_NULL(
12972 : : process_crypto_request(ts_params->valid_devs[0],
12973 : : ut_params->op), "failed to process sym crypto op");
12974 : :
12975 [ - + ]: 36 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12976 : : "crypto op processing failed");
12977 : :
12978 [ - + ]: 36 : if (ut_params->op->sym->m_dst)
12979 : 0 : plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
12980 : : uint8_t *);
12981 : : else
12982 : 36 : plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
12983 : : uint8_t *,
12984 : : ut_params->op->sym->cipher.data.offset);
12985 : :
12986 : 36 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
12987 : :
12988 : : /* Validate obuf */
12989 [ + + ]: 37 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
12990 : : plaintext,
12991 : : tdata->plaintext.data,
12992 : : tdata->plaintext.len,
12993 : : "Plaintext data not as expected");
12994 : :
12995 [ - + ]: 35 : TEST_ASSERT_EQUAL(ut_params->op->status,
12996 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
12997 : : "Authentication failed");
12998 : :
12999 : : return 0;
13000 : : }
13001 : :
13002 : : static int
13003 : : test_authenticated_decryption(const struct aead_test_data *tdata)
13004 : : {
13005 : 41 : return test_authenticated_decryption_helper(tdata, false);
13006 : : }
13007 : :
13008 : : static int
13009 : 1 : test_AES_GCM_authenticated_decryption_test_case_1(void)
13010 : : {
13011 : 1 : return test_authenticated_decryption(&gcm_test_case_1);
13012 : : }
13013 : :
13014 : : static int
13015 : 1 : test_AES_GCM_authenticated_decryption_test_case_2(void)
13016 : : {
13017 : 1 : return test_authenticated_decryption(&gcm_test_case_2);
13018 : : }
13019 : :
13020 : : static int
13021 : 1 : test_AES_GCM_authenticated_decryption_test_case_3(void)
13022 : : {
13023 : 1 : return test_authenticated_decryption(&gcm_test_case_3);
13024 : : }
13025 : :
13026 : : static int
13027 : 1 : test_AES_GCM_authenticated_decryption_test_case_3_ext_mbuf(void)
13028 : : {
13029 : 1 : return test_authenticated_decryption_helper(&gcm_test_case_3, true);
13030 : : }
13031 : :
13032 : : static int
13033 : 1 : test_AES_GCM_authenticated_decryption_test_case_4(void)
13034 : : {
13035 : 1 : return test_authenticated_decryption(&gcm_test_case_4);
13036 : : }
13037 : :
13038 : : static int
13039 : 1 : test_AES_GCM_authenticated_decryption_test_case_5(void)
13040 : : {
13041 : 1 : return test_authenticated_decryption(&gcm_test_case_5);
13042 : : }
13043 : :
13044 : : static int
13045 : 1 : test_AES_GCM_authenticated_decryption_test_case_6(void)
13046 : : {
13047 : 1 : return test_authenticated_decryption(&gcm_test_case_6);
13048 : : }
13049 : :
13050 : : static int
13051 : 1 : test_AES_GCM_authenticated_decryption_test_case_7(void)
13052 : : {
13053 : 1 : return test_authenticated_decryption(&gcm_test_case_7);
13054 : : }
13055 : :
13056 : : static int
13057 : 1 : test_AES_GCM_authenticated_decryption_test_case_8(void)
13058 : : {
13059 : 1 : return test_authenticated_decryption(&gcm_test_case_8);
13060 : : }
13061 : :
13062 : : static int
13063 : 1 : test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
13064 : : {
13065 : 1 : return test_authenticated_decryption(&gcm_J0_test_case_1);
13066 : : }
13067 : :
13068 : : static int
13069 : 1 : test_AES_GCM_auth_decryption_test_case_192_1(void)
13070 : : {
13071 : 1 : return test_authenticated_decryption(&gcm_test_case_192_1);
13072 : : }
13073 : :
13074 : : static int
13075 : 1 : test_AES_GCM_auth_decryption_test_case_192_2(void)
13076 : : {
13077 : 1 : return test_authenticated_decryption(&gcm_test_case_192_2);
13078 : : }
13079 : :
13080 : : static int
13081 : 1 : test_AES_GCM_auth_decryption_test_case_192_3(void)
13082 : : {
13083 : 1 : return test_authenticated_decryption(&gcm_test_case_192_3);
13084 : : }
13085 : :
13086 : : static int
13087 : 1 : test_AES_GCM_auth_decryption_test_case_192_4(void)
13088 : : {
13089 : 1 : return test_authenticated_decryption(&gcm_test_case_192_4);
13090 : : }
13091 : :
13092 : : static int
13093 : 1 : test_AES_GCM_auth_decryption_test_case_192_5(void)
13094 : : {
13095 : 1 : return test_authenticated_decryption(&gcm_test_case_192_5);
13096 : : }
13097 : :
13098 : : static int
13099 : 1 : test_AES_GCM_auth_decryption_test_case_192_6(void)
13100 : : {
13101 : 1 : return test_authenticated_decryption(&gcm_test_case_192_6);
13102 : : }
13103 : :
13104 : : static int
13105 : 1 : test_AES_GCM_auth_decryption_test_case_192_7(void)
13106 : : {
13107 : 1 : return test_authenticated_decryption(&gcm_test_case_192_7);
13108 : : }
13109 : :
13110 : : static int
13111 : 1 : test_AES_GCM_auth_decryption_test_case_256_1(void)
13112 : : {
13113 : 1 : return test_authenticated_decryption(&gcm_test_case_256_1);
13114 : : }
13115 : :
13116 : : static int
13117 : 1 : test_AES_GCM_auth_decryption_test_case_256_2(void)
13118 : : {
13119 : 1 : return test_authenticated_decryption(&gcm_test_case_256_2);
13120 : : }
13121 : :
13122 : : static int
13123 : 1 : test_AES_GCM_auth_decryption_test_case_256_3(void)
13124 : : {
13125 : 1 : return test_authenticated_decryption(&gcm_test_case_256_3);
13126 : : }
13127 : :
13128 : : static int
13129 : 1 : test_AES_GCM_auth_decryption_test_case_256_4(void)
13130 : : {
13131 : 1 : return test_authenticated_decryption(&gcm_test_case_256_4);
13132 : : }
13133 : :
13134 : : static int
13135 : 1 : test_AES_GCM_auth_decryption_test_case_256_5(void)
13136 : : {
13137 : 1 : return test_authenticated_decryption(&gcm_test_case_256_5);
13138 : : }
13139 : :
13140 : : static int
13141 : 1 : test_AES_GCM_auth_decryption_test_case_256_6(void)
13142 : : {
13143 : 1 : return test_authenticated_decryption(&gcm_test_case_256_6);
13144 : : }
13145 : :
13146 : : static int
13147 : 1 : test_AES_GCM_auth_decryption_test_case_256_7(void)
13148 : : {
13149 : 1 : return test_authenticated_decryption(&gcm_test_case_256_7);
13150 : : }
13151 : :
13152 : : static int
13153 : 1 : test_AES_GCM_auth_decryption_test_case_256_8(void)
13154 : : {
13155 : 1 : return test_authenticated_decryption(&gcm_test_case_256_8);
13156 : : }
13157 : :
13158 : : static int
13159 : 1 : test_AES_GCM_auth_encryption_test_case_256_8(void)
13160 : : {
13161 : 1 : return test_authenticated_encryption(&gcm_test_case_256_8);
13162 : : }
13163 : :
13164 : : static int
13165 : 1 : test_AES_GCM_auth_decryption_test_case_aad_1(void)
13166 : : {
13167 : 1 : return test_authenticated_decryption(&gcm_test_case_aad_1);
13168 : : }
13169 : :
13170 : : static int
13171 : 1 : test_AES_GCM_auth_decryption_test_case_aad_2(void)
13172 : : {
13173 : 1 : return test_authenticated_decryption(&gcm_test_case_aad_2);
13174 : : }
13175 : :
13176 : : static int
13177 : 1 : test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
13178 : : {
13179 : : struct aead_test_data tdata;
13180 : : int res;
13181 : :
13182 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13183 : 1 : tdata.iv.data[0] += 1;
13184 : : res = test_authenticated_decryption(&tdata);
13185 [ + - ]: 1 : if (res == TEST_SKIPPED)
13186 : : return res;
13187 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13188 : : return TEST_SUCCESS;
13189 : : }
13190 : :
13191 : : static int
13192 : 1 : test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
13193 : : {
13194 : : struct aead_test_data tdata;
13195 : : int res;
13196 : :
13197 : 1 : RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
13198 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13199 : 1 : tdata.plaintext.data[0] += 1;
13200 : : res = test_authenticated_decryption(&tdata);
13201 [ + - ]: 1 : if (res == TEST_SKIPPED)
13202 : : return res;
13203 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13204 : : return TEST_SUCCESS;
13205 : : }
13206 : :
13207 : : static int
13208 : 1 : test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
13209 : : {
13210 : : struct aead_test_data tdata;
13211 : : int res;
13212 : :
13213 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13214 : 1 : tdata.ciphertext.data[0] += 1;
13215 : : res = test_authenticated_decryption(&tdata);
13216 [ + - ]: 1 : if (res == TEST_SKIPPED)
13217 : : return res;
13218 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13219 : : return TEST_SUCCESS;
13220 : : }
13221 : :
13222 : : static int
13223 : 1 : test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
13224 : : {
13225 : : struct aead_test_data tdata;
13226 : : int res;
13227 : :
13228 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13229 : 1 : tdata.aad.len += 1;
13230 : : res = test_authenticated_decryption(&tdata);
13231 [ + - ]: 1 : if (res == TEST_SKIPPED)
13232 : : return res;
13233 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13234 : : return TEST_SUCCESS;
13235 : : }
13236 : :
13237 : : static int
13238 : 1 : test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
13239 : 1 : {
13240 : : struct aead_test_data tdata;
13241 : : uint8_t aad[gcm_test_case_7.aad.len];
13242 : : int res;
13243 : :
13244 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13245 : : memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
13246 : 1 : aad[0] += 1;
13247 : 1 : tdata.aad.data = aad;
13248 : : res = test_authenticated_decryption(&tdata);
13249 [ + - ]: 1 : if (res == TEST_SKIPPED)
13250 : : return res;
13251 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
13252 : : return TEST_SUCCESS;
13253 : : }
13254 : :
13255 : : static int
13256 : 1 : test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
13257 : : {
13258 : : struct aead_test_data tdata;
13259 : : int res;
13260 : :
13261 : : memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
13262 : 1 : tdata.auth_tag.data[0] += 1;
13263 : : res = test_authenticated_decryption(&tdata);
13264 [ + - ]: 1 : if (res == TEST_SKIPPED)
13265 : : return res;
13266 [ - + ]: 1 : TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
13267 : : return TEST_SUCCESS;
13268 : : }
13269 : :
13270 : : static int
13271 : 1 : test_authenticated_encryption_oop(const struct aead_test_data *tdata)
13272 : : {
13273 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13274 : : struct crypto_unittest_params *ut_params = &unittest_params;
13275 : :
13276 : : int retval;
13277 : : uint8_t *ciphertext, *auth_tag;
13278 : : uint16_t plaintext_pad_len;
13279 : : struct rte_cryptodev_info dev_info;
13280 : :
13281 : : /* Verify the capabilities */
13282 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13283 : : const struct rte_cryptodev_symmetric_capability *capability;
13284 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13285 : 1 : cap_idx.algo.aead = tdata->algo;
13286 : 1 : capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
13287 [ + - ]: 1 : if (capability == NULL)
13288 : : return TEST_SKIPPED;
13289 [ + - ]: 1 : if (rte_cryptodev_sym_capability_check_aead(
13290 : 1 : capability, tdata->key.len, tdata->auth_tag.len,
13291 : 1 : tdata->aad.len, tdata->iv.len))
13292 : : return TEST_SKIPPED;
13293 : :
13294 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13295 : 1 : uint64_t feat_flags = dev_info.feature_flags;
13296 : :
13297 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13298 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)))
13299 : : return TEST_SKIPPED;
13300 : :
13301 : : /* not supported with CPU crypto */
13302 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13303 : : return TEST_SKIPPED;
13304 : :
13305 : : /* Create AEAD session */
13306 : 1 : retval = create_aead_session(ts_params->valid_devs[0],
13307 : 1 : tdata->algo,
13308 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
13309 : 1 : tdata->key.data, tdata->key.len,
13310 : 1 : tdata->aad.len, tdata->auth_tag.len,
13311 : 1 : tdata->iv.len);
13312 [ + - ]: 1 : if (retval < 0)
13313 : : return retval;
13314 : :
13315 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13316 : 1 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13317 : :
13318 : : /* clear mbuf payload */
13319 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13320 : 1 : rte_pktmbuf_tailroom(ut_params->ibuf));
13321 : 1 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
13322 : 1 : rte_pktmbuf_tailroom(ut_params->obuf));
13323 : :
13324 : : /* Create AEAD operation */
13325 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
13326 [ + - ]: 1 : if (retval < 0)
13327 : : return retval;
13328 : :
13329 [ + - ]: 1 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13330 : :
13331 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
13332 : 1 : ut_params->op->sym->m_dst = ut_params->obuf;
13333 : :
13334 : : /* Process crypto operation */
13335 [ - + ]: 1 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13336 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13337 : : 0);
13338 [ # # ]: 0 : if (retval != TEST_SUCCESS)
13339 : : return retval;
13340 : : } else
13341 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
13342 : : ut_params->op), "failed to process sym crypto op");
13343 : :
13344 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13345 : : "crypto op processing failed");
13346 : :
13347 : 1 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
13348 : :
13349 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
13350 : : ut_params->op->sym->cipher.data.offset);
13351 : 1 : auth_tag = ciphertext + plaintext_pad_len;
13352 : :
13353 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
13354 : 1 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
13355 : :
13356 : : /* Validate obuf */
13357 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
13358 : : ciphertext,
13359 : : tdata->ciphertext.data,
13360 : : tdata->ciphertext.len,
13361 : : "Ciphertext data not as expected");
13362 : :
13363 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
13364 : : auth_tag,
13365 : : tdata->auth_tag.data,
13366 : : tdata->auth_tag.len,
13367 : : "Generated auth tag not as expected");
13368 : :
13369 : : return 0;
13370 : :
13371 : : }
13372 : :
13373 : : static int
13374 : 1 : test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
13375 : : {
13376 : 1 : return test_authenticated_encryption_oop(&gcm_test_case_5);
13377 : : }
13378 : :
13379 : : static int
13380 : 1 : test_authenticated_decryption_oop(const struct aead_test_data *tdata)
13381 : : {
13382 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13383 : : struct crypto_unittest_params *ut_params = &unittest_params;
13384 : :
13385 : : int retval;
13386 : : uint8_t *plaintext;
13387 : : struct rte_cryptodev_info dev_info;
13388 : :
13389 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13390 : : uint64_t feat_flags = dev_info.feature_flags;
13391 : :
13392 : : /* Verify the capabilities */
13393 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13394 : : const struct rte_cryptodev_symmetric_capability *capability;
13395 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13396 : 1 : cap_idx.algo.aead = tdata->algo;
13397 : 1 : capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
13398 : :
13399 [ + - ]: 1 : if (capability == NULL)
13400 : : return TEST_SKIPPED;
13401 : :
13402 [ + - ]: 1 : if (rte_cryptodev_sym_capability_check_aead(capability, tdata->key.len,
13403 : 1 : tdata->auth_tag.len, tdata->aad.len, tdata->iv.len))
13404 : : return TEST_SKIPPED;
13405 : :
13406 : : /* not supported with CPU crypto and raw data-path APIs*/
13407 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
13408 [ + - ]: 1 : global_api_test_type == CRYPTODEV_RAW_API_TEST)
13409 : : return TEST_SKIPPED;
13410 : :
13411 : : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13412 : : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13413 : : printf("Device does not support RAW data-path APIs.\n");
13414 : : return TEST_SKIPPED;
13415 : : }
13416 : :
13417 : : /* Create AEAD session */
13418 : 1 : retval = create_aead_session(ts_params->valid_devs[0],
13419 : 1 : tdata->algo,
13420 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
13421 : 1 : tdata->key.data, tdata->key.len,
13422 : 1 : tdata->aad.len, tdata->auth_tag.len,
13423 : 1 : tdata->iv.len);
13424 [ + - ]: 1 : if (retval < 0)
13425 : : return retval;
13426 : :
13427 : : /* alloc mbuf and set payload */
13428 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13429 : 1 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13430 : :
13431 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13432 : 1 : rte_pktmbuf_tailroom(ut_params->ibuf));
13433 : 1 : memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
13434 : 1 : rte_pktmbuf_tailroom(ut_params->obuf));
13435 : :
13436 : : /* Create AEAD operation */
13437 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
13438 [ + - ]: 1 : if (retval < 0)
13439 : : return retval;
13440 : :
13441 [ + - ]: 1 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13442 : :
13443 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
13444 : 1 : ut_params->op->sym->m_dst = ut_params->obuf;
13445 : :
13446 : : /* Process crypto operation */
13447 [ - + ]: 1 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13448 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13449 : : 0);
13450 [ # # ]: 0 : if (retval != TEST_SUCCESS)
13451 : : return retval;
13452 : : } else
13453 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
13454 : : ut_params->op), "failed to process sym crypto op");
13455 : :
13456 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13457 : : "crypto op processing failed");
13458 : :
13459 : 1 : plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
13460 : : ut_params->op->sym->cipher.data.offset);
13461 : :
13462 : 1 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
13463 : :
13464 : : /* Validate obuf */
13465 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
13466 : : plaintext,
13467 : : tdata->plaintext.data,
13468 : : tdata->plaintext.len,
13469 : : "Plaintext data not as expected");
13470 : :
13471 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status,
13472 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
13473 : : "Authentication failed");
13474 : : return 0;
13475 : : }
13476 : :
13477 : : static int
13478 : 1 : test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
13479 : : {
13480 : 1 : return test_authenticated_decryption_oop(&gcm_test_case_5);
13481 : : }
13482 : :
13483 : : static int
13484 : 1 : test_authenticated_encryption_sessionless(
13485 : : const struct aead_test_data *tdata)
13486 : 1 : {
13487 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13488 : : struct crypto_unittest_params *ut_params = &unittest_params;
13489 : :
13490 : : int retval;
13491 : : uint8_t *ciphertext, *auth_tag;
13492 : : uint16_t plaintext_pad_len;
13493 : 1 : uint8_t key[tdata->key.len + 1];
13494 : : struct rte_cryptodev_info dev_info;
13495 : :
13496 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13497 : 1 : uint64_t feat_flags = dev_info.feature_flags;
13498 : :
13499 [ - + ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
13500 : : printf("Device doesn't support Sessionless ops.\n");
13501 : 0 : return TEST_SKIPPED;
13502 : : }
13503 : :
13504 : : /* not supported with CPU crypto */
13505 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13506 : : return TEST_SKIPPED;
13507 : :
13508 : : /* Verify the capabilities */
13509 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13510 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13511 : 1 : cap_idx.algo.aead = tdata->algo;
13512 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13513 : : &cap_idx) == NULL)
13514 : : return TEST_SKIPPED;
13515 : :
13516 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13517 : :
13518 : : /* clear mbuf payload */
13519 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13520 : : rte_pktmbuf_tailroom(ut_params->ibuf));
13521 : :
13522 : : /* Create AEAD operation */
13523 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
13524 [ + - ]: 1 : if (retval < 0)
13525 : : return retval;
13526 : :
13527 : : /* Create GCM xform */
13528 : 1 : memcpy(key, tdata->key.data, tdata->key.len);
13529 : 1 : retval = create_aead_xform(ut_params->op,
13530 : 1 : tdata->algo,
13531 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
13532 : : key, tdata->key.len,
13533 : 1 : tdata->aad.len, tdata->auth_tag.len,
13534 : 1 : tdata->iv.len);
13535 [ + - ]: 1 : if (retval < 0)
13536 : : return retval;
13537 : :
13538 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
13539 : :
13540 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->sess_type,
13541 : : RTE_CRYPTO_OP_SESSIONLESS,
13542 : : "crypto op session type not sessionless");
13543 : :
13544 : : /* Process crypto operation */
13545 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
13546 : : ut_params->op), "failed to process sym crypto op");
13547 : :
13548 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
13549 : :
13550 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13551 : : "crypto op status not success");
13552 : :
13553 : 1 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
13554 : :
13555 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
13556 : : ut_params->op->sym->cipher.data.offset);
13557 : 1 : auth_tag = ciphertext + plaintext_pad_len;
13558 : :
13559 : 1 : debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
13560 : 1 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
13561 : :
13562 : : /* Validate obuf */
13563 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
13564 : : ciphertext,
13565 : : tdata->ciphertext.data,
13566 : : tdata->ciphertext.len,
13567 : : "Ciphertext data not as expected");
13568 : :
13569 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
13570 : : auth_tag,
13571 : : tdata->auth_tag.data,
13572 : : tdata->auth_tag.len,
13573 : : "Generated auth tag not as expected");
13574 : :
13575 : : return 0;
13576 : :
13577 : : }
13578 : :
13579 : : static int
13580 : 1 : test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
13581 : : {
13582 : 1 : return test_authenticated_encryption_sessionless(
13583 : : &gcm_test_case_5);
13584 : : }
13585 : :
13586 : : static int
13587 : 1 : test_authenticated_decryption_sessionless(
13588 : : const struct aead_test_data *tdata)
13589 : 1 : {
13590 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13591 : : struct crypto_unittest_params *ut_params = &unittest_params;
13592 : :
13593 : : int retval;
13594 : : uint8_t *plaintext;
13595 : 1 : uint8_t key[tdata->key.len + 1];
13596 : : struct rte_cryptodev_info dev_info;
13597 : :
13598 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13599 : 1 : uint64_t feat_flags = dev_info.feature_flags;
13600 : :
13601 [ - + ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
13602 : : printf("Device doesn't support Sessionless ops.\n");
13603 : 0 : return TEST_SKIPPED;
13604 : : }
13605 : :
13606 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13607 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13608 : : printf("Device doesn't support RAW data-path APIs.\n");
13609 : 0 : return TEST_SKIPPED;
13610 : : }
13611 : :
13612 : : /* not supported with CPU crypto */
13613 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13614 : : return TEST_SKIPPED;
13615 : :
13616 : : /* Verify the capabilities */
13617 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13618 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13619 : 1 : cap_idx.algo.aead = tdata->algo;
13620 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13621 : : &cap_idx) == NULL)
13622 : : return TEST_SKIPPED;
13623 : :
13624 : : /* alloc mbuf and set payload */
13625 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13626 : :
13627 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13628 : : rte_pktmbuf_tailroom(ut_params->ibuf));
13629 : :
13630 : : /* Create AEAD operation */
13631 : 1 : retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
13632 [ + - ]: 1 : if (retval < 0)
13633 : : return retval;
13634 : :
13635 : : /* Create AEAD xform */
13636 : 1 : memcpy(key, tdata->key.data, tdata->key.len);
13637 : 1 : retval = create_aead_xform(ut_params->op,
13638 : 1 : tdata->algo,
13639 : : RTE_CRYPTO_AEAD_OP_DECRYPT,
13640 : : key, tdata->key.len,
13641 : 1 : tdata->aad.len, tdata->auth_tag.len,
13642 : 1 : tdata->iv.len);
13643 [ + - ]: 1 : if (retval < 0)
13644 : : return retval;
13645 : :
13646 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
13647 : :
13648 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->sess_type,
13649 : : RTE_CRYPTO_OP_SESSIONLESS,
13650 : : "crypto op session type not sessionless");
13651 : :
13652 : : /* Process crypto operation */
13653 [ - + ]: 1 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
13654 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
13655 : : 0);
13656 [ # # ]: 0 : if (retval != TEST_SUCCESS)
13657 : : return retval;
13658 : : } else
13659 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(process_crypto_request(
13660 : : ts_params->valid_devs[0], ut_params->op),
13661 : : "failed to process sym crypto op");
13662 : :
13663 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
13664 : :
13665 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13666 : : "crypto op status not success");
13667 : :
13668 : 1 : plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
13669 : : ut_params->op->sym->cipher.data.offset);
13670 : :
13671 : 1 : debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
13672 : :
13673 : : /* Validate obuf */
13674 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
13675 : : plaintext,
13676 : : tdata->plaintext.data,
13677 : : tdata->plaintext.len,
13678 : : "Plaintext data not as expected");
13679 : :
13680 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status,
13681 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
13682 : : "Authentication failed");
13683 : : return 0;
13684 : : }
13685 : :
13686 : : static int
13687 : 1 : test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
13688 : : {
13689 : 1 : return test_authenticated_decryption_sessionless(
13690 : : &gcm_test_case_5);
13691 : : }
13692 : :
13693 : : static int
13694 : 1 : test_AES_CCM_authenticated_encryption_test_case_128_1(void)
13695 : : {
13696 : 1 : return test_authenticated_encryption(&ccm_test_case_128_1);
13697 : : }
13698 : :
13699 : : static int
13700 : 1 : test_AES_CCM_authenticated_encryption_test_case_128_2(void)
13701 : : {
13702 : 1 : return test_authenticated_encryption(&ccm_test_case_128_2);
13703 : : }
13704 : :
13705 : : static int
13706 : 1 : test_AES_CCM_authenticated_encryption_test_case_128_3(void)
13707 : : {
13708 : 1 : return test_authenticated_encryption(&ccm_test_case_128_3);
13709 : : }
13710 : :
13711 : : static int
13712 : 1 : test_AES_CCM_authenticated_decryption_test_case_128_1(void)
13713 : : {
13714 : 1 : return test_authenticated_decryption(&ccm_test_case_128_1);
13715 : : }
13716 : :
13717 : : static int
13718 : 1 : test_AES_CCM_authenticated_decryption_test_case_128_2(void)
13719 : : {
13720 : 1 : return test_authenticated_decryption(&ccm_test_case_128_2);
13721 : : }
13722 : :
13723 : : static int
13724 : 1 : test_AES_CCM_authenticated_decryption_test_case_128_3(void)
13725 : : {
13726 : 1 : return test_authenticated_decryption(&ccm_test_case_128_3);
13727 : : }
13728 : :
13729 : : static int
13730 : 1 : test_AES_CCM_authenticated_encryption_test_case_192_1(void)
13731 : : {
13732 : 1 : return test_authenticated_encryption(&ccm_test_case_192_1);
13733 : : }
13734 : :
13735 : : static int
13736 : 1 : test_AES_CCM_authenticated_encryption_test_case_192_2(void)
13737 : : {
13738 : 1 : return test_authenticated_encryption(&ccm_test_case_192_2);
13739 : : }
13740 : :
13741 : : static int
13742 : 1 : test_AES_CCM_authenticated_encryption_test_case_192_3(void)
13743 : : {
13744 : 1 : return test_authenticated_encryption(&ccm_test_case_192_3);
13745 : : }
13746 : :
13747 : : static int
13748 : 1 : test_AES_CCM_authenticated_decryption_test_case_192_1(void)
13749 : : {
13750 : 1 : return test_authenticated_decryption(&ccm_test_case_192_1);
13751 : : }
13752 : :
13753 : : static int
13754 : 1 : test_AES_CCM_authenticated_decryption_test_case_192_2(void)
13755 : : {
13756 : 1 : return test_authenticated_decryption(&ccm_test_case_192_2);
13757 : : }
13758 : :
13759 : : static int
13760 : 1 : test_AES_CCM_authenticated_decryption_test_case_192_3(void)
13761 : : {
13762 : 1 : return test_authenticated_decryption(&ccm_test_case_192_3);
13763 : : }
13764 : :
13765 : : static int
13766 : 1 : test_AES_CCM_authenticated_encryption_test_case_256_1(void)
13767 : : {
13768 : 1 : return test_authenticated_encryption(&ccm_test_case_256_1);
13769 : : }
13770 : :
13771 : : static int
13772 : 1 : test_AES_CCM_authenticated_encryption_test_case_256_2(void)
13773 : : {
13774 : 1 : return test_authenticated_encryption(&ccm_test_case_256_2);
13775 : : }
13776 : :
13777 : : static int
13778 : 1 : test_AES_CCM_authenticated_encryption_test_case_256_3(void)
13779 : : {
13780 : 1 : return test_authenticated_encryption(&ccm_test_case_256_3);
13781 : : }
13782 : :
13783 : : static int
13784 : 1 : test_AES_CCM_authenticated_decryption_test_case_256_1(void)
13785 : : {
13786 : 1 : return test_authenticated_decryption(&ccm_test_case_256_1);
13787 : : }
13788 : :
13789 : : static int
13790 : 1 : test_AES_CCM_authenticated_decryption_test_case_256_2(void)
13791 : : {
13792 : 1 : return test_authenticated_decryption(&ccm_test_case_256_2);
13793 : : }
13794 : :
13795 : : static int
13796 : 1 : test_AES_CCM_authenticated_decryption_test_case_256_3(void)
13797 : : {
13798 : 1 : return test_authenticated_decryption(&ccm_test_case_256_3);
13799 : : }
13800 : :
13801 : : static int
13802 : 1 : test_stats(void)
13803 : : {
13804 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13805 : : struct rte_cryptodev_stats stats;
13806 : :
13807 [ + - ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13808 : : return TEST_SKIPPED;
13809 : :
13810 : : /* Verify the capabilities */
13811 : : struct rte_cryptodev_sym_capability_idx cap_idx;
13812 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13813 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
13814 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13815 : : &cap_idx) == NULL)
13816 : : return TEST_SKIPPED;
13817 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13818 : 1 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
13819 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13820 : : &cap_idx) == NULL)
13821 : : return TEST_SKIPPED;
13822 : :
13823 [ + - ]: 1 : if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
13824 : : == -ENOTSUP)
13825 : : return TEST_SKIPPED;
13826 : :
13827 : 1 : rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
13828 [ - + ]: 1 : TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
13829 : : &stats) == -ENODEV),
13830 : : "rte_cryptodev_stats_get invalid dev failed");
13831 [ - + ]: 1 : TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
13832 : : "rte_cryptodev_stats_get invalid Param failed");
13833 : :
13834 : : /* Test expected values */
13835 : 1 : test_AES_CBC_HMAC_SHA1_encrypt_digest();
13836 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
13837 : : &stats),
13838 : : "rte_cryptodev_stats_get failed");
13839 [ - + ]: 1 : TEST_ASSERT((stats.enqueued_count == 1),
13840 : : "rte_cryptodev_stats_get returned unexpected enqueued stat");
13841 [ - + ]: 1 : TEST_ASSERT((stats.dequeued_count == 1),
13842 : : "rte_cryptodev_stats_get returned unexpected dequeued stat");
13843 [ - + ]: 1 : TEST_ASSERT((stats.enqueue_err_count == 0),
13844 : : "rte_cryptodev_stats_get returned unexpected enqueued error count stat");
13845 [ - + ]: 1 : TEST_ASSERT((stats.dequeue_err_count == 0),
13846 : : "rte_cryptodev_stats_get returned unexpected dequeued error count stat");
13847 : :
13848 : : /* invalid device but should ignore and not reset device stats*/
13849 : 1 : rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
13850 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
13851 : : &stats),
13852 : : "rte_cryptodev_stats_get failed");
13853 [ - + ]: 1 : TEST_ASSERT((stats.enqueued_count == 1),
13854 : : "rte_cryptodev_stats_get returned unexpected enqueued stat after invalid reset");
13855 : :
13856 : : /* check that a valid reset clears stats */
13857 : 1 : rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
13858 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
13859 : : &stats),
13860 : : "rte_cryptodev_stats_get failed");
13861 [ - + ]: 1 : TEST_ASSERT((stats.enqueued_count == 0),
13862 : : "rte_cryptodev_stats_get returned unexpected enqueued stat after valid reset");
13863 [ - + ]: 1 : TEST_ASSERT((stats.dequeued_count == 0),
13864 : : "rte_cryptodev_stats_get returned unexpected dequeued stat after valid reset");
13865 : :
13866 : : return TEST_SUCCESS;
13867 : : }
13868 : :
13869 : : static int
13870 : 1 : test_device_reconfigure(void)
13871 : : {
13872 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
13873 : 1 : uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
13874 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
13875 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT,
13876 : 1 : .mp_session = ts_params->session_mpool
13877 : : };
13878 : : uint16_t qp_id, dev_id, num_devs = 0;
13879 : :
13880 [ - + ]: 1 : TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
13881 : : "Need at least %d devices for test", 1);
13882 : :
13883 : 1 : dev_id = ts_params->valid_devs[0];
13884 : :
13885 : : /* Stop the device in case it's started so it can be configured */
13886 : 1 : rte_cryptodev_stop(dev_id);
13887 : :
13888 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
13889 : : "Failed test for rte_cryptodev_configure: "
13890 : : "dev_num %u", dev_id);
13891 : :
13892 : : /* Reconfigure with same configure params */
13893 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
13894 : : "Failed test for rte_cryptodev_configure: "
13895 : : "dev_num %u", dev_id);
13896 : :
13897 : : /* Reconfigure with just one queue pair */
13898 : 1 : ts_params->conf.nb_queue_pairs = 1;
13899 : :
13900 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
13901 : : &ts_params->conf),
13902 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
13903 : : ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
13904 : :
13905 [ + + ]: 2 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
13906 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
13907 : : ts_params->valid_devs[0], qp_id, &qp_conf,
13908 : : rte_cryptodev_socket_id(
13909 : : ts_params->valid_devs[0])),
13910 : : "Failed test for "
13911 : : "rte_cryptodev_queue_pair_setup: num_inflights "
13912 : : "%u on qp %u on cryptodev %u",
13913 : : qp_conf.nb_descriptors, qp_id,
13914 : : ts_params->valid_devs[0]);
13915 : : }
13916 : :
13917 : : /* Reconfigure with max number of queue pairs */
13918 : 1 : ts_params->conf.nb_queue_pairs = orig_nb_qps;
13919 : :
13920 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
13921 : : &ts_params->conf),
13922 : : "Failed to configure cryptodev: dev_id %u, qp_id %u",
13923 : : ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
13924 : :
13925 : 1 : qp_conf.mp_session = ts_params->session_mpool;
13926 : :
13927 [ + + ]: 9 : for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
13928 [ - + ]: 8 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
13929 : : ts_params->valid_devs[0], qp_id, &qp_conf,
13930 : : rte_cryptodev_socket_id(
13931 : : ts_params->valid_devs[0])),
13932 : : "Failed test for "
13933 : : "rte_cryptodev_queue_pair_setup: num_inflights "
13934 : : "%u on qp %u on cryptodev %u",
13935 : : qp_conf.nb_descriptors, qp_id,
13936 : : ts_params->valid_devs[0]);
13937 : : }
13938 : :
13939 : : /* Start the device */
13940 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
13941 : : "Failed to start cryptodev %u",
13942 : : ts_params->valid_devs[0]);
13943 : :
13944 : : /* Test expected values */
13945 : 1 : return test_AES_CBC_HMAC_SHA1_encrypt_digest();
13946 : : }
13947 : :
13948 : 4 : static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
13949 : : struct crypto_unittest_params *ut_params,
13950 : : enum rte_crypto_auth_operation op,
13951 : : const struct HMAC_MD5_vector *test_case)
13952 : : {
13953 : : uint8_t key[64];
13954 : :
13955 : 4 : memcpy(key, test_case->key.data, test_case->key.len);
13956 : :
13957 : 4 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13958 : 4 : ut_params->auth_xform.next = NULL;
13959 : 4 : ut_params->auth_xform.auth.op = op;
13960 : :
13961 : 4 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
13962 : :
13963 : 4 : ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
13964 : 4 : ut_params->auth_xform.auth.key.length = test_case->key.len;
13965 : 4 : ut_params->auth_xform.auth.key.data = key;
13966 : :
13967 : 8 : ut_params->sess = rte_cryptodev_sym_session_create(
13968 : 4 : ts_params->valid_devs[0], &ut_params->auth_xform,
13969 : : ts_params->session_mpool);
13970 [ - + - - ]: 4 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
13971 : : return TEST_SKIPPED;
13972 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13973 : :
13974 : 4 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13975 : :
13976 : 4 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13977 : : rte_pktmbuf_tailroom(ut_params->ibuf));
13978 : :
13979 : 4 : return 0;
13980 : : }
13981 : :
13982 : 4 : static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
13983 : : const struct HMAC_MD5_vector *test_case,
13984 : : uint8_t **plaintext)
13985 : : {
13986 : : uint16_t plaintext_pad_len;
13987 : :
13988 : 4 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13989 : :
13990 : 4 : plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
13991 : : 16);
13992 : :
13993 : 4 : *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13994 : : plaintext_pad_len);
13995 : 4 : memcpy(*plaintext, test_case->plaintext.data,
13996 : 4 : test_case->plaintext.len);
13997 : :
13998 : 4 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13999 : : ut_params->ibuf, MD5_DIGEST_LEN);
14000 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
14001 : : "no room to append digest");
14002 [ + + ]: 4 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
14003 : : ut_params->ibuf, plaintext_pad_len);
14004 : :
14005 [ + + ]: 4 : if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
14006 : 2 : rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
14007 [ - + ]: 2 : test_case->auth_tag.len);
14008 : : }
14009 : :
14010 : 4 : sym_op->auth.data.offset = 0;
14011 : 4 : sym_op->auth.data.length = test_case->plaintext.len;
14012 : :
14013 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14014 : 4 : ut_params->op->sym->m_src = ut_params->ibuf;
14015 : :
14016 : 4 : return 0;
14017 : : }
14018 : :
14019 : : static int
14020 : 2 : test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
14021 : : {
14022 : : uint16_t plaintext_pad_len;
14023 : : uint8_t *plaintext, *auth_tag;
14024 : : int ret;
14025 : :
14026 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14027 : : struct crypto_unittest_params *ut_params = &unittest_params;
14028 : : struct rte_cryptodev_info dev_info;
14029 : :
14030 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14031 : 2 : uint64_t feat_flags = dev_info.feature_flags;
14032 : :
14033 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14034 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14035 : : printf("Device doesn't support RAW data-path APIs.\n");
14036 : 0 : return TEST_SKIPPED;
14037 : : }
14038 : :
14039 : : /* Verify the capabilities */
14040 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14041 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14042 : 2 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
14043 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14044 : : &cap_idx) == NULL)
14045 : : return TEST_SKIPPED;
14046 : :
14047 [ + - ]: 2 : if (MD5_HMAC_create_session(ts_params, ut_params,
14048 : : RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
14049 : : return TEST_FAILED;
14050 : :
14051 : : /* Generate Crypto op data structure */
14052 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14053 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14054 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
14055 : : "Failed to allocate symmetric crypto operation struct");
14056 : :
14057 : 2 : plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
14058 : : 16);
14059 : :
14060 [ + - ]: 2 : if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
14061 : : return TEST_FAILED;
14062 : :
14063 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14064 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14065 : : ut_params->op);
14066 [ - + ]: 2 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14067 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
14068 [ # # ]: 0 : if (ret != TEST_SUCCESS)
14069 : : return ret;
14070 : : } else
14071 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(
14072 : : process_crypto_request(ts_params->valid_devs[0],
14073 : : ut_params->op),
14074 : : "failed to process sym crypto op");
14075 : :
14076 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14077 : : "crypto op processing failed");
14078 : :
14079 [ - + ]: 2 : if (ut_params->op->sym->m_dst) {
14080 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
14081 : : uint8_t *, plaintext_pad_len);
14082 : : } else {
14083 : 2 : auth_tag = plaintext + plaintext_pad_len;
14084 : : }
14085 : :
14086 [ - + ]: 2 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
14087 : : auth_tag,
14088 : : test_case->auth_tag.data,
14089 : : test_case->auth_tag.len,
14090 : : "HMAC_MD5 generated tag not as expected");
14091 : :
14092 : : return TEST_SUCCESS;
14093 : : }
14094 : :
14095 : : static int
14096 : 2 : test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
14097 : : {
14098 : : uint8_t *plaintext;
14099 : : int ret;
14100 : :
14101 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14102 : : struct crypto_unittest_params *ut_params = &unittest_params;
14103 : : struct rte_cryptodev_info dev_info;
14104 : :
14105 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14106 : 2 : uint64_t feat_flags = dev_info.feature_flags;
14107 : :
14108 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14109 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14110 : : printf("Device doesn't support RAW data-path APIs.\n");
14111 : 0 : return TEST_SKIPPED;
14112 : : }
14113 : :
14114 : : /* Verify the capabilities */
14115 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14116 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14117 : 2 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
14118 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14119 : : &cap_idx) == NULL)
14120 : : return TEST_SKIPPED;
14121 : :
14122 [ + - ]: 2 : if (MD5_HMAC_create_session(ts_params, ut_params,
14123 : : RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
14124 : : return TEST_FAILED;
14125 : : }
14126 : :
14127 : : /* Generate Crypto op data structure */
14128 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14129 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14130 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
14131 : : "Failed to allocate symmetric crypto operation struct");
14132 : :
14133 [ + - ]: 2 : if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
14134 : : return TEST_FAILED;
14135 : :
14136 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14137 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
14138 : : ut_params->op);
14139 [ - + ]: 2 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
14140 : 0 : ret = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0, 0);
14141 [ # # ]: 0 : if (ret != TEST_SUCCESS)
14142 : : return ret;
14143 : : } else
14144 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(
14145 : : process_crypto_request(ts_params->valid_devs[0],
14146 : : ut_params->op),
14147 : : "failed to process sym crypto op");
14148 : :
14149 [ - + ]: 2 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14150 : : "HMAC_MD5 crypto op processing failed");
14151 : :
14152 : : return TEST_SUCCESS;
14153 : : }
14154 : :
14155 : : static int
14156 : 1 : test_MD5_HMAC_generate_case_1(void)
14157 : : {
14158 : 1 : return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
14159 : : }
14160 : :
14161 : : static int
14162 : 1 : test_MD5_HMAC_verify_case_1(void)
14163 : : {
14164 : 1 : return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
14165 : : }
14166 : :
14167 : : static int
14168 : 1 : test_MD5_HMAC_generate_case_2(void)
14169 : : {
14170 : 1 : return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
14171 : : }
14172 : :
14173 : : static int
14174 : 1 : test_MD5_HMAC_verify_case_2(void)
14175 : : {
14176 : 1 : return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
14177 : : }
14178 : :
14179 : : static int
14180 : 1 : test_multi_session(void)
14181 : : {
14182 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14183 : : struct crypto_unittest_params *ut_params = &unittest_params;
14184 : : struct rte_cryptodev_info dev_info;
14185 : : int i, nb_sess, ret = TEST_SUCCESS;
14186 : : void **sessions;
14187 : :
14188 : : /* Verify the capabilities */
14189 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14190 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14191 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
14192 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14193 : : &cap_idx) == NULL)
14194 : : return TEST_SKIPPED;
14195 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14196 : 1 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
14197 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14198 : : &cap_idx) == NULL)
14199 : : return TEST_SKIPPED;
14200 : :
14201 : : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
14202 : : aes_cbc_key, hmac_sha512_key);
14203 : :
14204 : :
14205 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14206 : :
14207 : 1 : sessions = rte_malloc(NULL,
14208 : : sizeof(void *) *
14209 : : (MAX_NB_SESSIONS + 1), 0);
14210 : :
14211 : : /* Create multiple crypto sessions*/
14212 [ + + ]: 5 : for (i = 0; i < MAX_NB_SESSIONS; i++) {
14213 : 8 : sessions[i] = rte_cryptodev_sym_session_create(
14214 : 4 : ts_params->valid_devs[0], &ut_params->auth_xform,
14215 : : ts_params->session_mpool);
14216 [ - + - - ]: 4 : if (sessions[i] == NULL && rte_errno == ENOTSUP) {
14217 : : nb_sess = i;
14218 : : ret = TEST_SKIPPED;
14219 : : break;
14220 : : }
14221 : :
14222 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(sessions[i],
14223 : : "Session creation failed at session number %u",
14224 : : i);
14225 : :
14226 : : /* Attempt to send a request on each session */
14227 : 4 : ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
14228 : : sessions[i],
14229 : : ut_params,
14230 : : ts_params,
14231 : : catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
14232 : : catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
14233 : : aes_cbc_iv);
14234 : :
14235 : : /* free crypto operation structure */
14236 : 4 : rte_crypto_op_free(ut_params->op);
14237 : :
14238 : : /*
14239 : : * free mbuf - both obuf and ibuf are usually the same,
14240 : : * so check if they point at the same address is necessary,
14241 : : * to avoid freeing the mbuf twice.
14242 : : */
14243 [ + - ]: 4 : if (ut_params->obuf) {
14244 : 4 : rte_pktmbuf_free(ut_params->obuf);
14245 [ + - ]: 4 : if (ut_params->ibuf == ut_params->obuf)
14246 : 4 : ut_params->ibuf = 0;
14247 : 4 : ut_params->obuf = 0;
14248 : : }
14249 [ - + ]: 4 : if (ut_params->ibuf) {
14250 : 0 : rte_pktmbuf_free(ut_params->ibuf);
14251 : 0 : ut_params->ibuf = 0;
14252 : : }
14253 : :
14254 [ - + ]: 4 : if (ret != TEST_SUCCESS) {
14255 : 0 : i++;
14256 : 0 : break;
14257 : : }
14258 : : }
14259 : :
14260 : : nb_sess = i;
14261 : :
14262 [ + + ]: 5 : for (i = 0; i < nb_sess; i++) {
14263 : 4 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
14264 : 4 : sessions[i]);
14265 : : }
14266 : :
14267 : 1 : rte_free(sessions);
14268 : :
14269 [ + - ]: 1 : if (ret != TEST_SKIPPED)
14270 [ - + ]: 1 : TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", i - 1);
14271 : :
14272 : : return ret;
14273 : : }
14274 : :
14275 : : struct multi_session_params {
14276 : : struct crypto_unittest_params ut_params;
14277 : : uint8_t *cipher_key;
14278 : : uint8_t *hmac_key;
14279 : : const uint8_t *cipher;
14280 : : const uint8_t *digest;
14281 : : uint8_t *iv;
14282 : : };
14283 : :
14284 : : #define MB_SESSION_NUMBER 3
14285 : :
14286 : : static int
14287 : 1 : test_multi_session_random_usage(void)
14288 : : {
14289 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14290 : : struct rte_cryptodev_info dev_info;
14291 : : int index = 0, ret = TEST_SUCCESS;
14292 : : uint32_t nb_sess, i, j;
14293 : : void **sessions;
14294 : 1 : struct multi_session_params ut_paramz[] = {
14295 : :
14296 : : {
14297 : : .cipher_key = ms_aes_cbc_key0,
14298 : : .hmac_key = ms_hmac_key0,
14299 : : .cipher = ms_aes_cbc_cipher0,
14300 : : .digest = ms_hmac_digest0,
14301 : : .iv = ms_aes_cbc_iv0
14302 : : },
14303 : : {
14304 : : .cipher_key = ms_aes_cbc_key1,
14305 : : .hmac_key = ms_hmac_key1,
14306 : : .cipher = ms_aes_cbc_cipher1,
14307 : : .digest = ms_hmac_digest1,
14308 : : .iv = ms_aes_cbc_iv1
14309 : : },
14310 : : {
14311 : : .cipher_key = ms_aes_cbc_key2,
14312 : : .hmac_key = ms_hmac_key2,
14313 : : .cipher = ms_aes_cbc_cipher2,
14314 : : .digest = ms_hmac_digest2,
14315 : : .iv = ms_aes_cbc_iv2
14316 : : },
14317 : :
14318 : : };
14319 : :
14320 : : /* Verify the capabilities */
14321 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14322 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14323 : 1 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
14324 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14325 : : &cap_idx) == NULL)
14326 : : return TEST_SKIPPED;
14327 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14328 : 1 : cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
14329 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14330 : : &cap_idx) == NULL)
14331 : : return TEST_SKIPPED;
14332 : :
14333 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14334 : :
14335 : 1 : sessions = rte_malloc(NULL, (sizeof(void *)
14336 : : * MAX_NB_SESSIONS) + 1, 0);
14337 : :
14338 [ + + ]: 4 : for (i = 0; i < MB_SESSION_NUMBER; i++) {
14339 : :
14340 [ + + ]: 3 : rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
14341 : : sizeof(struct crypto_unittest_params));
14342 : :
14343 : 3 : test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
14344 : : &ut_paramz[i].ut_params,
14345 : : ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
14346 : :
14347 : : /* Create multiple crypto sessions*/
14348 : 6 : sessions[i] = rte_cryptodev_sym_session_create(
14349 : 3 : ts_params->valid_devs[0],
14350 : : &ut_paramz[i].ut_params.auth_xform,
14351 : : ts_params->session_mpool);
14352 [ - + - - ]: 3 : if (sessions[i] == NULL && rte_errno == ENOTSUP) {
14353 : : nb_sess = i;
14354 : : ret = TEST_SKIPPED;
14355 : 0 : goto session_clear;
14356 : : }
14357 : :
14358 [ - + ]: 3 : TEST_ASSERT_NOT_NULL(sessions[i],
14359 : : "Session creation failed at session number %u",
14360 : : i);
14361 : : }
14362 : :
14363 : : nb_sess = i;
14364 : :
14365 : 1 : srand(time(NULL));
14366 [ + - ]: 1 : for (i = 0; i < 40000; i++) {
14367 : :
14368 : 1 : j = rand() % MB_SESSION_NUMBER;
14369 : :
14370 : 1 : ret = test_AES_CBC_HMAC_SHA512_decrypt_perform(
14371 : 1 : sessions[j],
14372 : : &ut_paramz[j].ut_params,
14373 : : ts_params, ut_paramz[j].cipher,
14374 : : ut_paramz[j].digest,
14375 : 1 : ut_paramz[j].iv);
14376 : :
14377 : 1 : rte_crypto_op_free(ut_paramz[j].ut_params.op);
14378 : :
14379 : : /*
14380 : : * free mbuf - both obuf and ibuf are usually the same,
14381 : : * so check if they point at the same address is necessary,
14382 : : * to avoid freeing the mbuf twice.
14383 : : */
14384 [ + - ]: 1 : if (ut_paramz[j].ut_params.obuf) {
14385 : 1 : rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
14386 : 1 : if (ut_paramz[j].ut_params.ibuf
14387 [ + - ]: 1 : == ut_paramz[j].ut_params.obuf)
14388 : 1 : ut_paramz[j].ut_params.ibuf = 0;
14389 : 1 : ut_paramz[j].ut_params.obuf = 0;
14390 : : }
14391 [ - + ]: 1 : if (ut_paramz[j].ut_params.ibuf) {
14392 : 0 : rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
14393 : 0 : ut_paramz[j].ut_params.ibuf = 0;
14394 : : }
14395 : :
14396 [ + - ]: 1 : if (ret != TEST_SKIPPED) {
14397 : 1 : index = i;
14398 : 1 : break;
14399 : : }
14400 : : }
14401 : :
14402 : 0 : session_clear:
14403 [ + + ]: 4 : for (i = 0; i < nb_sess; i++) {
14404 : 3 : rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
14405 : 3 : sessions[i]);
14406 : : }
14407 : :
14408 : 1 : rte_free(sessions);
14409 : :
14410 [ + - ]: 1 : if (ret != TEST_SKIPPED)
14411 [ - + ]: 1 : TEST_ASSERT_SUCCESS(ret, "Failed to perform decrypt on request number %u.", index);
14412 : :
14413 : : return TEST_SUCCESS;
14414 : : }
14415 : :
14416 : : uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
14417 : : 0xab, 0xab, 0xab, 0xab,
14418 : : 0xab, 0xab, 0xab, 0xab,
14419 : : 0xab, 0xab, 0xab, 0xab};
14420 : :
14421 : : static int
14422 : 0 : test_null_invalid_operation(void)
14423 : : {
14424 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14425 : : struct crypto_unittest_params *ut_params = &unittest_params;
14426 : :
14427 : : /* This test is for NULL PMD only */
14428 [ # # ]: 0 : if (gbl_driver_id != rte_cryptodev_driver_id_get(
14429 : : RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
14430 : : return TEST_SKIPPED;
14431 : :
14432 : : /* Setup Cipher Parameters */
14433 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14434 : 0 : ut_params->cipher_xform.next = NULL;
14435 : :
14436 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
14437 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
14438 : :
14439 : : /* Create Crypto session*/
14440 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
14441 : 0 : ts_params->valid_devs[0], &ut_params->cipher_xform,
14442 : : ts_params->session_mpool);
14443 [ # # ]: 0 : TEST_ASSERT(ut_params->sess == NULL,
14444 : : "Session creation succeeded unexpectedly");
14445 : :
14446 : : /* Setup HMAC Parameters */
14447 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14448 : 0 : ut_params->auth_xform.next = NULL;
14449 : :
14450 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
14451 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
14452 : :
14453 : : /* Create Crypto session*/
14454 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
14455 : 0 : ts_params->valid_devs[0], &ut_params->auth_xform,
14456 : : ts_params->session_mpool);
14457 [ # # ]: 0 : TEST_ASSERT(ut_params->sess == NULL,
14458 : : "Session creation succeeded unexpectedly");
14459 : :
14460 : : return TEST_SUCCESS;
14461 : : }
14462 : :
14463 : :
14464 : : #define NULL_BURST_LENGTH (32)
14465 : :
14466 : : static int
14467 : 2 : test_null_burst_operation(void)
14468 : : {
14469 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14470 : : struct crypto_unittest_params *ut_params = &unittest_params;
14471 : :
14472 : : unsigned i, burst_len = NULL_BURST_LENGTH;
14473 : :
14474 : 2 : struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
14475 : 2 : struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
14476 : :
14477 : : /* This test is for NULL PMD only */
14478 [ - + ]: 2 : if (gbl_driver_id != rte_cryptodev_driver_id_get(
14479 : : RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
14480 : : return TEST_SKIPPED;
14481 : :
14482 : : /* Setup Cipher Parameters */
14483 : 0 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
14484 : 0 : ut_params->cipher_xform.next = &ut_params->auth_xform;
14485 : :
14486 : 0 : ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
14487 : 0 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
14488 : :
14489 : : /* Setup HMAC Parameters */
14490 : 0 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14491 : 0 : ut_params->auth_xform.next = NULL;
14492 : :
14493 : 0 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
14494 : 0 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
14495 : :
14496 : : /* Create Crypto session*/
14497 : 0 : ut_params->sess = rte_cryptodev_sym_session_create(
14498 : 0 : ts_params->valid_devs[0],
14499 : : &ut_params->auth_xform,
14500 : : ts_params->session_mpool);
14501 [ # # # # ]: 0 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14502 : : return TEST_SKIPPED;
14503 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
14504 : :
14505 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
14506 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
14507 : : burst_len, "failed to generate burst of crypto ops");
14508 : :
14509 : : /* Generate an operation for each mbuf in burst */
14510 [ # # ]: 0 : for (i = 0; i < burst_len; i++) {
14511 : 0 : struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14512 : :
14513 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
14514 : :
14515 : : unsigned *data = (unsigned *)rte_pktmbuf_append(m,
14516 : : sizeof(unsigned));
14517 : 0 : *data = i;
14518 : :
14519 [ # # ]: 0 : rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
14520 : :
14521 : 0 : burst[i]->sym->m_src = m;
14522 : : }
14523 : :
14524 : : /* Process crypto operation */
14525 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
14526 : : 0, burst, burst_len),
14527 : : burst_len,
14528 : : "Error enqueuing burst");
14529 : :
14530 [ # # ]: 0 : TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
14531 : : 0, burst_dequeued, burst_len),
14532 : : burst_len,
14533 : : "Error dequeuing burst");
14534 : :
14535 : :
14536 [ # # ]: 0 : for (i = 0; i < burst_len; i++) {
14537 [ # # ]: 0 : TEST_ASSERT_EQUAL(
14538 : : *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
14539 : : *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
14540 : : uint32_t *),
14541 : : "data not as expected");
14542 : :
14543 : 0 : rte_pktmbuf_free(burst[i]->sym->m_src);
14544 : 0 : rte_crypto_op_free(burst[i]);
14545 : : }
14546 : :
14547 : : return TEST_SUCCESS;
14548 : : }
14549 : :
14550 : : static uint16_t
14551 : 0 : test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
14552 : : uint16_t nb_ops, void *user_param)
14553 : : {
14554 : : RTE_SET_USED(dev_id);
14555 : : RTE_SET_USED(qp_id);
14556 : : RTE_SET_USED(ops);
14557 : : RTE_SET_USED(user_param);
14558 : :
14559 : : printf("crypto enqueue callback called\n");
14560 : 0 : return nb_ops;
14561 : : }
14562 : :
14563 : : static uint16_t
14564 : 0 : test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
14565 : : uint16_t nb_ops, void *user_param)
14566 : : {
14567 : : RTE_SET_USED(dev_id);
14568 : : RTE_SET_USED(qp_id);
14569 : : RTE_SET_USED(ops);
14570 : : RTE_SET_USED(user_param);
14571 : :
14572 : : printf("crypto dequeue callback called\n");
14573 : 0 : return nb_ops;
14574 : : }
14575 : :
14576 : : /*
14577 : : * Thread using enqueue/dequeue callback with RCU.
14578 : : */
14579 : : static int
14580 : 2 : test_enqdeq_callback_thread(void *arg)
14581 : : {
14582 : : RTE_SET_USED(arg);
14583 : : /* DP thread calls rte_cryptodev_enqueue_burst()/
14584 : : * rte_cryptodev_dequeue_burst() and invokes callback.
14585 : : */
14586 : 2 : test_null_burst_operation();
14587 : 2 : return 0;
14588 : : }
14589 : :
14590 : : static int
14591 : 1 : test_enq_callback_setup(void)
14592 : : {
14593 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14594 : : struct rte_cryptodev_info dev_info;
14595 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
14596 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT
14597 : : };
14598 : :
14599 : : struct rte_cryptodev_cb *cb;
14600 : : uint16_t qp_id = 0;
14601 : :
14602 : : /* Stop the device in case it's started so it can be configured */
14603 : 1 : rte_cryptodev_stop(ts_params->valid_devs[0]);
14604 : :
14605 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14606 : :
14607 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
14608 : : &ts_params->conf),
14609 : : "Failed to configure cryptodev %u",
14610 : : ts_params->valid_devs[0]);
14611 : :
14612 : 1 : qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
14613 : 1 : qp_conf.mp_session = ts_params->session_mpool;
14614 : :
14615 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
14616 : : ts_params->valid_devs[0], qp_id, &qp_conf,
14617 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
14618 : : "Failed test for "
14619 : : "rte_cryptodev_queue_pair_setup: num_inflights "
14620 : : "%u on qp %u on cryptodev %u",
14621 : : qp_conf.nb_descriptors, qp_id,
14622 : : ts_params->valid_devs[0]);
14623 : :
14624 : : /* Test with invalid crypto device */
14625 : 1 : cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
14626 : : qp_id, test_enq_callback, NULL);
14627 [ - + ]: 1 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14628 : : "cryptodev %u did not fail",
14629 : : qp_id, RTE_CRYPTO_MAX_DEVS);
14630 : :
14631 : : /* Test with invalid queue pair */
14632 : 1 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
14633 : 1 : dev_info.max_nb_queue_pairs + 1,
14634 : : test_enq_callback, NULL);
14635 [ - + ]: 1 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14636 : : "cryptodev %u did not fail",
14637 : : dev_info.max_nb_queue_pairs + 1,
14638 : : ts_params->valid_devs[0]);
14639 : :
14640 : : /* Test with NULL callback */
14641 : 1 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
14642 : : qp_id, NULL, NULL);
14643 [ - + ]: 1 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14644 : : "cryptodev %u did not fail",
14645 : : qp_id, ts_params->valid_devs[0]);
14646 : :
14647 : : /* Test with valid configuration */
14648 : 1 : cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
14649 : : qp_id, test_enq_callback, NULL);
14650 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
14651 : : "qp %u on cryptodev %u",
14652 : : qp_id, ts_params->valid_devs[0]);
14653 : :
14654 : 1 : rte_cryptodev_start(ts_params->valid_devs[0]);
14655 : :
14656 : : /* Launch a thread */
14657 : 1 : rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
14658 : : rte_get_next_lcore(-1, 1, 0));
14659 : :
14660 : : /* Wait until reader exited. */
14661 : 1 : rte_eal_mp_wait_lcore();
14662 : :
14663 : : /* Test with invalid crypto device */
14664 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
14665 : : RTE_CRYPTO_MAX_DEVS, qp_id, cb),
14666 : : "Expected call to fail as crypto device is invalid");
14667 : :
14668 : : /* Test with invalid queue pair */
14669 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
14670 : : ts_params->valid_devs[0],
14671 : : dev_info.max_nb_queue_pairs + 1, cb),
14672 : : "Expected call to fail as queue pair is invalid");
14673 : :
14674 : : /* Test with NULL callback */
14675 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
14676 : : ts_params->valid_devs[0], qp_id, NULL),
14677 : : "Expected call to fail as callback is NULL");
14678 : :
14679 : : /* Test with valid configuration */
14680 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
14681 : : ts_params->valid_devs[0], qp_id, cb),
14682 : : "Failed test to remove callback on "
14683 : : "qp %u on cryptodev %u",
14684 : : qp_id, ts_params->valid_devs[0]);
14685 : :
14686 : : return TEST_SUCCESS;
14687 : : }
14688 : :
14689 : : static int
14690 : 1 : test_deq_callback_setup(void)
14691 : : {
14692 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14693 : : struct rte_cryptodev_info dev_info;
14694 : 1 : struct rte_cryptodev_qp_conf qp_conf = {
14695 : : .nb_descriptors = MAX_NUM_OPS_INFLIGHT
14696 : : };
14697 : :
14698 : : struct rte_cryptodev_cb *cb;
14699 : : uint16_t qp_id = 0;
14700 : :
14701 : : /* Stop the device in case it's started so it can be configured */
14702 : 1 : rte_cryptodev_stop(ts_params->valid_devs[0]);
14703 : :
14704 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14705 : :
14706 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
14707 : : &ts_params->conf),
14708 : : "Failed to configure cryptodev %u",
14709 : : ts_params->valid_devs[0]);
14710 : :
14711 : 1 : qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
14712 : 1 : qp_conf.mp_session = ts_params->session_mpool;
14713 : :
14714 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
14715 : : ts_params->valid_devs[0], qp_id, &qp_conf,
14716 : : rte_cryptodev_socket_id(ts_params->valid_devs[0])),
14717 : : "Failed test for "
14718 : : "rte_cryptodev_queue_pair_setup: num_inflights "
14719 : : "%u on qp %u on cryptodev %u",
14720 : : qp_conf.nb_descriptors, qp_id,
14721 : : ts_params->valid_devs[0]);
14722 : :
14723 : : /* Test with invalid crypto device */
14724 : 1 : cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
14725 : : qp_id, test_deq_callback, NULL);
14726 [ - + ]: 1 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14727 : : "cryptodev %u did not fail",
14728 : : qp_id, RTE_CRYPTO_MAX_DEVS);
14729 : :
14730 : : /* Test with invalid queue pair */
14731 : 1 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
14732 : 1 : dev_info.max_nb_queue_pairs + 1,
14733 : : test_deq_callback, NULL);
14734 [ - + ]: 1 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14735 : : "cryptodev %u did not fail",
14736 : : dev_info.max_nb_queue_pairs + 1,
14737 : : ts_params->valid_devs[0]);
14738 : :
14739 : : /* Test with NULL callback */
14740 : 1 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
14741 : : qp_id, NULL, NULL);
14742 [ - + ]: 1 : TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
14743 : : "cryptodev %u did not fail",
14744 : : qp_id, ts_params->valid_devs[0]);
14745 : :
14746 : : /* Test with valid configuration */
14747 : 1 : cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
14748 : : qp_id, test_deq_callback, NULL);
14749 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
14750 : : "qp %u on cryptodev %u",
14751 : : qp_id, ts_params->valid_devs[0]);
14752 : :
14753 : 1 : rte_cryptodev_start(ts_params->valid_devs[0]);
14754 : :
14755 : : /* Launch a thread */
14756 : 1 : rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
14757 : : rte_get_next_lcore(-1, 1, 0));
14758 : :
14759 : : /* Wait until reader exited. */
14760 : 1 : rte_eal_mp_wait_lcore();
14761 : :
14762 : : /* Test with invalid crypto device */
14763 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
14764 : : RTE_CRYPTO_MAX_DEVS, qp_id, cb),
14765 : : "Expected call to fail as crypto device is invalid");
14766 : :
14767 : : /* Test with invalid queue pair */
14768 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
14769 : : ts_params->valid_devs[0],
14770 : : dev_info.max_nb_queue_pairs + 1, cb),
14771 : : "Expected call to fail as queue pair is invalid");
14772 : :
14773 : : /* Test with NULL callback */
14774 [ - + ]: 1 : TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
14775 : : ts_params->valid_devs[0], qp_id, NULL),
14776 : : "Expected call to fail as callback is NULL");
14777 : :
14778 : : /* Test with valid configuration */
14779 [ - + ]: 1 : TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
14780 : : ts_params->valid_devs[0], qp_id, cb),
14781 : : "Failed test to remove callback on "
14782 : : "qp %u on cryptodev %u",
14783 : : qp_id, ts_params->valid_devs[0]);
14784 : :
14785 : : return TEST_SUCCESS;
14786 : : }
14787 : :
14788 : : static void
14789 : : generate_gmac_large_plaintext(uint8_t *data)
14790 : : {
14791 : : uint16_t i;
14792 : :
14793 [ + + + + ]: 4084 : for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
14794 : 4082 : memcpy(&data[i], &data[0], 32);
14795 : : }
14796 : :
14797 : : static int
14798 : 8 : create_gmac_operation(enum rte_crypto_auth_operation op,
14799 : : const struct gmac_test_data *tdata)
14800 : : {
14801 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14802 : : struct crypto_unittest_params *ut_params = &unittest_params;
14803 : : struct rte_crypto_sym_op *sym_op;
14804 : :
14805 : 8 : uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
14806 : :
14807 : : /* Generate Crypto op data structure */
14808 : 8 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14809 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14810 [ - + ]: 8 : TEST_ASSERT_NOT_NULL(ut_params->op,
14811 : : "Failed to allocate symmetric crypto operation struct");
14812 : :
14813 : : sym_op = ut_params->op->sym;
14814 : :
14815 : 16 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
14816 : 8 : ut_params->ibuf, tdata->gmac_tag.len);
14817 [ - + ]: 8 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
14818 : : "no room to append digest");
14819 : :
14820 [ + + ]: 8 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
14821 : : ut_params->ibuf, plaintext_pad_len);
14822 : :
14823 [ + + ]: 8 : if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
14824 : 4 : rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
14825 [ - + ]: 4 : tdata->gmac_tag.len);
14826 : 4 : debug_hexdump(stdout, "digest:",
14827 : 4 : sym_op->auth.digest.data,
14828 : 4 : tdata->gmac_tag.len);
14829 : : }
14830 : :
14831 : 8 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
14832 : : uint8_t *, IV_OFFSET);
14833 : :
14834 [ - + ]: 8 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
14835 : :
14836 : 8 : debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
14837 : :
14838 : 8 : sym_op->cipher.data.length = 0;
14839 : 8 : sym_op->cipher.data.offset = 0;
14840 : :
14841 : 8 : sym_op->auth.data.offset = 0;
14842 : 8 : sym_op->auth.data.length = tdata->plaintext.len;
14843 : :
14844 : 8 : return 0;
14845 : : }
14846 : :
14847 : : static int
14848 : 0 : create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
14849 : : const struct gmac_test_data *tdata,
14850 : : void *digest_mem, uint64_t digest_phys)
14851 : : {
14852 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14853 : : struct crypto_unittest_params *ut_params = &unittest_params;
14854 : : struct rte_crypto_sym_op *sym_op;
14855 : :
14856 : : /* Generate Crypto op data structure */
14857 : 0 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
14858 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
14859 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->op,
14860 : : "Failed to allocate symmetric crypto operation struct");
14861 : :
14862 : : sym_op = ut_params->op->sym;
14863 : :
14864 : 0 : sym_op->auth.digest.data = digest_mem;
14865 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
14866 : : "no room to append digest");
14867 : :
14868 : 0 : sym_op->auth.digest.phys_addr = digest_phys;
14869 : :
14870 [ # # ]: 0 : if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
14871 : 0 : rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
14872 [ # # ]: 0 : tdata->gmac_tag.len);
14873 : 0 : debug_hexdump(stdout, "digest:",
14874 : 0 : sym_op->auth.digest.data,
14875 : 0 : tdata->gmac_tag.len);
14876 : : }
14877 : :
14878 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
14879 : : uint8_t *, IV_OFFSET);
14880 : :
14881 [ # # ]: 0 : rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
14882 : :
14883 : 0 : debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
14884 : :
14885 : 0 : sym_op->cipher.data.length = 0;
14886 : 0 : sym_op->cipher.data.offset = 0;
14887 : :
14888 : 0 : sym_op->auth.data.offset = 0;
14889 : 0 : sym_op->auth.data.length = tdata->plaintext.len;
14890 : :
14891 : 0 : return 0;
14892 : : }
14893 : :
14894 : 8 : static int create_gmac_session(uint8_t dev_id,
14895 : : const struct gmac_test_data *tdata,
14896 : : enum rte_crypto_auth_operation auth_op)
14897 : 8 : {
14898 : 8 : uint8_t auth_key[tdata->key.len];
14899 : :
14900 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14901 : : struct crypto_unittest_params *ut_params = &unittest_params;
14902 : :
14903 : 8 : memcpy(auth_key, tdata->key.data, tdata->key.len);
14904 : :
14905 : 8 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14906 : 8 : ut_params->auth_xform.next = NULL;
14907 : :
14908 : 8 : ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
14909 : 8 : ut_params->auth_xform.auth.op = auth_op;
14910 : 8 : ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
14911 : 8 : ut_params->auth_xform.auth.key.length = tdata->key.len;
14912 : 8 : ut_params->auth_xform.auth.key.data = auth_key;
14913 : 8 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
14914 : 8 : ut_params->auth_xform.auth.iv.length = tdata->iv.len;
14915 : :
14916 : :
14917 : 8 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
14918 : : &ut_params->auth_xform, ts_params->session_mpool);
14919 [ - + - - ]: 8 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
14920 : : return TEST_SKIPPED;
14921 [ - + ]: 8 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
14922 : :
14923 : : return 0;
14924 : : }
14925 : :
14926 : : static int
14927 : 4 : test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
14928 : : {
14929 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
14930 : : struct crypto_unittest_params *ut_params = &unittest_params;
14931 : : struct rte_cryptodev_info dev_info;
14932 : :
14933 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
14934 : 4 : uint64_t feat_flags = dev_info.feature_flags;
14935 : :
14936 [ - + ]: 4 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
14937 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
14938 : : printf("Device doesn't support RAW data-path APIs.\n");
14939 : 0 : return TEST_SKIPPED;
14940 : : }
14941 : :
14942 : : int retval;
14943 : :
14944 : : uint8_t *auth_tag, *plaintext;
14945 : : uint16_t plaintext_pad_len;
14946 : :
14947 [ - + ]: 4 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
14948 : : "No GMAC length in the source data");
14949 : :
14950 : : /* Verify the capabilities */
14951 : : struct rte_cryptodev_sym_capability_idx cap_idx;
14952 : 4 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
14953 : 4 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
14954 [ + - ]: 4 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
14955 : : &cap_idx) == NULL)
14956 : : return TEST_SKIPPED;
14957 : :
14958 : 4 : retval = create_gmac_session(ts_params->valid_devs[0],
14959 : : tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
14960 : :
14961 [ + - ]: 4 : if (retval == TEST_SKIPPED)
14962 : : return TEST_SKIPPED;
14963 [ + - ]: 4 : if (retval < 0)
14964 : : return retval;
14965 : :
14966 [ + + ]: 4 : if (tdata->plaintext.len > MBUF_SIZE)
14967 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
14968 : : else
14969 : 3 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
14970 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
14971 : : "Failed to allocate input buffer in mempool");
14972 : :
14973 [ + + ]: 4 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
14974 : : rte_pktmbuf_tailroom(ut_params->ibuf));
14975 : :
14976 : 4 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
14977 : : /*
14978 : : * Runtime generate the large plain text instead of use hard code
14979 : : * plain text vector. It is done to avoid create huge source file
14980 : : * with the test vector.
14981 : : */
14982 [ + + ]: 4 : if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
14983 : 1 : generate_gmac_large_plaintext(tdata->plaintext.data);
14984 : :
14985 : 4 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14986 : : plaintext_pad_len);
14987 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
14988 : :
14989 : 4 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
14990 : 4 : debug_hexdump(stdout, "plaintext:", plaintext,
14991 : 4 : tdata->plaintext.len);
14992 : :
14993 : 4 : retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
14994 : : tdata);
14995 : :
14996 [ + - ]: 4 : if (retval < 0)
14997 : : return retval;
14998 : :
14999 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15000 : :
15001 : 4 : ut_params->op->sym->m_src = ut_params->ibuf;
15002 : :
15003 [ - + ]: 4 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15004 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15005 : : ut_params->op);
15006 [ - + ]: 4 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15007 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
15008 : : 0);
15009 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15010 : : return retval;
15011 : : } else
15012 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(
15013 : : process_crypto_request(ts_params->valid_devs[0],
15014 : : ut_params->op), "failed to process sym crypto op");
15015 : :
15016 [ - + ]: 4 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15017 : : "crypto op processing failed");
15018 : :
15019 [ - + ]: 4 : if (ut_params->op->sym->m_dst) {
15020 : 0 : auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
15021 : : uint8_t *, plaintext_pad_len);
15022 : : } else {
15023 : 4 : auth_tag = plaintext + plaintext_pad_len;
15024 : : }
15025 : :
15026 : 4 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
15027 : :
15028 [ - + ]: 4 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
15029 : : auth_tag,
15030 : : tdata->gmac_tag.data,
15031 : : tdata->gmac_tag.len,
15032 : : "GMAC Generated auth tag not as expected");
15033 : :
15034 : : return 0;
15035 : : }
15036 : :
15037 : : static int
15038 : 1 : test_AES_GMAC_authentication_test_case_1(void)
15039 : : {
15040 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_1);
15041 : : }
15042 : :
15043 : : static int
15044 : 1 : test_AES_GMAC_authentication_test_case_2(void)
15045 : : {
15046 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_2);
15047 : : }
15048 : :
15049 : : static int
15050 : 1 : test_AES_GMAC_authentication_test_case_3(void)
15051 : : {
15052 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_3);
15053 : : }
15054 : :
15055 : : static int
15056 : 1 : test_AES_GMAC_authentication_test_case_4(void)
15057 : : {
15058 : 1 : return test_AES_GMAC_authentication(&gmac_test_case_4);
15059 : : }
15060 : :
15061 : : static int
15062 : 4 : test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
15063 : : {
15064 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15065 : : struct crypto_unittest_params *ut_params = &unittest_params;
15066 : : int retval;
15067 : : uint32_t plaintext_pad_len;
15068 : : uint8_t *plaintext;
15069 : : struct rte_cryptodev_info dev_info;
15070 : :
15071 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15072 : 4 : uint64_t feat_flags = dev_info.feature_flags;
15073 : :
15074 [ - + ]: 4 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15075 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15076 : : printf("Device doesn't support RAW data-path APIs.\n");
15077 : 0 : return TEST_SKIPPED;
15078 : : }
15079 : :
15080 [ - + ]: 4 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
15081 : : "No GMAC length in the source data");
15082 : :
15083 : : /* Verify the capabilities */
15084 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15085 : 4 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15086 : 4 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
15087 [ + - ]: 4 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15088 : : &cap_idx) == NULL)
15089 : : return TEST_SKIPPED;
15090 : :
15091 : 4 : retval = create_gmac_session(ts_params->valid_devs[0],
15092 : : tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
15093 : :
15094 [ + - ]: 4 : if (retval == TEST_SKIPPED)
15095 : : return TEST_SKIPPED;
15096 [ + - ]: 4 : if (retval < 0)
15097 : : return retval;
15098 : :
15099 [ + + ]: 4 : if (tdata->plaintext.len > MBUF_SIZE)
15100 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
15101 : : else
15102 : 3 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15103 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15104 : : "Failed to allocate input buffer in mempool");
15105 : :
15106 [ + + ]: 4 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15107 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15108 : :
15109 : 4 : plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
15110 : :
15111 : : /*
15112 : : * Runtime generate the large plain text instead of use hard code
15113 : : * plain text vector. It is done to avoid create huge source file
15114 : : * with the test vector.
15115 : : */
15116 [ + + ]: 4 : if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
15117 : 1 : generate_gmac_large_plaintext(tdata->plaintext.data);
15118 : :
15119 : 4 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15120 : : plaintext_pad_len);
15121 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15122 : :
15123 : 4 : memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
15124 : 4 : debug_hexdump(stdout, "plaintext:", plaintext,
15125 : 4 : tdata->plaintext.len);
15126 : :
15127 : 4 : retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
15128 : : tdata);
15129 : :
15130 [ + - ]: 4 : if (retval < 0)
15131 : : return retval;
15132 : :
15133 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15134 : :
15135 : 4 : ut_params->op->sym->m_src = ut_params->ibuf;
15136 : :
15137 [ - + ]: 4 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15138 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15139 : : ut_params->op);
15140 [ - + ]: 4 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15141 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
15142 : : 0);
15143 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15144 : : return retval;
15145 : : } else
15146 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(
15147 : : process_crypto_request(ts_params->valid_devs[0],
15148 : : ut_params->op), "failed to process sym crypto op");
15149 : :
15150 [ - + ]: 4 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15151 : : "crypto op processing failed");
15152 : :
15153 : : return 0;
15154 : :
15155 : : }
15156 : :
15157 : : static int
15158 : 1 : test_AES_GMAC_authentication_verify_test_case_1(void)
15159 : : {
15160 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
15161 : : }
15162 : :
15163 : : static int
15164 : 1 : test_AES_GMAC_authentication_verify_test_case_2(void)
15165 : : {
15166 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
15167 : : }
15168 : :
15169 : : static int
15170 : 1 : test_AES_GMAC_authentication_verify_test_case_3(void)
15171 : : {
15172 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
15173 : : }
15174 : :
15175 : : static int
15176 : 1 : test_AES_GMAC_authentication_verify_test_case_4(void)
15177 : : {
15178 : 1 : return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
15179 : : }
15180 : :
15181 : : static int
15182 : 4 : test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
15183 : : uint32_t fragsz)
15184 : : {
15185 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15186 : : struct crypto_unittest_params *ut_params = &unittest_params;
15187 : : struct rte_cryptodev_info dev_info;
15188 : : uint64_t feature_flags;
15189 : : unsigned int trn_data = 0;
15190 : : void *digest_mem = NULL;
15191 : : uint32_t segs = 1;
15192 : : unsigned int to_trn = 0;
15193 : : struct rte_mbuf *buf = NULL;
15194 : : uint8_t *auth_tag, *plaintext;
15195 : : int retval;
15196 : :
15197 [ - + ]: 4 : TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
15198 : : "No GMAC length in the source data");
15199 : :
15200 : : /* Verify the capabilities */
15201 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15202 : 4 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15203 : 4 : cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
15204 [ + - ]: 4 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15205 : : &cap_idx) == NULL)
15206 : : return TEST_SKIPPED;
15207 : :
15208 : : /* Check for any input SGL support */
15209 : 4 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15210 : 4 : feature_flags = dev_info.feature_flags;
15211 : :
15212 : 4 : if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
15213 [ - + ]: 4 : (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
15214 : : (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
15215 : : return TEST_SKIPPED;
15216 : :
15217 : 0 : if (fragsz > tdata->plaintext.len)
15218 : : fragsz = tdata->plaintext.len;
15219 : :
15220 : 0 : uint16_t plaintext_len = fragsz;
15221 : :
15222 : 0 : retval = create_gmac_session(ts_params->valid_devs[0],
15223 : : tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
15224 : :
15225 [ # # ]: 0 : if (retval == TEST_SKIPPED)
15226 : : return TEST_SKIPPED;
15227 [ # # ]: 0 : if (retval < 0)
15228 : : return retval;
15229 : :
15230 : 0 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15231 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15232 : : "Failed to allocate input buffer in mempool");
15233 : :
15234 : 0 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15235 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15236 : :
15237 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15238 : : plaintext_len);
15239 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15240 : :
15241 : 0 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
15242 : :
15243 : : trn_data += plaintext_len;
15244 : :
15245 : 0 : buf = ut_params->ibuf;
15246 : :
15247 : : /*
15248 : : * Loop until no more fragments
15249 : : */
15250 : :
15251 [ # # ]: 0 : while (trn_data < tdata->plaintext.len) {
15252 : 0 : ++segs;
15253 : 0 : to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
15254 : : (tdata->plaintext.len - trn_data) : fragsz;
15255 : :
15256 : 0 : buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15257 : : buf = buf->next;
15258 : :
15259 : 0 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
15260 : : rte_pktmbuf_tailroom(buf));
15261 : :
15262 : 0 : plaintext = (uint8_t *)rte_pktmbuf_append(buf,
15263 : : to_trn);
15264 : :
15265 [ # # ]: 0 : memcpy(plaintext, tdata->plaintext.data + trn_data,
15266 : : to_trn);
15267 : 0 : trn_data += to_trn;
15268 [ # # ]: 0 : if (trn_data == tdata->plaintext.len)
15269 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
15270 : 0 : tdata->gmac_tag.len);
15271 : : }
15272 [ # # ]: 0 : ut_params->ibuf->nb_segs = segs;
15273 : :
15274 : : /*
15275 : : * Place digest at the end of the last buffer
15276 : : */
15277 : 0 : uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
15278 : :
15279 [ # # ]: 0 : if (!digest_mem) {
15280 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15281 : 0 : + tdata->gmac_tag.len);
15282 : 0 : digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
15283 : : tdata->plaintext.len);
15284 : : }
15285 : :
15286 : 0 : retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
15287 : : tdata, digest_mem, digest_phys);
15288 : :
15289 [ # # ]: 0 : if (retval < 0)
15290 : : return retval;
15291 : :
15292 [ # # ]: 0 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15293 : :
15294 : 0 : ut_params->op->sym->m_src = ut_params->ibuf;
15295 : :
15296 [ # # ]: 0 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
15297 : : return TEST_SKIPPED;
15298 : :
15299 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(
15300 : : process_crypto_request(ts_params->valid_devs[0],
15301 : : ut_params->op), "failed to process sym crypto op");
15302 : :
15303 [ # # ]: 0 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
15304 : : "crypto op processing failed");
15305 : :
15306 : : auth_tag = digest_mem;
15307 : 0 : debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
15308 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
15309 : : auth_tag,
15310 : : tdata->gmac_tag.data,
15311 : : tdata->gmac_tag.len,
15312 : : "GMAC Generated auth tag not as expected");
15313 : :
15314 : : return 0;
15315 : : }
15316 : :
15317 : : /* Segment size not multiple of block size (16B) */
15318 : : static int
15319 : 1 : test_AES_GMAC_authentication_SGL_40B(void)
15320 : : {
15321 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
15322 : : }
15323 : :
15324 : : static int
15325 : 1 : test_AES_GMAC_authentication_SGL_80B(void)
15326 : : {
15327 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
15328 : : }
15329 : :
15330 : : static int
15331 : 1 : test_AES_GMAC_authentication_SGL_2048B(void)
15332 : : {
15333 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
15334 : : }
15335 : :
15336 : : /* Segment size not multiple of block size (16B) */
15337 : : static int
15338 : 1 : test_AES_GMAC_authentication_SGL_2047B(void)
15339 : : {
15340 : 1 : return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
15341 : : }
15342 : :
15343 : : struct test_crypto_vector {
15344 : : enum rte_crypto_cipher_algorithm crypto_algo;
15345 : : unsigned int cipher_offset;
15346 : : unsigned int cipher_len;
15347 : :
15348 : : struct {
15349 : : uint8_t data[64];
15350 : : unsigned int len;
15351 : : } cipher_key;
15352 : :
15353 : : struct {
15354 : : uint8_t data[64];
15355 : : unsigned int len;
15356 : : } iv;
15357 : :
15358 : : struct {
15359 : : const uint8_t *data;
15360 : : unsigned int len;
15361 : : } plaintext;
15362 : :
15363 : : struct {
15364 : : const uint8_t *data;
15365 : : unsigned int len;
15366 : : } ciphertext;
15367 : :
15368 : : enum rte_crypto_auth_algorithm auth_algo;
15369 : : unsigned int auth_offset;
15370 : :
15371 : : struct {
15372 : : uint8_t data[128];
15373 : : unsigned int len;
15374 : : } auth_key;
15375 : :
15376 : : struct {
15377 : : const uint8_t *data;
15378 : : unsigned int len;
15379 : : } aad;
15380 : :
15381 : : struct {
15382 : : uint8_t data[128];
15383 : : unsigned int len;
15384 : : } digest;
15385 : : };
15386 : :
15387 : : static const struct test_crypto_vector
15388 : : hmac_sha1_test_crypto_vector = {
15389 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
15390 : : .plaintext = {
15391 : : .data = plaintext_hash,
15392 : : .len = 512
15393 : : },
15394 : : .auth_key = {
15395 : : .data = {
15396 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
15397 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
15398 : : 0xDE, 0xF4, 0xDE, 0xAD
15399 : : },
15400 : : .len = 20
15401 : : },
15402 : : .digest = {
15403 : : .data = {
15404 : : 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
15405 : : 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
15406 : : 0x3F, 0x91, 0x64, 0x59
15407 : : },
15408 : : .len = 20
15409 : : }
15410 : : };
15411 : :
15412 : : static const struct test_crypto_vector
15413 : : aes128_gmac_test_vector = {
15414 : : .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
15415 : : .plaintext = {
15416 : : .data = plaintext_hash,
15417 : : .len = 512
15418 : : },
15419 : : .iv = {
15420 : : .data = {
15421 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
15422 : : 0x08, 0x09, 0x0A, 0x0B
15423 : : },
15424 : : .len = 12
15425 : : },
15426 : : .auth_key = {
15427 : : .data = {
15428 : : 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
15429 : : 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
15430 : : },
15431 : : .len = 16
15432 : : },
15433 : : .digest = {
15434 : : .data = {
15435 : : 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
15436 : : 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
15437 : : },
15438 : : .len = 16
15439 : : }
15440 : : };
15441 : :
15442 : : static const struct test_crypto_vector
15443 : : aes128cbc_hmac_sha1_test_vector = {
15444 : : .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
15445 : : .cipher_offset = 0,
15446 : : .cipher_len = 512,
15447 : : .cipher_key = {
15448 : : .data = {
15449 : : 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
15450 : : 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
15451 : : },
15452 : : .len = 16
15453 : : },
15454 : : .iv = {
15455 : : .data = {
15456 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
15457 : : 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
15458 : : },
15459 : : .len = 16
15460 : : },
15461 : : .plaintext = {
15462 : : .data = plaintext_hash,
15463 : : .len = 512
15464 : : },
15465 : : .ciphertext = {
15466 : : .data = ciphertext512_aes128cbc,
15467 : : .len = 512
15468 : : },
15469 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
15470 : : .auth_offset = 0,
15471 : : .auth_key = {
15472 : : .data = {
15473 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
15474 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
15475 : : 0xDE, 0xF4, 0xDE, 0xAD
15476 : : },
15477 : : .len = 20
15478 : : },
15479 : : .digest = {
15480 : : .data = {
15481 : : 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
15482 : : 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
15483 : : 0x18, 0x8C, 0x1D, 0x32
15484 : : },
15485 : : .len = 20
15486 : : }
15487 : : };
15488 : :
15489 : : static const struct test_crypto_vector
15490 : : aes128cbc_hmac_sha1_aad_test_vector = {
15491 : : .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
15492 : : .cipher_offset = 8,
15493 : : .cipher_len = 496,
15494 : : .cipher_key = {
15495 : : .data = {
15496 : : 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
15497 : : 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
15498 : : },
15499 : : .len = 16
15500 : : },
15501 : : .iv = {
15502 : : .data = {
15503 : : 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
15504 : : 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
15505 : : },
15506 : : .len = 16
15507 : : },
15508 : : .plaintext = {
15509 : : .data = plaintext_hash,
15510 : : .len = 512
15511 : : },
15512 : : .ciphertext = {
15513 : : .data = ciphertext512_aes128cbc_aad,
15514 : : .len = 512
15515 : : },
15516 : : .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
15517 : : .auth_offset = 0,
15518 : : .auth_key = {
15519 : : .data = {
15520 : : 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
15521 : : 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
15522 : : 0xDE, 0xF4, 0xDE, 0xAD
15523 : : },
15524 : : .len = 20
15525 : : },
15526 : : .digest = {
15527 : : .data = {
15528 : : 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
15529 : : 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
15530 : : 0x62, 0x0F, 0xFB, 0x10
15531 : : },
15532 : : .len = 20
15533 : : }
15534 : : };
15535 : :
15536 : : static void
15537 : : data_corruption(uint8_t *data)
15538 : : {
15539 : 3 : data[0] += 1;
15540 : 3 : }
15541 : :
15542 : : static void
15543 : : tag_corruption(uint8_t *data, unsigned int tag_offset)
15544 : : {
15545 : 3 : data[tag_offset] += 1;
15546 : 3 : }
15547 : :
15548 : : static int
15549 : 2 : create_auth_session(struct crypto_unittest_params *ut_params,
15550 : : uint8_t dev_id,
15551 : : const struct test_crypto_vector *reference,
15552 : : enum rte_crypto_auth_operation auth_op)
15553 : 2 : {
15554 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15555 : 2 : uint8_t auth_key[reference->auth_key.len + 1];
15556 : :
15557 : 2 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
15558 : :
15559 : : /* Setup Authentication Parameters */
15560 : 2 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15561 : 2 : ut_params->auth_xform.auth.op = auth_op;
15562 : 2 : ut_params->auth_xform.next = NULL;
15563 : 2 : ut_params->auth_xform.auth.algo = reference->auth_algo;
15564 : 2 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
15565 : 2 : ut_params->auth_xform.auth.key.data = auth_key;
15566 : 2 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
15567 : :
15568 : : /* Create Crypto session*/
15569 : 2 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
15570 : : &ut_params->auth_xform,
15571 : : ts_params->session_mpool);
15572 [ - + - - ]: 2 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15573 : 0 : return TEST_SKIPPED;
15574 : :
15575 : : return 0;
15576 : : }
15577 : :
15578 : : static int
15579 : 4 : create_auth_cipher_session(struct crypto_unittest_params *ut_params,
15580 : : uint8_t dev_id,
15581 : : const struct test_crypto_vector *reference,
15582 : : enum rte_crypto_auth_operation auth_op,
15583 : : enum rte_crypto_cipher_operation cipher_op)
15584 : 4 : {
15585 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
15586 : 4 : uint8_t cipher_key[reference->cipher_key.len + 1];
15587 : 4 : uint8_t auth_key[reference->auth_key.len + 1];
15588 : :
15589 [ + + ]: 4 : memcpy(cipher_key, reference->cipher_key.data,
15590 : : reference->cipher_key.len);
15591 : 4 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
15592 : :
15593 : : /* Setup Authentication Parameters */
15594 : 4 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15595 : 4 : ut_params->auth_xform.auth.op = auth_op;
15596 : 4 : ut_params->auth_xform.auth.algo = reference->auth_algo;
15597 : 4 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
15598 : 4 : ut_params->auth_xform.auth.key.data = auth_key;
15599 : 4 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
15600 : :
15601 [ + + ]: 4 : if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
15602 : 2 : ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
15603 : 2 : ut_params->auth_xform.auth.iv.length = reference->iv.len;
15604 : : } else {
15605 : 2 : ut_params->auth_xform.next = &ut_params->cipher_xform;
15606 : :
15607 : : /* Setup Cipher Parameters */
15608 : 2 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
15609 : 2 : ut_params->cipher_xform.next = NULL;
15610 : 2 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
15611 : 2 : ut_params->cipher_xform.cipher.op = cipher_op;
15612 : 2 : ut_params->cipher_xform.cipher.key.data = cipher_key;
15613 : 2 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
15614 : 2 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
15615 : 2 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
15616 : : }
15617 : :
15618 : : /* Create Crypto session*/
15619 : 4 : ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
15620 : : &ut_params->auth_xform,
15621 : : ts_params->session_mpool);
15622 [ - + - - ]: 4 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
15623 : 0 : return TEST_SKIPPED;
15624 : :
15625 : : return 0;
15626 : : }
15627 : :
15628 : : static int
15629 : 2 : create_auth_operation(struct crypto_testsuite_params *ts_params,
15630 : : struct crypto_unittest_params *ut_params,
15631 : : const struct test_crypto_vector *reference,
15632 : : unsigned int auth_generate)
15633 : : {
15634 : : /* Generate Crypto op data structure */
15635 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15636 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15637 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
15638 : : "Failed to allocate pktmbuf offload");
15639 : :
15640 : : /* Set crypto operation data parameters */
15641 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15642 : :
15643 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
15644 : :
15645 : : /* set crypto operation source mbuf */
15646 : 2 : sym_op->m_src = ut_params->ibuf;
15647 : :
15648 : : /* digest */
15649 : 4 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
15650 : 2 : ut_params->ibuf, reference->digest.len);
15651 : :
15652 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15653 : : "no room to append auth tag");
15654 : :
15655 [ - + ]: 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
15656 : : ut_params->ibuf, reference->plaintext.len);
15657 : :
15658 [ - + ]: 2 : if (auth_generate)
15659 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
15660 : : else
15661 : 2 : memcpy(sym_op->auth.digest.data,
15662 : 2 : reference->digest.data,
15663 : 2 : reference->digest.len);
15664 : :
15665 : 2 : debug_hexdump(stdout, "digest:",
15666 : 2 : sym_op->auth.digest.data,
15667 : 2 : reference->digest.len);
15668 : :
15669 : 2 : sym_op->auth.data.length = reference->plaintext.len;
15670 : 2 : sym_op->auth.data.offset = 0;
15671 : :
15672 : 2 : return 0;
15673 : : }
15674 : :
15675 : : static int
15676 : 2 : create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
15677 : : struct crypto_unittest_params *ut_params,
15678 : : const struct test_crypto_vector *reference,
15679 : : unsigned int auth_generate)
15680 : : {
15681 : : /* Generate Crypto op data structure */
15682 : 2 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15683 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15684 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->op,
15685 : : "Failed to allocate pktmbuf offload");
15686 : :
15687 : : /* Set crypto operation data parameters */
15688 [ + - ]: 2 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15689 : :
15690 : 2 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
15691 : :
15692 : : /* set crypto operation source mbuf */
15693 : 2 : sym_op->m_src = ut_params->ibuf;
15694 : :
15695 : : /* digest */
15696 : 4 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
15697 : 2 : ut_params->ibuf, reference->digest.len);
15698 : :
15699 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15700 : : "no room to append auth tag");
15701 : :
15702 [ - + ]: 2 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
15703 : : ut_params->ibuf, reference->ciphertext.len);
15704 : :
15705 [ - + ]: 2 : if (auth_generate)
15706 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
15707 : : else
15708 : 2 : memcpy(sym_op->auth.digest.data,
15709 : 2 : reference->digest.data,
15710 : 2 : reference->digest.len);
15711 : :
15712 : 2 : debug_hexdump(stdout, "digest:",
15713 : 2 : sym_op->auth.digest.data,
15714 : 2 : reference->digest.len);
15715 : :
15716 : 2 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
15717 [ - + ]: 2 : reference->iv.data, reference->iv.len);
15718 : :
15719 : 2 : sym_op->cipher.data.length = 0;
15720 : 2 : sym_op->cipher.data.offset = 0;
15721 : :
15722 : 2 : sym_op->auth.data.length = reference->plaintext.len;
15723 : 2 : sym_op->auth.data.offset = 0;
15724 : :
15725 : 2 : return 0;
15726 : : }
15727 : :
15728 : : static int
15729 : 4 : create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
15730 : : struct crypto_unittest_params *ut_params,
15731 : : const struct test_crypto_vector *reference,
15732 : : unsigned int auth_generate)
15733 : : {
15734 : : /* Generate Crypto op data structure */
15735 : 4 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
15736 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
15737 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(ut_params->op,
15738 : : "Failed to allocate pktmbuf offload");
15739 : :
15740 : : /* Set crypto operation data parameters */
15741 [ + - ]: 4 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
15742 : :
15743 : 4 : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
15744 : :
15745 : : /* set crypto operation source mbuf */
15746 : 4 : sym_op->m_src = ut_params->ibuf;
15747 : :
15748 : : /* digest */
15749 : 8 : sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
15750 : 4 : ut_params->ibuf, reference->digest.len);
15751 : :
15752 [ - + ]: 4 : TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
15753 : : "no room to append auth tag");
15754 : :
15755 [ - + ]: 4 : sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
15756 : : ut_params->ibuf, reference->ciphertext.len);
15757 : :
15758 [ - + ]: 4 : if (auth_generate)
15759 : 0 : memset(sym_op->auth.digest.data, 0, reference->digest.len);
15760 : : else
15761 : 4 : memcpy(sym_op->auth.digest.data,
15762 : 4 : reference->digest.data,
15763 : 4 : reference->digest.len);
15764 : :
15765 : 4 : debug_hexdump(stdout, "digest:",
15766 : 4 : sym_op->auth.digest.data,
15767 : 4 : reference->digest.len);
15768 : :
15769 : 4 : rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
15770 [ - + ]: 4 : reference->iv.data, reference->iv.len);
15771 : :
15772 : 4 : sym_op->cipher.data.length = reference->cipher_len;
15773 : 4 : sym_op->cipher.data.offset = reference->cipher_offset;
15774 : :
15775 : 4 : sym_op->auth.data.length = reference->plaintext.len;
15776 : 4 : sym_op->auth.data.offset = reference->auth_offset;
15777 : :
15778 : 4 : return 0;
15779 : : }
15780 : :
15781 : : static int
15782 : : create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
15783 : : struct crypto_unittest_params *ut_params,
15784 : : const struct test_crypto_vector *reference)
15785 : : {
15786 : 2 : return create_auth_operation(ts_params, ut_params, reference, 0);
15787 : : }
15788 : :
15789 : : static int
15790 : : create_auth_verify_GMAC_operation(
15791 : : struct crypto_testsuite_params *ts_params,
15792 : : struct crypto_unittest_params *ut_params,
15793 : : const struct test_crypto_vector *reference)
15794 : : {
15795 : 2 : return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
15796 : : }
15797 : :
15798 : : static int
15799 : : create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
15800 : : struct crypto_unittest_params *ut_params,
15801 : : const struct test_crypto_vector *reference)
15802 : : {
15803 : 3 : return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
15804 : : }
15805 : :
15806 : : static int
15807 : 2 : test_authentication_verify_fail_when_data_corruption(
15808 : : struct crypto_testsuite_params *ts_params,
15809 : : struct crypto_unittest_params *ut_params,
15810 : : const struct test_crypto_vector *reference,
15811 : : unsigned int data_corrupted)
15812 : : {
15813 : : int retval;
15814 : :
15815 : : uint8_t *plaintext;
15816 : : struct rte_cryptodev_info dev_info;
15817 : :
15818 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15819 : 2 : uint64_t feat_flags = dev_info.feature_flags;
15820 : :
15821 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15822 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15823 : : printf("Device doesn't support RAW data-path APIs.\n");
15824 : 0 : return TEST_SKIPPED;
15825 : : }
15826 : :
15827 : : /* Verify the capabilities */
15828 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15829 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15830 : 2 : cap_idx.algo.auth = reference->auth_algo;
15831 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15832 : : &cap_idx) == NULL)
15833 : : return TEST_SKIPPED;
15834 : :
15835 : :
15836 : : /* Create session */
15837 : 2 : retval = create_auth_session(ut_params,
15838 : 2 : ts_params->valid_devs[0],
15839 : : reference,
15840 : : RTE_CRYPTO_AUTH_OP_VERIFY);
15841 : :
15842 [ + - ]: 2 : if (retval == TEST_SKIPPED)
15843 : : return TEST_SKIPPED;
15844 [ + - ]: 2 : if (retval < 0)
15845 : : return retval;
15846 : :
15847 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15848 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15849 : : "Failed to allocate input buffer in mempool");
15850 : :
15851 : : /* clear mbuf payload */
15852 : 2 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15853 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15854 : :
15855 : 2 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15856 : 2 : reference->plaintext.len);
15857 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15858 : 2 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
15859 : :
15860 : 2 : debug_hexdump(stdout, "plaintext:", plaintext,
15861 : 2 : reference->plaintext.len);
15862 : :
15863 : : /* Create operation */
15864 : : retval = create_auth_verify_operation(ts_params, ut_params, reference);
15865 : :
15866 [ + - ]: 2 : if (retval < 0)
15867 : : return retval;
15868 : :
15869 [ + + ]: 2 : if (data_corrupted)
15870 : : data_corruption(plaintext);
15871 : : else
15872 : 1 : tag_corruption(plaintext, reference->plaintext.len);
15873 : :
15874 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
15875 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15876 : : ut_params->op);
15877 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
15878 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
15879 : : "authentication not failed");
15880 [ - + ]: 2 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15881 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
15882 : : 0);
15883 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15884 : : return retval;
15885 : : } else {
15886 : 2 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
15887 : : ut_params->op);
15888 : : }
15889 [ - + ]: 2 : if (ut_params->op == NULL)
15890 : : return 0;
15891 [ # # ]: 0 : else if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
15892 : 0 : return 0;
15893 : :
15894 : : return -1;
15895 : : }
15896 : :
15897 : : static int
15898 : 2 : test_authentication_verify_GMAC_fail_when_corruption(
15899 : : struct crypto_testsuite_params *ts_params,
15900 : : struct crypto_unittest_params *ut_params,
15901 : : const struct test_crypto_vector *reference,
15902 : : unsigned int data_corrupted)
15903 : : {
15904 : : int retval;
15905 : : uint8_t *plaintext;
15906 : : struct rte_cryptodev_info dev_info;
15907 : :
15908 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15909 : 2 : uint64_t feat_flags = dev_info.feature_flags;
15910 : :
15911 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
15912 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
15913 : : printf("Device doesn't support RAW data-path APIs.\n");
15914 : 0 : return TEST_SKIPPED;
15915 : : }
15916 : :
15917 : : /* Verify the capabilities */
15918 : : struct rte_cryptodev_sym_capability_idx cap_idx;
15919 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
15920 : 2 : cap_idx.algo.auth = reference->auth_algo;
15921 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
15922 : : &cap_idx) == NULL)
15923 : : return TEST_SKIPPED;
15924 : :
15925 : : /* Create session */
15926 : 2 : retval = create_auth_cipher_session(ut_params,
15927 : 2 : ts_params->valid_devs[0],
15928 : : reference,
15929 : : RTE_CRYPTO_AUTH_OP_VERIFY,
15930 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
15931 [ + - ]: 2 : if (retval == TEST_SKIPPED)
15932 : : return TEST_SKIPPED;
15933 [ + - ]: 2 : if (retval < 0)
15934 : : return retval;
15935 : :
15936 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
15937 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
15938 : : "Failed to allocate input buffer in mempool");
15939 : :
15940 : : /* clear mbuf payload */
15941 : 2 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
15942 : : rte_pktmbuf_tailroom(ut_params->ibuf));
15943 : :
15944 : 2 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
15945 : 2 : reference->plaintext.len);
15946 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
15947 : 2 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
15948 : :
15949 : 2 : debug_hexdump(stdout, "plaintext:", plaintext,
15950 : 2 : reference->plaintext.len);
15951 : :
15952 : : /* Create operation */
15953 : : retval = create_auth_verify_GMAC_operation(ts_params,
15954 : : ut_params,
15955 : : reference);
15956 : :
15957 [ + - ]: 2 : if (retval < 0)
15958 : : return retval;
15959 : :
15960 [ + + ]: 2 : if (data_corrupted)
15961 : : data_corruption(plaintext);
15962 : : else
15963 : 1 : tag_corruption(plaintext, reference->aad.len);
15964 : :
15965 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
15966 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
15967 : : ut_params->op);
15968 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
15969 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
15970 : : "authentication not failed");
15971 [ - + ]: 2 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
15972 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 1, 0,
15973 : : 0);
15974 [ # # ]: 0 : if (retval != TEST_SUCCESS)
15975 : 0 : return retval;
15976 : : } else {
15977 : 2 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
15978 : : ut_params->op);
15979 [ - + ]: 2 : TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
15980 : : }
15981 : :
15982 : : return 0;
15983 : : }
15984 : :
15985 : : static int
15986 : 2 : test_authenticated_decryption_fail_when_corruption(
15987 : : struct crypto_testsuite_params *ts_params,
15988 : : struct crypto_unittest_params *ut_params,
15989 : : const struct test_crypto_vector *reference,
15990 : : unsigned int data_corrupted)
15991 : : {
15992 : : int retval;
15993 : :
15994 : : uint8_t *ciphertext;
15995 : : struct rte_cryptodev_info dev_info;
15996 : :
15997 : 2 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
15998 : 2 : uint64_t feat_flags = dev_info.feature_flags;
15999 : :
16000 [ - + ]: 2 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16001 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16002 : : printf("Device doesn't support RAW data-path APIs.\n");
16003 : 0 : return TEST_SKIPPED;
16004 : : }
16005 : :
16006 : : /* Verify the capabilities */
16007 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16008 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16009 : 2 : cap_idx.algo.auth = reference->auth_algo;
16010 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16011 : : &cap_idx) == NULL)
16012 : : return TEST_SKIPPED;
16013 : 2 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16014 : 2 : cap_idx.algo.cipher = reference->crypto_algo;
16015 [ + - ]: 2 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16016 : : &cap_idx) == NULL)
16017 : : return TEST_SKIPPED;
16018 : :
16019 : : /* Create session */
16020 : 2 : retval = create_auth_cipher_session(ut_params,
16021 : 2 : ts_params->valid_devs[0],
16022 : : reference,
16023 : : RTE_CRYPTO_AUTH_OP_VERIFY,
16024 : : RTE_CRYPTO_CIPHER_OP_DECRYPT);
16025 [ + - ]: 2 : if (retval == TEST_SKIPPED)
16026 : : return TEST_SKIPPED;
16027 [ + - ]: 2 : if (retval < 0)
16028 : : return retval;
16029 : :
16030 : 2 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16031 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16032 : : "Failed to allocate input buffer in mempool");
16033 : :
16034 : : /* clear mbuf payload */
16035 : 2 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16036 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16037 : :
16038 : 2 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16039 : 2 : reference->ciphertext.len);
16040 [ - + ]: 2 : TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
16041 : 2 : memcpy(ciphertext, reference->ciphertext.data,
16042 : 2 : reference->ciphertext.len);
16043 : :
16044 : : /* Create operation */
16045 : : retval = create_cipher_auth_verify_operation(ts_params,
16046 : : ut_params,
16047 : : reference);
16048 : :
16049 [ + - ]: 2 : if (retval < 0)
16050 : : return retval;
16051 : :
16052 [ + + ]: 2 : if (data_corrupted)
16053 : : data_corruption(ciphertext);
16054 : : else
16055 : 1 : tag_corruption(ciphertext, reference->ciphertext.len);
16056 : :
16057 [ - + ]: 2 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
16058 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16059 : : ut_params->op);
16060 [ # # ]: 0 : TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
16061 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
16062 : : "authentication not failed");
16063 [ - + ]: 2 : } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16064 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
16065 : : 0);
16066 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16067 : 0 : return retval;
16068 : : } else {
16069 : 2 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16070 : : ut_params->op);
16071 [ - + ]: 2 : TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
16072 : : }
16073 : :
16074 : : return 0;
16075 : : }
16076 : :
16077 : : static int
16078 : 1 : test_authenticated_encrypt_with_esn(
16079 : : struct crypto_testsuite_params *ts_params,
16080 : : struct crypto_unittest_params *ut_params,
16081 : : const struct test_crypto_vector *reference)
16082 : 1 : {
16083 : : int retval;
16084 : :
16085 : : uint8_t *authciphertext, *plaintext, *auth_tag;
16086 : : uint16_t plaintext_pad_len;
16087 : 1 : uint8_t cipher_key[reference->cipher_key.len + 1];
16088 : 1 : uint8_t auth_key[reference->auth_key.len + 1];
16089 : : struct rte_cryptodev_info dev_info;
16090 : :
16091 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16092 : 1 : uint64_t feat_flags = dev_info.feature_flags;
16093 : :
16094 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16095 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16096 : : printf("Device doesn't support RAW data-path APIs.\n");
16097 : 0 : return TEST_SKIPPED;
16098 : : }
16099 : :
16100 : : /* Verify the capabilities */
16101 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16102 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16103 : 1 : cap_idx.algo.auth = reference->auth_algo;
16104 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16105 : : &cap_idx) == NULL)
16106 : : return TEST_SKIPPED;
16107 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16108 : 1 : cap_idx.algo.cipher = reference->crypto_algo;
16109 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16110 : : &cap_idx) == NULL)
16111 : : return TEST_SKIPPED;
16112 : :
16113 : : /* Create session */
16114 : 1 : memcpy(cipher_key, reference->cipher_key.data,
16115 : 1 : reference->cipher_key.len);
16116 : 1 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16117 : :
16118 : : /* Setup Cipher Parameters */
16119 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16120 : 1 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
16121 : 1 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
16122 : 1 : ut_params->cipher_xform.cipher.key.data = cipher_key;
16123 : 1 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
16124 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
16125 : 1 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
16126 : :
16127 : 1 : ut_params->cipher_xform.next = &ut_params->auth_xform;
16128 : :
16129 : : /* Setup Authentication Parameters */
16130 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16131 : 1 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
16132 : 1 : ut_params->auth_xform.auth.algo = reference->auth_algo;
16133 : 1 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16134 : 1 : ut_params->auth_xform.auth.key.data = auth_key;
16135 : 1 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
16136 : 1 : ut_params->auth_xform.next = NULL;
16137 : :
16138 : : /* Create Crypto session*/
16139 : 2 : ut_params->sess = rte_cryptodev_sym_session_create(
16140 : 1 : ts_params->valid_devs[0], &ut_params->cipher_xform,
16141 : : ts_params->session_mpool);
16142 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16143 : : return TEST_SKIPPED;
16144 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16145 : :
16146 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16147 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16148 : : "Failed to allocate input buffer in mempool");
16149 : :
16150 : : /* clear mbuf payload */
16151 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16152 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16153 : :
16154 : 1 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16155 : 1 : reference->plaintext.len);
16156 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
16157 : 1 : memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
16158 : :
16159 : : /* Create operation */
16160 : 1 : retval = create_cipher_auth_operation(ts_params,
16161 : : ut_params,
16162 : : reference, 0);
16163 : :
16164 [ + - ]: 1 : if (retval < 0)
16165 : : return retval;
16166 : :
16167 [ - + ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
16168 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16169 : : ut_params->op);
16170 [ - + ]: 1 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16171 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
16172 : : 0);
16173 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16174 : : return retval;
16175 : : } else
16176 : 1 : ut_params->op = process_crypto_request(
16177 : 1 : ts_params->valid_devs[0], ut_params->op);
16178 : :
16179 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
16180 : :
16181 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
16182 : : "crypto op processing failed");
16183 : :
16184 : 1 : plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
16185 : :
16186 : 1 : authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
16187 : : ut_params->op->sym->auth.data.offset);
16188 : 1 : auth_tag = authciphertext + plaintext_pad_len;
16189 : 1 : debug_hexdump(stdout, "ciphertext:", authciphertext,
16190 : 1 : reference->ciphertext.len);
16191 : 1 : debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
16192 : :
16193 : : /* Validate obuf */
16194 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
16195 : : authciphertext,
16196 : : reference->ciphertext.data,
16197 : : reference->ciphertext.len,
16198 : : "Ciphertext data not as expected");
16199 : :
16200 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
16201 : : auth_tag,
16202 : : reference->digest.data,
16203 : : reference->digest.len,
16204 : : "Generated digest not as expected");
16205 : :
16206 : : return TEST_SUCCESS;
16207 : :
16208 : : }
16209 : :
16210 : : static int
16211 : 1 : test_authenticated_decrypt_with_esn(
16212 : : struct crypto_testsuite_params *ts_params,
16213 : : struct crypto_unittest_params *ut_params,
16214 : : const struct test_crypto_vector *reference)
16215 : 1 : {
16216 : : int retval;
16217 : :
16218 : : uint8_t *ciphertext;
16219 : 1 : uint8_t cipher_key[reference->cipher_key.len + 1];
16220 : 1 : uint8_t auth_key[reference->auth_key.len + 1];
16221 : : struct rte_cryptodev_info dev_info;
16222 : :
16223 : 1 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16224 : 1 : uint64_t feat_flags = dev_info.feature_flags;
16225 : :
16226 [ - + ]: 1 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16227 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16228 : : printf("Device doesn't support RAW data-path APIs.\n");
16229 : 0 : return TEST_SKIPPED;
16230 : : }
16231 : :
16232 : : /* Verify the capabilities */
16233 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16234 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16235 : 1 : cap_idx.algo.auth = reference->auth_algo;
16236 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16237 : : &cap_idx) == NULL)
16238 : : return TEST_SKIPPED;
16239 : 1 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16240 : 1 : cap_idx.algo.cipher = reference->crypto_algo;
16241 [ + - ]: 1 : if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
16242 : : &cap_idx) == NULL)
16243 : : return TEST_SKIPPED;
16244 : :
16245 : : /* Create session */
16246 : 1 : memcpy(cipher_key, reference->cipher_key.data,
16247 : 1 : reference->cipher_key.len);
16248 : 1 : memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
16249 : :
16250 : : /* Setup Authentication Parameters */
16251 : 1 : ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
16252 : 1 : ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
16253 : 1 : ut_params->auth_xform.auth.algo = reference->auth_algo;
16254 : 1 : ut_params->auth_xform.auth.key.length = reference->auth_key.len;
16255 : 1 : ut_params->auth_xform.auth.key.data = auth_key;
16256 : 1 : ut_params->auth_xform.auth.digest_length = reference->digest.len;
16257 : 1 : ut_params->auth_xform.next = &ut_params->cipher_xform;
16258 : :
16259 : : /* Setup Cipher Parameters */
16260 : 1 : ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
16261 : 1 : ut_params->cipher_xform.next = NULL;
16262 : 1 : ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
16263 : 1 : ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
16264 : 1 : ut_params->cipher_xform.cipher.key.data = cipher_key;
16265 : 1 : ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
16266 : 1 : ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
16267 : 1 : ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
16268 : :
16269 : : /* Create Crypto session*/
16270 : 2 : ut_params->sess = rte_cryptodev_sym_session_create(
16271 : 1 : ts_params->valid_devs[0], &ut_params->auth_xform,
16272 : : ts_params->session_mpool);
16273 [ - + - - ]: 1 : if (ut_params->sess == NULL && rte_errno == ENOTSUP)
16274 : : return TEST_SKIPPED;
16275 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
16276 : :
16277 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16278 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->ibuf,
16279 : : "Failed to allocate input buffer in mempool");
16280 : :
16281 : : /* clear mbuf payload */
16282 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16283 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16284 : :
16285 : 1 : ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16286 : 1 : reference->ciphertext.len);
16287 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
16288 : 1 : memcpy(ciphertext, reference->ciphertext.data,
16289 : 1 : reference->ciphertext.len);
16290 : :
16291 : : /* Create operation */
16292 : : retval = create_cipher_auth_verify_operation(ts_params,
16293 : : ut_params,
16294 : : reference);
16295 : :
16296 [ + - ]: 1 : if (retval < 0)
16297 : : return retval;
16298 : :
16299 [ - + ]: 1 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
16300 : 0 : process_cpu_crypt_auth_op(ts_params->valid_devs[0],
16301 : : ut_params->op);
16302 [ - + ]: 1 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16303 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 1, 1, 0,
16304 : : 0);
16305 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16306 : : return retval;
16307 : : } else
16308 : 1 : ut_params->op = process_crypto_request(ts_params->valid_devs[0],
16309 : : ut_params->op);
16310 : :
16311 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
16312 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status,
16313 : : RTE_CRYPTO_OP_STATUS_SUCCESS,
16314 : : "crypto op processing passed");
16315 : :
16316 : 1 : ut_params->obuf = ut_params->op->sym->m_src;
16317 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
16318 : :
16319 : : return 0;
16320 : : }
16321 : :
16322 : : static int
16323 : 1 : create_aead_operation_SGL(enum rte_crypto_aead_operation op,
16324 : : const struct aead_test_data *tdata,
16325 : : void *digest_mem, uint64_t digest_phys)
16326 : : {
16327 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
16328 : : struct crypto_unittest_params *ut_params = &unittest_params;
16329 : :
16330 : 1 : const unsigned int auth_tag_len = tdata->auth_tag.len;
16331 : 1 : const unsigned int iv_len = tdata->iv.len;
16332 : 1 : unsigned int aad_len = tdata->aad.len;
16333 : : unsigned int aad_len_pad = 0;
16334 : :
16335 : : /* Generate Crypto op data structure */
16336 : 1 : ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
16337 : : RTE_CRYPTO_OP_TYPE_SYMMETRIC);
16338 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(ut_params->op,
16339 : : "Failed to allocate symmetric crypto operation struct");
16340 : :
16341 : : struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
16342 : :
16343 : 1 : sym_op->aead.digest.data = digest_mem;
16344 : :
16345 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
16346 : : "no room to append digest");
16347 : :
16348 : 1 : sym_op->aead.digest.phys_addr = digest_phys;
16349 : :
16350 [ - + ]: 1 : if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
16351 [ # # ]: 0 : rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
16352 : : auth_tag_len);
16353 : 0 : debug_hexdump(stdout, "digest:",
16354 : 0 : sym_op->aead.digest.data,
16355 : : auth_tag_len);
16356 : : }
16357 : :
16358 : : /* Append aad data */
16359 [ - + ]: 1 : if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
16360 : 0 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
16361 : : uint8_t *, IV_OFFSET);
16362 : :
16363 : : /* Copy IV 1 byte after the IV pointer, according to the API */
16364 [ # # ]: 0 : rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
16365 : :
16366 : 0 : aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
16367 : :
16368 [ # # ]: 0 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
16369 : : ut_params->ibuf, aad_len);
16370 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
16371 : : "no room to prepend aad");
16372 [ # # ]: 0 : sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
16373 : : ut_params->ibuf);
16374 : :
16375 [ # # ]: 0 : memset(sym_op->aead.aad.data, 0, aad_len);
16376 : : /* Copy AAD 18 bytes after the AAD pointer, according to the API */
16377 [ # # ]: 0 : rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
16378 : :
16379 : 0 : debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
16380 : 0 : debug_hexdump(stdout, "aad:",
16381 : 0 : sym_op->aead.aad.data, aad_len);
16382 : : } else {
16383 : 1 : uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
16384 : : uint8_t *, IV_OFFSET);
16385 : :
16386 [ - + ]: 1 : rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
16387 : :
16388 : 1 : aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
16389 : :
16390 [ + - ]: 1 : sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
16391 : : ut_params->ibuf, aad_len_pad);
16392 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
16393 : : "no room to prepend aad");
16394 [ - + ]: 1 : sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
16395 : : ut_params->ibuf);
16396 : :
16397 [ - + ]: 1 : memset(sym_op->aead.aad.data, 0, aad_len);
16398 [ - + ]: 1 : rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
16399 : :
16400 : 1 : debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
16401 : 1 : debug_hexdump(stdout, "aad:",
16402 : 1 : sym_op->aead.aad.data, aad_len);
16403 : : }
16404 : :
16405 : 1 : sym_op->aead.data.length = tdata->plaintext.len;
16406 : 1 : sym_op->aead.data.offset = aad_len_pad;
16407 : :
16408 : 1 : return 0;
16409 : : }
16410 : :
16411 : : #define SGL_MAX_NO 16
16412 : :
16413 : : static int
16414 : 3 : test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
16415 : : const int oop, uint32_t fragsz, uint32_t fragsz_oop)
16416 : : {
16417 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
16418 : : struct crypto_unittest_params *ut_params = &unittest_params;
16419 : : struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
16420 : : int retval;
16421 : : int to_trn = 0;
16422 : : int to_trn_tbl[SGL_MAX_NO];
16423 : : int segs = 1;
16424 : : unsigned int trn_data = 0;
16425 : : uint8_t *plaintext, *ciphertext, *auth_tag;
16426 : : struct rte_cryptodev_info dev_info;
16427 : :
16428 : : /* Verify the capabilities */
16429 : : struct rte_cryptodev_sym_capability_idx cap_idx;
16430 : : const struct rte_cryptodev_symmetric_capability *capability;
16431 : 3 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
16432 : 3 : cap_idx.algo.aead = tdata->algo;
16433 : 3 : capability = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0], &cap_idx);
16434 [ + - ]: 3 : if (capability == NULL)
16435 : : return TEST_SKIPPED;
16436 [ + - ]: 3 : if (rte_cryptodev_sym_capability_check_aead(capability, tdata->key.len,
16437 : 3 : tdata->auth_tag.len, tdata->aad.len, tdata->iv.len))
16438 : : return TEST_SKIPPED;
16439 : :
16440 : : /*
16441 : : * SGL not supported on AESNI_MB PMD CPU crypto,
16442 : : * OOP not supported on AESNI_GCM CPU crypto
16443 : : */
16444 [ - + ]: 3 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO &&
16445 [ # # ]: 0 : (gbl_driver_id == rte_cryptodev_driver_id_get(
16446 [ # # ]: 0 : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) || oop))
16447 : : return TEST_SKIPPED;
16448 : :
16449 : : /* Detailed check for the particular SGL support flag */
16450 : 3 : rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
16451 [ - + ]: 3 : if (!oop) {
16452 : 0 : unsigned int sgl_in = fragsz < tdata->plaintext.len;
16453 [ # # # # ]: 0 : if (sgl_in && (!(dev_info.feature_flags &
16454 : : RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
16455 : : return TEST_SKIPPED;
16456 : :
16457 : 0 : uint64_t feat_flags = dev_info.feature_flags;
16458 : :
16459 [ # # ]: 0 : if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
16460 [ # # ]: 0 : (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
16461 : : printf("Device doesn't support RAW data-path APIs.\n");
16462 : 0 : return TEST_SKIPPED;
16463 : : }
16464 : : } else {
16465 : 3 : unsigned int sgl_in = fragsz < tdata->plaintext.len;
16466 [ - + ]: 3 : unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
16467 : : tdata->plaintext.len;
16468 : : /* Raw data path API does not support OOP */
16469 [ + - ]: 3 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
16470 : : return TEST_SKIPPED;
16471 [ + + ]: 3 : if (sgl_in && !sgl_out) {
16472 [ + - ]: 1 : if (!(dev_info.feature_flags &
16473 : : RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
16474 : : return TEST_SKIPPED;
16475 [ - + ]: 2 : } else if (!sgl_in && sgl_out) {
16476 [ # # ]: 0 : if (!(dev_info.feature_flags &
16477 : : RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
16478 : : return TEST_SKIPPED;
16479 [ + - ]: 2 : } else if (sgl_in && sgl_out) {
16480 [ - + ]: 2 : if (!(dev_info.feature_flags &
16481 : : RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
16482 : : return TEST_SKIPPED;
16483 : : }
16484 : : }
16485 : :
16486 : 1 : if (fragsz > tdata->plaintext.len)
16487 : : fragsz = tdata->plaintext.len;
16488 : :
16489 : 1 : uint16_t plaintext_len = fragsz;
16490 [ + - ]: 1 : uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
16491 : :
16492 [ - + ]: 1 : if (fragsz_oop > tdata->plaintext.len)
16493 : 0 : frag_size_oop = tdata->plaintext.len;
16494 : :
16495 : : int ecx = 0;
16496 : : void *digest_mem = NULL;
16497 : :
16498 : 1 : uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
16499 : :
16500 [ + - ]: 1 : if (tdata->plaintext.len % fragsz != 0) {
16501 [ + - ]: 1 : if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
16502 : : return 1;
16503 : : } else {
16504 [ # # ]: 0 : if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
16505 : : return 1;
16506 : : }
16507 : :
16508 : : /*
16509 : : * For out-op-place we need to alloc another mbuf
16510 : : */
16511 [ + - ]: 1 : if (oop) {
16512 : 1 : ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16513 : : rte_pktmbuf_append(ut_params->obuf,
16514 : 1 : frag_size_oop + prepend_len);
16515 : 1 : buf_oop = ut_params->obuf;
16516 : : }
16517 : :
16518 : : /* Create AEAD session */
16519 : 1 : retval = create_aead_session(ts_params->valid_devs[0],
16520 : 1 : tdata->algo,
16521 : : RTE_CRYPTO_AEAD_OP_ENCRYPT,
16522 : 1 : tdata->key.data, tdata->key.len,
16523 : 1 : tdata->aad.len, tdata->auth_tag.len,
16524 : 1 : tdata->iv.len);
16525 [ + - ]: 1 : if (retval < 0)
16526 : : return retval;
16527 : :
16528 : 1 : ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16529 : :
16530 : : /* clear mbuf payload */
16531 : 1 : memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
16532 : : rte_pktmbuf_tailroom(ut_params->ibuf));
16533 : :
16534 : 1 : plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16535 : : plaintext_len);
16536 : :
16537 : 1 : memcpy(plaintext, tdata->plaintext.data, plaintext_len);
16538 : :
16539 : : trn_data += plaintext_len;
16540 : :
16541 : 1 : buf = ut_params->ibuf;
16542 : :
16543 : : /*
16544 : : * Loop until no more fragments
16545 : : */
16546 : :
16547 [ + + ]: 6 : while (trn_data < tdata->plaintext.len) {
16548 : 5 : ++segs;
16549 : 5 : to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
16550 : 5 : (tdata->plaintext.len - trn_data) : fragsz;
16551 : :
16552 : 5 : to_trn_tbl[ecx++] = to_trn;
16553 : :
16554 [ - + ]: 5 : buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
16555 : : buf = buf->next;
16556 : :
16557 [ - + ]: 5 : memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
16558 : : rte_pktmbuf_tailroom(buf));
16559 : :
16560 : : /* OOP */
16561 [ - + ]: 5 : if (oop && !fragsz_oop) {
16562 : 0 : buf_last_oop = buf_oop->next =
16563 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
16564 : : buf_oop = buf_oop->next;
16565 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
16566 : : 0, rte_pktmbuf_tailroom(buf_oop));
16567 : 0 : rte_pktmbuf_append(buf_oop, to_trn);
16568 : : }
16569 : :
16570 : 5 : plaintext = (uint8_t *)rte_pktmbuf_append(buf,
16571 : : to_trn);
16572 : :
16573 [ + + ]: 5 : memcpy(plaintext, tdata->plaintext.data + trn_data,
16574 : : to_trn);
16575 : 5 : trn_data += to_trn;
16576 [ + + ]: 5 : if (trn_data == tdata->plaintext.len) {
16577 [ + - ]: 1 : if (oop) {
16578 [ - + ]: 1 : if (!fragsz_oop)
16579 : 0 : digest_mem = rte_pktmbuf_append(buf_oop,
16580 : 0 : tdata->auth_tag.len);
16581 : : } else
16582 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
16583 : 0 : tdata->auth_tag.len);
16584 : : }
16585 : : }
16586 : :
16587 : : uint64_t digest_phys = 0;
16588 : :
16589 : 1 : ut_params->ibuf->nb_segs = segs;
16590 : :
16591 : : segs = 1;
16592 [ + - ]: 1 : if (fragsz_oop && oop) {
16593 : : to_trn = 0;
16594 : : ecx = 0;
16595 : :
16596 [ + - ]: 1 : if (frag_size_oop == tdata->plaintext.len) {
16597 : 1 : digest_mem = rte_pktmbuf_append(ut_params->obuf,
16598 : 1 : tdata->auth_tag.len);
16599 : :
16600 : 1 : digest_phys = rte_pktmbuf_iova_offset(
16601 : : ut_params->obuf,
16602 : : tdata->plaintext.len + prepend_len);
16603 : : }
16604 : :
16605 : : trn_data = frag_size_oop;
16606 [ - + ]: 1 : while (trn_data < tdata->plaintext.len) {
16607 : 0 : ++segs;
16608 : 0 : to_trn =
16609 : 0 : (tdata->plaintext.len - trn_data <
16610 : : frag_size_oop) ?
16611 : 0 : (tdata->plaintext.len - trn_data) :
16612 : : frag_size_oop;
16613 : :
16614 : 0 : to_trn_tbl[ecx++] = to_trn;
16615 : :
16616 : 0 : buf_last_oop = buf_oop->next =
16617 : 0 : rte_pktmbuf_alloc(ts_params->mbuf_pool);
16618 : : buf_oop = buf_oop->next;
16619 : 0 : memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
16620 : : 0, rte_pktmbuf_tailroom(buf_oop));
16621 : 0 : rte_pktmbuf_append(buf_oop, to_trn);
16622 : :
16623 : 0 : trn_data += to_trn;
16624 : :
16625 [ # # ]: 0 : if (trn_data == tdata->plaintext.len) {
16626 : 0 : digest_mem = rte_pktmbuf_append(buf_oop,
16627 : 0 : tdata->auth_tag.len);
16628 : : }
16629 : : }
16630 : :
16631 : 1 : ut_params->obuf->nb_segs = segs;
16632 : : }
16633 : :
16634 : : /*
16635 : : * Place digest at the end of the last buffer
16636 : : */
16637 [ - + ]: 1 : if (!digest_phys)
16638 : 0 : digest_phys = rte_pktmbuf_iova(buf) + to_trn;
16639 [ - + ]: 1 : if (oop && buf_last_oop)
16640 : 0 : digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
16641 : :
16642 [ - + ]: 1 : if (!digest_mem && !oop) {
16643 : 0 : digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
16644 : 0 : + tdata->auth_tag.len);
16645 : 0 : digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
16646 : : tdata->plaintext.len);
16647 : : }
16648 : :
16649 : : /* Create AEAD operation */
16650 : 1 : retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
16651 : : tdata, digest_mem, digest_phys);
16652 : :
16653 [ + - ]: 1 : if (retval < 0)
16654 : : return retval;
16655 : :
16656 [ + - ]: 1 : rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
16657 : :
16658 : 1 : ut_params->op->sym->m_src = ut_params->ibuf;
16659 [ + - ]: 1 : if (oop)
16660 : 1 : ut_params->op->sym->m_dst = ut_params->obuf;
16661 : :
16662 : : /* Process crypto operation */
16663 [ - + ]: 1 : if (oop == IN_PLACE &&
16664 [ # # ]: 0 : gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
16665 : 0 : process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
16666 [ - + ]: 1 : else if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
16667 : 0 : retval = process_sym_raw_dp_op(ts_params->valid_devs[0], 0, ut_params->op, 0, 0, 0,
16668 : : 0);
16669 [ # # ]: 0 : if (retval != TEST_SUCCESS)
16670 : : return retval;
16671 : : } else
16672 [ - + ]: 1 : TEST_ASSERT_NOT_NULL(
16673 : : process_crypto_request(ts_params->valid_devs[0],
16674 : : ut_params->op), "failed to process sym crypto op");
16675 : :
16676 [ - + ]: 1 : TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
16677 : : "crypto op processing failed");
16678 : :
16679 : :
16680 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
16681 : : uint8_t *, prepend_len);
16682 [ + - ]: 1 : if (oop) {
16683 : 1 : ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
16684 : : uint8_t *, prepend_len);
16685 : : }
16686 : :
16687 [ + - ]: 1 : if (fragsz_oop)
16688 : : fragsz = fragsz_oop;
16689 : :
16690 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
16691 : : ciphertext,
16692 : : tdata->ciphertext.data,
16693 : : fragsz,
16694 : : "Ciphertext data not as expected");
16695 : :
16696 : 1 : buf = ut_params->op->sym->m_src->next;
16697 [ + - ]: 1 : if (oop)
16698 : 1 : buf = ut_params->op->sym->m_dst->next;
16699 : :
16700 : : unsigned int off = fragsz;
16701 : :
16702 : : ecx = 0;
16703 [ - + ]: 1 : while (buf) {
16704 : 0 : ciphertext = rte_pktmbuf_mtod(buf,
16705 : : uint8_t *);
16706 : :
16707 [ # # ]: 0 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
16708 : : ciphertext,
16709 : : tdata->ciphertext.data + off,
16710 : : to_trn_tbl[ecx],
16711 : : "Ciphertext data not as expected");
16712 : :
16713 : 0 : off += to_trn_tbl[ecx++];
16714 : 0 : buf = buf->next;
16715 : : }
16716 : :
16717 : : auth_tag = digest_mem;
16718 [ - + ]: 1 : TEST_ASSERT_BUFFERS_ARE_EQUAL(
16719 : : auth_tag,
16720 : : tdata->auth_tag.data,
16721 : : tdata->auth_tag.len,
16722 : : "Generated auth tag not as expected");
16723 : :
16724 : : return 0;
16725 : : }
16726 : :
16727 : : static int
16728 : 1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
16729 : : {
16730 : 1 : return test_authenticated_encryption_SGL(
16731 : : &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
16732 : : }
16733 : :
16734 : : static int
16735 : 1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
16736 : : {
16737 : 1 : return test_authenticated_encryption_SGL(
16738 : : &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
16739 : : }
16740 : :
16741 : : static int
16742 : 1 : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
16743 : : {
16744 : 1 : return test_authenticated_encryption_SGL(
16745 : : &gcm_test_case_8, OUT_OF_PLACE, 400,
16746 : : gcm_test_case_8.plaintext.len);
16747 : : }
16748 : :
16749 : : static int
16750 : 1 : test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
16751 : : {
16752 : : /* This test is not for OPENSSL PMD */
16753 [ - + ]: 1 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
16754 : : RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
16755 : : return TEST_SKIPPED;
16756 : :
16757 : 0 : return test_authenticated_encryption_SGL(
16758 : : &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
16759 : : }
16760 : :
16761 : : static int
16762 : : test_authentication_verify_fail_when_data_corrupted(
16763 : : struct crypto_testsuite_params *ts_params,
16764 : : struct crypto_unittest_params *ut_params,
16765 : : const struct test_crypto_vector *reference)
16766 : : {
16767 : 1 : return test_authentication_verify_fail_when_data_corruption(
16768 : : ts_params, ut_params, reference, 1);
16769 : : }
16770 : :
16771 : : static int
16772 : : test_authentication_verify_fail_when_tag_corrupted(
16773 : : struct crypto_testsuite_params *ts_params,
16774 : : struct crypto_unittest_params *ut_params,
16775 : : const struct test_crypto_vector *reference)
16776 : : {
16777 : 1 : return test_authentication_verify_fail_when_data_corruption(
16778 : : ts_params, ut_params, reference, 0);
16779 : : }
16780 : :
16781 : : static int
16782 : : test_authentication_verify_GMAC_fail_when_data_corrupted(
16783 : : struct crypto_testsuite_params *ts_params,
16784 : : struct crypto_unittest_params *ut_params,
16785 : : const struct test_crypto_vector *reference)
16786 : : {
16787 : 1 : return test_authentication_verify_GMAC_fail_when_corruption(
16788 : : ts_params, ut_params, reference, 1);
16789 : : }
16790 : :
16791 : : static int
16792 : : test_authentication_verify_GMAC_fail_when_tag_corrupted(
16793 : : struct crypto_testsuite_params *ts_params,
16794 : : struct crypto_unittest_params *ut_params,
16795 : : const struct test_crypto_vector *reference)
16796 : : {
16797 : 1 : return test_authentication_verify_GMAC_fail_when_corruption(
16798 : : ts_params, ut_params, reference, 0);
16799 : : }
16800 : :
16801 : : static int
16802 : : test_authenticated_decryption_fail_when_data_corrupted(
16803 : : struct crypto_testsuite_params *ts_params,
16804 : : struct crypto_unittest_params *ut_params,
16805 : : const struct test_crypto_vector *reference)
16806 : : {
16807 : 1 : return test_authenticated_decryption_fail_when_corruption(
16808 : : ts_params, ut_params, reference, 1);
16809 : : }
16810 : :
16811 : : static int
16812 : : test_authenticated_decryption_fail_when_tag_corrupted(
16813 : : struct crypto_testsuite_params *ts_params,
16814 : : struct crypto_unittest_params *ut_params,
16815 : : const struct test_crypto_vector *reference)
16816 : : {
16817 : 1 : return test_authenticated_decryption_fail_when_corruption(
16818 : : ts_params, ut_params, reference, 0);
16819 : : }
16820 : :
16821 : : static int
16822 : 1 : authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
16823 : : {
16824 : 1 : return test_authentication_verify_fail_when_data_corrupted(
16825 : : &testsuite_params, &unittest_params,
16826 : : &hmac_sha1_test_crypto_vector);
16827 : : }
16828 : :
16829 : : static int
16830 : 1 : authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
16831 : : {
16832 : 1 : return test_authentication_verify_fail_when_tag_corrupted(
16833 : : &testsuite_params, &unittest_params,
16834 : : &hmac_sha1_test_crypto_vector);
16835 : : }
16836 : :
16837 : : static int
16838 : 1 : authentication_verify_AES128_GMAC_fail_data_corrupt(void)
16839 : : {
16840 : 1 : return test_authentication_verify_GMAC_fail_when_data_corrupted(
16841 : : &testsuite_params, &unittest_params,
16842 : : &aes128_gmac_test_vector);
16843 : : }
16844 : :
16845 : : static int
16846 : 1 : authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
16847 : : {
16848 : 1 : return test_authentication_verify_GMAC_fail_when_tag_corrupted(
16849 : : &testsuite_params, &unittest_params,
16850 : : &aes128_gmac_test_vector);
16851 : : }
16852 : :
16853 : : static int
16854 : 1 : auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
16855 : : {
16856 : 1 : return test_authenticated_decryption_fail_when_data_corrupted(
16857 : : &testsuite_params,
16858 : : &unittest_params,
16859 : : &aes128cbc_hmac_sha1_test_vector);
16860 : : }
16861 : :
16862 : : static int
16863 : 1 : auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
16864 : : {
16865 : 1 : return test_authenticated_decryption_fail_when_tag_corrupted(
16866 : : &testsuite_params,
16867 : : &unittest_params,
16868 : : &aes128cbc_hmac_sha1_test_vector);
16869 : : }
16870 : :
16871 : : static int
16872 : 1 : auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
16873 : : {
16874 : 1 : return test_authenticated_encrypt_with_esn(
16875 : : &testsuite_params,
16876 : : &unittest_params,
16877 : : &aes128cbc_hmac_sha1_aad_test_vector);
16878 : : }
16879 : :
16880 : : static int
16881 : 1 : auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
16882 : : {
16883 : 1 : return test_authenticated_decrypt_with_esn(
16884 : : &testsuite_params,
16885 : : &unittest_params,
16886 : : &aes128cbc_hmac_sha1_aad_test_vector);
16887 : : }
16888 : :
16889 : : static int
16890 : 0 : test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
16891 : : {
16892 : 0 : return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
16893 : : }
16894 : :
16895 : : static int
16896 : 0 : test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
16897 : : {
16898 : 0 : return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
16899 : : }
16900 : :
16901 : : static int
16902 : 0 : test_chacha20_poly1305_encrypt_SGL_out_of_place(void)
16903 : : {
16904 : 0 : return test_authenticated_encryption_SGL(
16905 : : &chacha20_poly1305_case_2, OUT_OF_PLACE, 32,
16906 : : chacha20_poly1305_case_2.plaintext.len);
16907 : : }
16908 : :
16909 : : #ifdef RTE_CRYPTO_SCHEDULER
16910 : :
16911 : : /* global AESNI worker IDs for the scheduler test */
16912 : : uint8_t aesni_ids[2];
16913 : :
16914 : : static int
16915 : 0 : scheduler_testsuite_setup(void)
16916 : : {
16917 : : uint32_t i = 0;
16918 : : int32_t nb_devs, ret;
16919 : 0 : char vdev_args[VDEV_ARGS_SIZE] = {""};
16920 : 0 : char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
16921 : : "ordering=enable,name=cryptodev_test_scheduler,corelist="};
16922 : : uint16_t worker_core_count = 0;
16923 : : uint16_t socket_id = 0;
16924 : :
16925 [ # # ]: 0 : if (gbl_driver_id == rte_cryptodev_driver_id_get(
16926 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
16927 : :
16928 : : /* Identify the Worker Cores
16929 : : * Use 2 worker cores for the device args
16930 : : */
16931 [ # # ]: 0 : RTE_LCORE_FOREACH_WORKER(i) {
16932 [ # # ]: 0 : if (worker_core_count > 1)
16933 : : break;
16934 : : snprintf(vdev_args, sizeof(vdev_args),
16935 : : "%s%d", temp_str, i);
16936 : : strcpy(temp_str, vdev_args);
16937 : 0 : strlcat(temp_str, ";", sizeof(temp_str));
16938 : 0 : worker_core_count++;
16939 : 0 : socket_id = rte_lcore_to_socket_id(i);
16940 : : }
16941 [ # # ]: 0 : if (worker_core_count != 2) {
16942 : 0 : RTE_LOG(ERR, USER1,
16943 : : "Cryptodev scheduler test require at least "
16944 : : "two worker cores to run. "
16945 : : "Please use the correct coremask.\n");
16946 : 0 : return TEST_FAILED;
16947 : : }
16948 : : strcpy(temp_str, vdev_args);
16949 : 0 : snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
16950 : : temp_str, socket_id);
16951 : 0 : RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
16952 : 0 : nb_devs = rte_cryptodev_device_count_by_driver(
16953 : 0 : rte_cryptodev_driver_id_get(
16954 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
16955 [ # # ]: 0 : if (nb_devs < 1) {
16956 : 0 : ret = rte_vdev_init(
16957 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
16958 : : vdev_args);
16959 [ # # ]: 0 : TEST_ASSERT(ret == 0,
16960 : : "Failed to create instance %u of pmd : %s",
16961 : : i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
16962 : : }
16963 : : }
16964 : 0 : return testsuite_setup();
16965 : : }
16966 : :
16967 : : static int
16968 : 0 : test_scheduler_attach_worker_op(void)
16969 : : {
16970 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
16971 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
16972 : : uint32_t i, nb_devs_attached = 0;
16973 : : int ret;
16974 : : char vdev_name[32];
16975 : 0 : unsigned int count = rte_cryptodev_count();
16976 : :
16977 : : /* create 2 AESNI_MB vdevs on top of existing devices */
16978 [ # # ]: 0 : for (i = count; i < count + 2; i++) {
16979 : : snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
16980 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
16981 : : i);
16982 : 0 : ret = rte_vdev_init(vdev_name, NULL);
16983 : :
16984 [ # # ]: 0 : TEST_ASSERT(ret == 0,
16985 : : "Failed to create instance %u of"
16986 : : " pmd : %s",
16987 : : i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
16988 : :
16989 : : if (ret < 0) {
16990 : : RTE_LOG(ERR, USER1,
16991 : : "Failed to create 2 AESNI MB PMDs.\n");
16992 : : return TEST_SKIPPED;
16993 : : }
16994 : : }
16995 : :
16996 : : /* attach 2 AESNI_MB cdevs */
16997 [ # # ]: 0 : for (i = count; i < count + 2; i++) {
16998 : : struct rte_cryptodev_info info;
16999 : : unsigned int session_size;
17000 : :
17001 : 0 : rte_cryptodev_info_get(i, &info);
17002 [ # # ]: 0 : if (info.driver_id != rte_cryptodev_driver_id_get(
17003 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
17004 : 0 : continue;
17005 : :
17006 : 0 : session_size = rte_cryptodev_sym_get_private_session_size(i);
17007 : : /*
17008 : : * Create the session mempool again, since now there are new devices
17009 : : * to use the mempool.
17010 : : */
17011 [ # # ]: 0 : if (ts_params->session_mpool) {
17012 : 0 : rte_mempool_free(ts_params->session_mpool);
17013 : 0 : ts_params->session_mpool = NULL;
17014 : : }
17015 : :
17016 [ # # ]: 0 : if (info.sym.max_nb_sessions != 0 &&
17017 : : info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
17018 : 0 : RTE_LOG(ERR, USER1,
17019 : : "Device does not support "
17020 : : "at least %u sessions\n",
17021 : : MAX_NB_SESSIONS);
17022 : 0 : return TEST_FAILED;
17023 : : }
17024 : : /*
17025 : : * Create mempool with maximum number of sessions,
17026 : : * to include the session headers
17027 : : */
17028 [ # # ]: 0 : if (ts_params->session_mpool == NULL) {
17029 : 0 : ts_params->session_mpool =
17030 : 0 : rte_cryptodev_sym_session_pool_create(
17031 : : "test_sess_mp",
17032 : : MAX_NB_SESSIONS, session_size,
17033 : : 0, 0, SOCKET_ID_ANY);
17034 [ # # ]: 0 : TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
17035 : : "session mempool allocation failed");
17036 : : }
17037 : :
17038 : 0 : ts_params->qp_conf.mp_session = ts_params->session_mpool;
17039 : :
17040 : 0 : ret = rte_cryptodev_scheduler_worker_attach(sched_id,
17041 : : (uint8_t)i);
17042 : :
17043 [ # # ]: 0 : TEST_ASSERT(ret == 0,
17044 : : "Failed to attach device %u of pmd : %s", i,
17045 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
17046 : :
17047 : 0 : aesni_ids[nb_devs_attached] = (uint8_t)i;
17048 : :
17049 : 0 : nb_devs_attached++;
17050 : : }
17051 : :
17052 : : return 0;
17053 : : }
17054 : :
17055 : : static int
17056 : 0 : test_scheduler_detach_worker_op(void)
17057 : : {
17058 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
17059 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
17060 : : uint32_t i;
17061 : : int ret;
17062 : :
17063 [ # # ]: 0 : for (i = 0; i < 2; i++) {
17064 : 0 : ret = rte_cryptodev_scheduler_worker_detach(sched_id,
17065 : 0 : aesni_ids[i]);
17066 [ # # ]: 0 : TEST_ASSERT(ret == 0,
17067 : : "Failed to detach device %u", aesni_ids[i]);
17068 : : }
17069 : :
17070 : : return 0;
17071 : : }
17072 : :
17073 : : static int
17074 : : test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
17075 : : {
17076 : : struct crypto_testsuite_params *ts_params = &testsuite_params;
17077 : 0 : uint8_t sched_id = ts_params->valid_devs[0];
17078 : : /* set mode */
17079 : 0 : return rte_cryptodev_scheduler_mode_set(sched_id,
17080 : : scheduler_mode);
17081 : : }
17082 : :
17083 : : static int
17084 : 0 : test_scheduler_mode_roundrobin_op(void)
17085 : : {
17086 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
17087 : : 0, "Failed to set roundrobin mode");
17088 : : return 0;
17089 : :
17090 : : }
17091 : :
17092 : : static int
17093 : 0 : test_scheduler_mode_multicore_op(void)
17094 : : {
17095 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
17096 : : 0, "Failed to set multicore mode");
17097 : :
17098 : : return 0;
17099 : : }
17100 : :
17101 : : static int
17102 : 0 : test_scheduler_mode_failover_op(void)
17103 : : {
17104 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
17105 : : 0, "Failed to set failover mode");
17106 : :
17107 : : return 0;
17108 : : }
17109 : :
17110 : : static int
17111 : 0 : test_scheduler_mode_pkt_size_distr_op(void)
17112 : : {
17113 [ # # ]: 0 : TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
17114 : : 0, "Failed to set pktsize mode");
17115 : :
17116 : : return 0;
17117 : : }
17118 : :
17119 : : static int
17120 : 0 : scheduler_multicore_testsuite_setup(void)
17121 : : {
17122 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
17123 : : return TEST_SKIPPED;
17124 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
17125 : 0 : return TEST_SKIPPED;
17126 : : return 0;
17127 : : }
17128 : :
17129 : : static int
17130 : 0 : scheduler_roundrobin_testsuite_setup(void)
17131 : : {
17132 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
17133 : : return TEST_SKIPPED;
17134 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
17135 : 0 : return TEST_SKIPPED;
17136 : : return 0;
17137 : : }
17138 : :
17139 : : static int
17140 : 0 : scheduler_failover_testsuite_setup(void)
17141 : : {
17142 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
17143 : : return TEST_SKIPPED;
17144 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
17145 : 0 : return TEST_SKIPPED;
17146 : : return 0;
17147 : : }
17148 : :
17149 : : static int
17150 : 0 : scheduler_pkt_size_distr_testsuite_setup(void)
17151 : : {
17152 [ # # ]: 0 : if (test_scheduler_attach_worker_op() < 0)
17153 : : return TEST_SKIPPED;
17154 [ # # ]: 0 : if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
17155 : 0 : return TEST_SKIPPED;
17156 : : return 0;
17157 : : }
17158 : :
17159 : : static void
17160 : 0 : scheduler_mode_testsuite_teardown(void)
17161 : : {
17162 : 0 : test_scheduler_detach_worker_op();
17163 : 0 : }
17164 : :
17165 : : #endif /* RTE_CRYPTO_SCHEDULER */
17166 : :
17167 : : static struct unit_test_suite end_testsuite = {
17168 : : .suite_name = NULL,
17169 : : .setup = NULL,
17170 : : .teardown = NULL,
17171 : : .unit_test_suites = NULL
17172 : : };
17173 : :
17174 : : #ifdef RTE_LIB_SECURITY
17175 : : static struct unit_test_suite ipsec_proto_testsuite = {
17176 : : .suite_name = "IPsec Proto Unit Test Suite",
17177 : : .setup = ipsec_proto_testsuite_setup,
17178 : : .unit_test_cases = {
17179 : : TEST_CASE_NAMED_WITH_DATA(
17180 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
17181 : : ut_setup_security, ut_teardown,
17182 : : test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
17183 : : TEST_CASE_NAMED_WITH_DATA(
17184 : : "Outbound known vector ext_mbuf mode (ESP tunnel mode IPv4 AES-GCM 128)",
17185 : : ut_setup_security, ut_teardown,
17186 : : test_ipsec_proto_known_vec_ext_mbuf, &pkt_aes_128_gcm),
17187 : : TEST_CASE_NAMED_WITH_DATA(
17188 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
17189 : : ut_setup_security, ut_teardown,
17190 : : test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
17191 : : TEST_CASE_NAMED_WITH_DATA(
17192 : : "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
17193 : : ut_setup_security, ut_teardown,
17194 : : test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
17195 : : TEST_CASE_NAMED_WITH_DATA(
17196 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
17197 : : ut_setup_security, ut_teardown,
17198 : : test_ipsec_proto_known_vec, &pkt_aes_256_ccm),
17199 : : TEST_CASE_NAMED_WITH_DATA(
17200 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
17201 : : ut_setup_security, ut_teardown,
17202 : : test_ipsec_proto_known_vec,
17203 : : &pkt_aes_128_cbc_md5),
17204 : : TEST_CASE_NAMED_WITH_DATA(
17205 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
17206 : : ut_setup_security, ut_teardown,
17207 : : test_ipsec_proto_known_vec,
17208 : : &pkt_aes_128_cbc_hmac_sha256),
17209 : : TEST_CASE_NAMED_WITH_DATA(
17210 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
17211 : : ut_setup_security, ut_teardown,
17212 : : test_ipsec_proto_known_vec,
17213 : : &pkt_aes_128_cbc_hmac_sha384),
17214 : : TEST_CASE_NAMED_WITH_DATA(
17215 : : "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
17216 : : ut_setup_security, ut_teardown,
17217 : : test_ipsec_proto_known_vec,
17218 : : &pkt_aes_128_cbc_hmac_sha512),
17219 : : TEST_CASE_NAMED_WITH_DATA(
17220 : : "Outbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
17221 : : ut_setup_security, ut_teardown,
17222 : : test_ipsec_proto_known_vec, &pkt_aes_256_gcm_v6),
17223 : : TEST_CASE_NAMED_WITH_DATA(
17224 : : "Outbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
17225 : : ut_setup_security, ut_teardown,
17226 : : test_ipsec_proto_known_vec,
17227 : : &pkt_aes_128_cbc_hmac_sha256_v6),
17228 : : TEST_CASE_NAMED_WITH_DATA(
17229 : : "Outbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
17230 : : ut_setup_security, ut_teardown,
17231 : : test_ipsec_proto_known_vec,
17232 : : &pkt_null_aes_xcbc),
17233 : : TEST_CASE_NAMED_WITH_DATA(
17234 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
17235 : : ut_setup_security, ut_teardown,
17236 : : test_ipsec_proto_known_vec,
17237 : : &pkt_des_cbc_hmac_sha256),
17238 : : TEST_CASE_NAMED_WITH_DATA(
17239 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
17240 : : ut_setup_security, ut_teardown,
17241 : : test_ipsec_proto_known_vec,
17242 : : &pkt_des_cbc_hmac_sha384),
17243 : : TEST_CASE_NAMED_WITH_DATA(
17244 : : "Outbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
17245 : : ut_setup_security, ut_teardown,
17246 : : test_ipsec_proto_known_vec,
17247 : : &pkt_des_cbc_hmac_sha512),
17248 : : TEST_CASE_NAMED_WITH_DATA(
17249 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
17250 : : ut_setup_security, ut_teardown,
17251 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256),
17252 : : TEST_CASE_NAMED_WITH_DATA(
17253 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
17254 : : ut_setup_security, ut_teardown,
17255 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha384),
17256 : : TEST_CASE_NAMED_WITH_DATA(
17257 : : "Outbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
17258 : : ut_setup_security, ut_teardown,
17259 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha512),
17260 : : TEST_CASE_NAMED_WITH_DATA(
17261 : : "Outbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
17262 : : ut_setup_security, ut_teardown,
17263 : : test_ipsec_proto_known_vec,
17264 : : &pkt_des_cbc_hmac_sha256_v6),
17265 : : TEST_CASE_NAMED_WITH_DATA(
17266 : : "Outbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
17267 : : ut_setup_security, ut_teardown,
17268 : : test_ipsec_proto_known_vec, &pkt_3des_cbc_hmac_sha256_v6),
17269 : : TEST_CASE_NAMED_WITH_DATA(
17270 : : "Outbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
17271 : : ut_setup_security, ut_teardown,
17272 : : test_ipsec_proto_known_vec,
17273 : : &pkt_ah_tunnel_sha256),
17274 : : TEST_CASE_NAMED_WITH_DATA(
17275 : : "Outbound known vector (AH transport mode IPv4 HMAC-SHA256)",
17276 : : ut_setup_security, ut_teardown,
17277 : : test_ipsec_proto_known_vec,
17278 : : &pkt_ah_transport_sha256),
17279 : : TEST_CASE_NAMED_WITH_DATA(
17280 : : "Outbound known vector (AH transport mode IPv4 AES-GMAC 128)",
17281 : : ut_setup_security, ut_teardown,
17282 : : test_ipsec_proto_known_vec,
17283 : : &pkt_ah_ipv4_aes_gmac_128),
17284 : : TEST_CASE_NAMED_WITH_DATA(
17285 : : "Outbound fragmented packet",
17286 : : ut_setup_security, ut_teardown,
17287 : : test_ipsec_proto_known_vec_fragmented,
17288 : : &pkt_aes_128_gcm_frag),
17289 : : TEST_CASE_NAMED_WITH_DATA(
17290 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
17291 : : ut_setup_security, ut_teardown,
17292 : : test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
17293 : : TEST_CASE_NAMED_WITH_DATA(
17294 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
17295 : : ut_setup_security, ut_teardown,
17296 : : test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
17297 : : TEST_CASE_NAMED_WITH_DATA(
17298 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
17299 : : ut_setup_security, ut_teardown,
17300 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
17301 : : TEST_CASE_NAMED_WITH_DATA(
17302 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CCM 256)",
17303 : : ut_setup_security, ut_teardown,
17304 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_ccm),
17305 : : TEST_CASE_NAMED_WITH_DATA(
17306 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128)",
17307 : : ut_setup_security, ut_teardown,
17308 : : test_ipsec_proto_known_vec_inb, &pkt_aes_128_cbc_null),
17309 : : TEST_CASE_NAMED_WITH_DATA(
17310 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC MD5 [12B ICV])",
17311 : : ut_setup_security, ut_teardown,
17312 : : test_ipsec_proto_known_vec_inb,
17313 : : &pkt_aes_128_cbc_md5),
17314 : : TEST_CASE_NAMED_WITH_DATA(
17315 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
17316 : : ut_setup_security, ut_teardown,
17317 : : test_ipsec_proto_known_vec_inb,
17318 : : &pkt_aes_128_cbc_hmac_sha256),
17319 : : TEST_CASE_NAMED_WITH_DATA(
17320 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
17321 : : ut_setup_security, ut_teardown,
17322 : : test_ipsec_proto_known_vec_inb,
17323 : : &pkt_aes_128_cbc_hmac_sha384),
17324 : : TEST_CASE_NAMED_WITH_DATA(
17325 : : "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
17326 : : ut_setup_security, ut_teardown,
17327 : : test_ipsec_proto_known_vec_inb,
17328 : : &pkt_aes_128_cbc_hmac_sha512),
17329 : : TEST_CASE_NAMED_WITH_DATA(
17330 : : "Inbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
17331 : : ut_setup_security, ut_teardown,
17332 : : test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm_v6),
17333 : : TEST_CASE_NAMED_WITH_DATA(
17334 : : "Inbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
17335 : : ut_setup_security, ut_teardown,
17336 : : test_ipsec_proto_known_vec_inb,
17337 : : &pkt_aes_128_cbc_hmac_sha256_v6),
17338 : : TEST_CASE_NAMED_WITH_DATA(
17339 : : "Inbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
17340 : : ut_setup_security, ut_teardown,
17341 : : test_ipsec_proto_known_vec_inb,
17342 : : &pkt_null_aes_xcbc),
17343 : : TEST_CASE_NAMED_WITH_DATA(
17344 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA256 [16B ICV])",
17345 : : ut_setup_security, ut_teardown,
17346 : : test_ipsec_proto_known_vec_inb,
17347 : : &pkt_des_cbc_hmac_sha256),
17348 : : TEST_CASE_NAMED_WITH_DATA(
17349 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA384 [24B ICV])",
17350 : : ut_setup_security, ut_teardown,
17351 : : test_ipsec_proto_known_vec_inb,
17352 : : &pkt_des_cbc_hmac_sha384),
17353 : : TEST_CASE_NAMED_WITH_DATA(
17354 : : "Inbound known vector (ESP tunnel mode IPv4 DES-CBC HMAC-SHA512 [32B ICV])",
17355 : : ut_setup_security, ut_teardown,
17356 : : test_ipsec_proto_known_vec_inb,
17357 : : &pkt_des_cbc_hmac_sha512),
17358 : : TEST_CASE_NAMED_WITH_DATA(
17359 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA256 [16B ICV])",
17360 : : ut_setup_security, ut_teardown,
17361 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256),
17362 : : TEST_CASE_NAMED_WITH_DATA(
17363 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA384 [24B ICV])",
17364 : : ut_setup_security, ut_teardown,
17365 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha384),
17366 : : TEST_CASE_NAMED_WITH_DATA(
17367 : : "Inbound known vector (ESP tunnel mode IPv4 3DES-CBC HMAC-SHA512 [32B ICV])",
17368 : : ut_setup_security, ut_teardown,
17369 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha512),
17370 : : TEST_CASE_NAMED_WITH_DATA(
17371 : : "Inbound known vector (ESP tunnel mode IPv6 DES-CBC HMAC-SHA256 [16B ICV])",
17372 : : ut_setup_security, ut_teardown,
17373 : : test_ipsec_proto_known_vec_inb,
17374 : : &pkt_des_cbc_hmac_sha256_v6),
17375 : : TEST_CASE_NAMED_WITH_DATA(
17376 : : "Inbound known vector (ESP tunnel mode IPv6 3DES-CBC HMAC-SHA256 [16B ICV])",
17377 : : ut_setup_security, ut_teardown,
17378 : : test_ipsec_proto_known_vec_inb, &pkt_3des_cbc_hmac_sha256_v6),
17379 : : TEST_CASE_NAMED_WITH_DATA(
17380 : : "Inbound known vector (AH tunnel mode IPv4 HMAC-SHA256)",
17381 : : ut_setup_security, ut_teardown,
17382 : : test_ipsec_proto_known_vec_inb,
17383 : : &pkt_ah_tunnel_sha256),
17384 : : TEST_CASE_NAMED_WITH_DATA(
17385 : : "Inbound known vector (AH transport mode IPv4 HMAC-SHA256)",
17386 : : ut_setup_security, ut_teardown,
17387 : : test_ipsec_proto_known_vec_inb,
17388 : : &pkt_ah_transport_sha256),
17389 : : TEST_CASE_NAMED_WITH_DATA(
17390 : : "Inbound known vector (AH transport mode IPv4 AES-GMAC 128)",
17391 : : ut_setup_security, ut_teardown,
17392 : : test_ipsec_proto_known_vec_inb,
17393 : : &pkt_ah_ipv4_aes_gmac_128),
17394 : : TEST_CASE_NAMED_ST(
17395 : : "Combined test alg list",
17396 : : ut_setup_security, ut_teardown,
17397 : : test_ipsec_proto_display_list),
17398 : : TEST_CASE_NAMED_ST(
17399 : : "Combined test alg list (AH)",
17400 : : ut_setup_security, ut_teardown,
17401 : : test_ipsec_proto_ah_tunnel_ipv4),
17402 : : TEST_CASE_NAMED_ST(
17403 : : "IV generation",
17404 : : ut_setup_security, ut_teardown,
17405 : : test_ipsec_proto_iv_gen),
17406 : : TEST_CASE_NAMED_ST(
17407 : : "UDP encapsulation",
17408 : : ut_setup_security, ut_teardown,
17409 : : test_ipsec_proto_udp_encap),
17410 : : TEST_CASE_NAMED_ST(
17411 : : "UDP encapsulation with custom ports",
17412 : : ut_setup_security, ut_teardown,
17413 : : test_ipsec_proto_udp_encap_custom_ports),
17414 : : TEST_CASE_NAMED_ST(
17415 : : "UDP encapsulation ports verification test",
17416 : : ut_setup_security, ut_teardown,
17417 : : test_ipsec_proto_udp_ports_verify),
17418 : : TEST_CASE_NAMED_ST(
17419 : : "SA expiry packets soft",
17420 : : ut_setup_security, ut_teardown,
17421 : : test_ipsec_proto_sa_exp_pkts_soft),
17422 : : TEST_CASE_NAMED_ST(
17423 : : "SA expiry packets hard",
17424 : : ut_setup_security, ut_teardown,
17425 : : test_ipsec_proto_sa_exp_pkts_hard),
17426 : : TEST_CASE_NAMED_ST(
17427 : : "Negative test: ICV corruption",
17428 : : ut_setup_security, ut_teardown,
17429 : : test_ipsec_proto_err_icv_corrupt),
17430 : : TEST_CASE_NAMED_ST(
17431 : : "Tunnel dst addr verification",
17432 : : ut_setup_security, ut_teardown,
17433 : : test_ipsec_proto_tunnel_dst_addr_verify),
17434 : : TEST_CASE_NAMED_ST(
17435 : : "Tunnel src and dst addr verification",
17436 : : ut_setup_security, ut_teardown,
17437 : : test_ipsec_proto_tunnel_src_dst_addr_verify),
17438 : : TEST_CASE_NAMED_ST(
17439 : : "Inner IP checksum",
17440 : : ut_setup_security, ut_teardown,
17441 : : test_ipsec_proto_inner_ip_csum),
17442 : : TEST_CASE_NAMED_ST(
17443 : : "Inner L4 checksum",
17444 : : ut_setup_security, ut_teardown,
17445 : : test_ipsec_proto_inner_l4_csum),
17446 : : TEST_CASE_NAMED_ST(
17447 : : "Tunnel IPv4 in IPv4",
17448 : : ut_setup_security, ut_teardown,
17449 : : test_ipsec_proto_tunnel_v4_in_v4),
17450 : : TEST_CASE_NAMED_ST(
17451 : : "Tunnel IPv6 in IPv6",
17452 : : ut_setup_security, ut_teardown,
17453 : : test_ipsec_proto_tunnel_v6_in_v6),
17454 : : TEST_CASE_NAMED_ST(
17455 : : "Tunnel IPv4 in IPv6",
17456 : : ut_setup_security, ut_teardown,
17457 : : test_ipsec_proto_tunnel_v4_in_v6),
17458 : : TEST_CASE_NAMED_ST(
17459 : : "Tunnel IPv6 in IPv4",
17460 : : ut_setup_security, ut_teardown,
17461 : : test_ipsec_proto_tunnel_v6_in_v4),
17462 : : TEST_CASE_NAMED_ST(
17463 : : "Transport IPv4",
17464 : : ut_setup_security, ut_teardown,
17465 : : test_ipsec_proto_transport_v4),
17466 : : TEST_CASE_NAMED_ST(
17467 : : "AH transport IPv4",
17468 : : ut_setup_security, ut_teardown,
17469 : : test_ipsec_proto_ah_transport_ipv4),
17470 : : TEST_CASE_NAMED_ST(
17471 : : "Transport l4 checksum",
17472 : : ut_setup_security, ut_teardown,
17473 : : test_ipsec_proto_transport_l4_csum),
17474 : : TEST_CASE_NAMED_ST(
17475 : : "Statistics: success",
17476 : : ut_setup_security, ut_teardown,
17477 : : test_ipsec_proto_stats),
17478 : : TEST_CASE_NAMED_ST(
17479 : : "Fragmented packet",
17480 : : ut_setup_security, ut_teardown,
17481 : : test_ipsec_proto_pkt_fragment),
17482 : : TEST_CASE_NAMED_ST(
17483 : : "Tunnel header copy DF (inner 0)",
17484 : : ut_setup_security, ut_teardown,
17485 : : test_ipsec_proto_copy_df_inner_0),
17486 : : TEST_CASE_NAMED_ST(
17487 : : "Tunnel header copy DF (inner 1)",
17488 : : ut_setup_security, ut_teardown,
17489 : : test_ipsec_proto_copy_df_inner_1),
17490 : : TEST_CASE_NAMED_ST(
17491 : : "Tunnel header set DF 0 (inner 1)",
17492 : : ut_setup_security, ut_teardown,
17493 : : test_ipsec_proto_set_df_0_inner_1),
17494 : : TEST_CASE_NAMED_ST(
17495 : : "Tunnel header set DF 1 (inner 0)",
17496 : : ut_setup_security, ut_teardown,
17497 : : test_ipsec_proto_set_df_1_inner_0),
17498 : : TEST_CASE_NAMED_ST(
17499 : : "Tunnel header IPv4 copy DSCP (inner 0)",
17500 : : ut_setup_security, ut_teardown,
17501 : : test_ipsec_proto_ipv4_copy_dscp_inner_0),
17502 : : TEST_CASE_NAMED_ST(
17503 : : "Tunnel header IPv4 copy DSCP (inner 1)",
17504 : : ut_setup_security, ut_teardown,
17505 : : test_ipsec_proto_ipv4_copy_dscp_inner_1),
17506 : : TEST_CASE_NAMED_ST(
17507 : : "Tunnel header IPv4 set DSCP 0 (inner 1)",
17508 : : ut_setup_security, ut_teardown,
17509 : : test_ipsec_proto_ipv4_set_dscp_0_inner_1),
17510 : : TEST_CASE_NAMED_ST(
17511 : : "Tunnel header IPv4 set DSCP 1 (inner 0)",
17512 : : ut_setup_security, ut_teardown,
17513 : : test_ipsec_proto_ipv4_set_dscp_1_inner_0),
17514 : : TEST_CASE_NAMED_ST(
17515 : : "Tunnel header IPv6 copy DSCP (inner 0)",
17516 : : ut_setup_security, ut_teardown,
17517 : : test_ipsec_proto_ipv6_copy_dscp_inner_0),
17518 : : TEST_CASE_NAMED_ST(
17519 : : "Tunnel header IPv6 copy DSCP (inner 1)",
17520 : : ut_setup_security, ut_teardown,
17521 : : test_ipsec_proto_ipv6_copy_dscp_inner_1),
17522 : : TEST_CASE_NAMED_ST(
17523 : : "Tunnel header IPv6 set DSCP 0 (inner 1)",
17524 : : ut_setup_security, ut_teardown,
17525 : : test_ipsec_proto_ipv6_set_dscp_0_inner_1),
17526 : : TEST_CASE_NAMED_ST(
17527 : : "Tunnel header IPv6 set DSCP 1 (inner 0)",
17528 : : ut_setup_security, ut_teardown,
17529 : : test_ipsec_proto_ipv6_set_dscp_1_inner_0),
17530 : : TEST_CASE_NAMED_WITH_DATA(
17531 : : "Antireplay with window size 1024",
17532 : : ut_setup_security, ut_teardown,
17533 : : test_ipsec_proto_pkt_antireplay1024, &pkt_aes_128_gcm),
17534 : : TEST_CASE_NAMED_WITH_DATA(
17535 : : "Antireplay with window size 2048",
17536 : : ut_setup_security, ut_teardown,
17537 : : test_ipsec_proto_pkt_antireplay2048, &pkt_aes_128_gcm),
17538 : : TEST_CASE_NAMED_WITH_DATA(
17539 : : "Antireplay with window size 4096",
17540 : : ut_setup_security, ut_teardown,
17541 : : test_ipsec_proto_pkt_antireplay4096, &pkt_aes_128_gcm),
17542 : : TEST_CASE_NAMED_WITH_DATA(
17543 : : "ESN and Antireplay with window size 1024",
17544 : : ut_setup_security, ut_teardown,
17545 : : test_ipsec_proto_pkt_esn_antireplay1024,
17546 : : &pkt_aes_128_gcm),
17547 : : TEST_CASE_NAMED_WITH_DATA(
17548 : : "ESN and Antireplay with window size 2048",
17549 : : ut_setup_security, ut_teardown,
17550 : : test_ipsec_proto_pkt_esn_antireplay2048,
17551 : : &pkt_aes_128_gcm),
17552 : : TEST_CASE_NAMED_WITH_DATA(
17553 : : "ESN and Antireplay with window size 4096",
17554 : : ut_setup_security, ut_teardown,
17555 : : test_ipsec_proto_pkt_esn_antireplay4096,
17556 : : &pkt_aes_128_gcm),
17557 : : TEST_CASE_NAMED_ST(
17558 : : "Tunnel header IPv4 decrement inner TTL",
17559 : : ut_setup_security, ut_teardown,
17560 : : test_ipsec_proto_ipv4_ttl_decrement),
17561 : : TEST_CASE_NAMED_ST(
17562 : : "Tunnel header IPv6 decrement inner hop limit",
17563 : : ut_setup_security, ut_teardown,
17564 : : test_ipsec_proto_ipv6_hop_limit_decrement),
17565 : : TEST_CASE_NAMED_ST(
17566 : : "Multi-segmented mode",
17567 : : ut_setup_security, ut_teardown,
17568 : : test_ipsec_proto_sgl),
17569 : : TEST_CASE_NAMED_ST(
17570 : : "Multi-segmented external mbuf mode",
17571 : : ut_setup_security, ut_teardown,
17572 : : test_ipsec_proto_sgl_ext_mbuf),
17573 : : TEST_CASE_NAMED_WITH_DATA(
17574 : : "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128) Rx inject",
17575 : : ut_setup_security_rx_inject, ut_teardown_rx_inject,
17576 : : test_ipsec_proto_known_vec_inb_rx_inject, &pkt_aes_128_gcm),
17577 : : TEST_CASES_END() /**< NULL terminate unit test array */
17578 : : }
17579 : : };
17580 : :
17581 : : static struct unit_test_suite pdcp_proto_testsuite = {
17582 : : .suite_name = "PDCP Proto Unit Test Suite",
17583 : : .setup = pdcp_proto_testsuite_setup,
17584 : : .unit_test_cases = {
17585 : : TEST_CASE_ST(ut_setup_security, ut_teardown,
17586 : : test_PDCP_PROTO_all),
17587 : : TEST_CASES_END() /**< NULL terminate unit test array */
17588 : : }
17589 : : };
17590 : :
17591 : : static struct unit_test_suite tls12_record_proto_testsuite = {
17592 : : .suite_name = "TLS 1.2 Record Protocol Unit Test Suite",
17593 : : .setup = tls_record_proto_testsuite_setup,
17594 : : .unit_test_cases = {
17595 : : TEST_CASE_NAMED_WITH_DATA(
17596 : : "Write record known vector AES-GCM-128 (vector 1)",
17597 : : ut_setup_security, ut_teardown,
17598 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v1),
17599 : : TEST_CASE_NAMED_WITH_DATA(
17600 : : "Write record known vector AES-GCM-128 (vector 2)",
17601 : : ut_setup_security, ut_teardown,
17602 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_gcm_v2),
17603 : : TEST_CASE_NAMED_WITH_DATA(
17604 : : "Write record known vector AES-GCM-256",
17605 : : ut_setup_security, ut_teardown,
17606 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_gcm),
17607 : : TEST_CASE_NAMED_WITH_DATA(
17608 : : "Write record known vector AES-CBC-128-SHA1",
17609 : : ut_setup_security, ut_teardown,
17610 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha1_hmac),
17611 : : TEST_CASE_NAMED_WITH_DATA(
17612 : : "Write record known vector AES-128-CBC-SHA256",
17613 : : ut_setup_security, ut_teardown,
17614 : : test_tls_record_proto_known_vec, &tls_test_data_aes_128_cbc_sha256_hmac),
17615 : : TEST_CASE_NAMED_WITH_DATA(
17616 : : "Write record known vector AES-256-CBC-SHA1",
17617 : : ut_setup_security, ut_teardown,
17618 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha1_hmac),
17619 : : TEST_CASE_NAMED_WITH_DATA(
17620 : : "Write record known vector AES-256-CBC-SHA256",
17621 : : ut_setup_security, ut_teardown,
17622 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha256_hmac),
17623 : : TEST_CASE_NAMED_WITH_DATA(
17624 : : "Write record known vector AES-256-CBC-SHA384",
17625 : : ut_setup_security, ut_teardown,
17626 : : test_tls_record_proto_known_vec, &tls_test_data_aes_256_cbc_sha384_hmac),
17627 : : TEST_CASE_NAMED_WITH_DATA(
17628 : : "Write record known vector 3DES-CBC-SHA1-HMAC",
17629 : : ut_setup_security, ut_teardown,
17630 : : test_tls_record_proto_known_vec, &tls_test_data_3des_cbc_sha1_hmac),
17631 : : TEST_CASE_NAMED_WITH_DATA(
17632 : : "Write record known vector NULL-SHA1-HMAC",
17633 : : ut_setup_security, ut_teardown,
17634 : : test_tls_record_proto_known_vec, &tls_test_data_null_cipher_sha1_hmac),
17635 : : TEST_CASE_NAMED_WITH_DATA(
17636 : : "Write record known vector CHACHA20-POLY1305",
17637 : : ut_setup_security, ut_teardown,
17638 : : test_tls_record_proto_known_vec, &tls_test_data_chacha20_poly1305),
17639 : :
17640 : : TEST_CASE_NAMED_WITH_DATA(
17641 : : "Read record known vector AES-GCM-128 (vector 1)",
17642 : : ut_setup_security, ut_teardown,
17643 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v1),
17644 : : TEST_CASE_NAMED_WITH_DATA(
17645 : : "Read record known vector AES-GCM-128 (vector 2)",
17646 : : ut_setup_security, ut_teardown,
17647 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_gcm_v2),
17648 : : TEST_CASE_NAMED_WITH_DATA(
17649 : : "Read record known vector AES-GCM-256",
17650 : : ut_setup_security, ut_teardown,
17651 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_gcm),
17652 : : TEST_CASE_NAMED_WITH_DATA(
17653 : : "Read record known vector AES-128-CBC-SHA1",
17654 : : ut_setup_security, ut_teardown,
17655 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_128_cbc_sha1_hmac),
17656 : : TEST_CASE_NAMED_WITH_DATA(
17657 : : "Read record known vector AES-128-CBC-SHA256",
17658 : : ut_setup_security, ut_teardown,
17659 : : test_tls_record_proto_known_vec_read,
17660 : : &tls_test_data_aes_128_cbc_sha256_hmac),
17661 : : TEST_CASE_NAMED_WITH_DATA(
17662 : : "Read record known vector AES-256-CBC-SHA1",
17663 : : ut_setup_security, ut_teardown,
17664 : : test_tls_record_proto_known_vec_read, &tls_test_data_aes_256_cbc_sha1_hmac),
17665 : : TEST_CASE_NAMED_WITH_DATA(
17666 : : "Read record known vector AES-256-CBC-SHA256",
17667 : : ut_setup_security, ut_teardown,
17668 : : test_tls_record_proto_known_vec_read,
17669 : : &tls_test_data_aes_256_cbc_sha256_hmac),
17670 : : TEST_CASE_NAMED_WITH_DATA(
17671 : : "Read record known vector AES-256-CBC-SHA384",
17672 : : ut_setup_security, ut_teardown,
17673 : : test_tls_record_proto_known_vec_read,
17674 : : &tls_test_data_aes_256_cbc_sha384_hmac),
17675 : : TEST_CASE_NAMED_WITH_DATA(
17676 : : "Read record known vector 3DES-CBC-SHA1-HMAC",
17677 : : ut_setup_security, ut_teardown,
17678 : : test_tls_record_proto_known_vec_read, &tls_test_data_3des_cbc_sha1_hmac),
17679 : : TEST_CASE_NAMED_WITH_DATA(
17680 : : "Read record known vector NULL-SHA1-HMAC",
17681 : : ut_setup_security, ut_teardown,
17682 : : test_tls_record_proto_known_vec_read, &tls_test_data_null_cipher_sha1_hmac),
17683 : : TEST_CASE_NAMED_WITH_DATA(
17684 : : "Read record known vector CHACHA20-POLY1305",
17685 : : ut_setup_security, ut_teardown,
17686 : : test_tls_record_proto_known_vec_read, &tls_test_data_chacha20_poly1305),
17687 : :
17688 : : TEST_CASE_NAMED_ST(
17689 : : "Combined test alg list",
17690 : : ut_setup_security, ut_teardown,
17691 : : test_tls_1_2_record_proto_display_list),
17692 : : TEST_CASE_NAMED_ST(
17693 : : "Data walkthrough combined test alg list",
17694 : : ut_setup_security, ut_teardown,
17695 : : test_tls_1_2_record_proto_data_walkthrough),
17696 : : TEST_CASE_NAMED_ST(
17697 : : "Multi-segmented mode",
17698 : : ut_setup_security, ut_teardown,
17699 : : test_tls_1_2_record_proto_sgl),
17700 : : TEST_CASE_NAMED_ST(
17701 : : "Multi-segmented mode data walkthrough",
17702 : : ut_setup_security, ut_teardown,
17703 : : test_tls_1_2_record_proto_sgl_data_walkthrough),
17704 : : TEST_CASE_NAMED_ST(
17705 : : "Multi-segmented mode out of place",
17706 : : ut_setup_security, ut_teardown,
17707 : : test_tls_1_2_record_proto_sgl_oop),
17708 : : TEST_CASE_NAMED_ST(
17709 : : "TLS packet header corruption",
17710 : : ut_setup_security, ut_teardown,
17711 : : test_tls_record_proto_corrupt_pkt),
17712 : : TEST_CASE_NAMED_ST(
17713 : : "Custom content type",
17714 : : ut_setup_security, ut_teardown,
17715 : : test_tls_record_proto_custom_content_type),
17716 : : TEST_CASE_NAMED_ST(
17717 : : "Zero len TLS record with content type as app",
17718 : : ut_setup_security, ut_teardown,
17719 : : test_tls_record_proto_zero_len),
17720 : : TEST_CASE_NAMED_ST(
17721 : : "Zero len TLS record with content type as ctrl",
17722 : : ut_setup_security, ut_teardown,
17723 : : test_tls_record_proto_zero_len_non_app),
17724 : : TEST_CASE_NAMED_ST(
17725 : : "TLS record DM mode with optional padding < 2 blocks",
17726 : : ut_setup_security, ut_teardown,
17727 : : test_tls_record_proto_dm_opt_padding),
17728 : : TEST_CASE_NAMED_ST(
17729 : : "TLS record DM mode with optional padding > 2 blocks",
17730 : : ut_setup_security, ut_teardown,
17731 : : test_tls_record_proto_dm_opt_padding_1),
17732 : : TEST_CASE_NAMED_ST(
17733 : : "TLS record SG mode with optional padding < 2 blocks",
17734 : : ut_setup_security, ut_teardown,
17735 : : test_tls_record_proto_sg_opt_padding),
17736 : : TEST_CASE_NAMED_ST(
17737 : : "TLS record SG mode with optional padding > 2 blocks",
17738 : : ut_setup_security, ut_teardown,
17739 : : test_tls_record_proto_sg_opt_padding_1),
17740 : : TEST_CASE_NAMED_ST(
17741 : : "TLS record SG mode with optional padding > 2 blocks",
17742 : : ut_setup_security, ut_teardown,
17743 : : test_tls_record_proto_sg_opt_padding_2),
17744 : : TEST_CASE_NAMED_ST(
17745 : : "TLS record SG mode with optional padding > max range",
17746 : : ut_setup_security, ut_teardown,
17747 : : test_tls_record_proto_sg_opt_padding_max),
17748 : : TEST_CASES_END() /**< NULL terminate unit test array */
17749 : : }
17750 : : };
17751 : :
17752 : : static struct unit_test_suite dtls12_record_proto_testsuite = {
17753 : : .suite_name = "DTLS 1.2 Record Protocol Unit Test Suite",
17754 : : .setup = tls_record_proto_testsuite_setup,
17755 : : .unit_test_cases = {
17756 : : TEST_CASE_NAMED_WITH_DATA(
17757 : : "Write record known vector AES-GCM-128",
17758 : : ut_setup_security, ut_teardown,
17759 : : test_tls_record_proto_known_vec, &dtls_test_data_aes_128_gcm),
17760 : : TEST_CASE_NAMED_WITH_DATA(
17761 : : "Write record known vector AES-GCM-256",
17762 : : ut_setup_security, ut_teardown,
17763 : : test_tls_record_proto_known_vec, &dtls_test_data_aes_256_gcm),
17764 : : TEST_CASE_NAMED_WITH_DATA(
17765 : : "Write record known vector AES-128-CBC-SHA1",
17766 : : ut_setup_security, ut_teardown,
17767 : : test_tls_record_proto_known_vec,
17768 : : &dtls_test_data_aes_128_cbc_sha1_hmac),
17769 : : TEST_CASE_NAMED_WITH_DATA(
17770 : : "Write record known vector AES-128-CBC-SHA256",
17771 : : ut_setup_security, ut_teardown,
17772 : : test_tls_record_proto_known_vec,
17773 : : &dtls_test_data_aes_128_cbc_sha256_hmac),
17774 : : TEST_CASE_NAMED_WITH_DATA(
17775 : : "Write record known vector AES-256-CBC-SHA1",
17776 : : ut_setup_security, ut_teardown,
17777 : : test_tls_record_proto_known_vec,
17778 : : &dtls_test_data_aes_256_cbc_sha1_hmac),
17779 : : TEST_CASE_NAMED_WITH_DATA(
17780 : : "Write record known vector AES-256-CBC-SHA256",
17781 : : ut_setup_security, ut_teardown,
17782 : : test_tls_record_proto_known_vec,
17783 : : &dtls_test_data_aes_256_cbc_sha256_hmac),
17784 : : TEST_CASE_NAMED_WITH_DATA(
17785 : : "Write record known vector AES-256-CBC-SHA384",
17786 : : ut_setup_security, ut_teardown,
17787 : : test_tls_record_proto_known_vec,
17788 : : &dtls_test_data_aes_256_cbc_sha384_hmac),
17789 : : TEST_CASE_NAMED_WITH_DATA(
17790 : : "Write record known vector 3DES-CBC-SHA1-HMAC",
17791 : : ut_setup_security, ut_teardown,
17792 : : test_tls_record_proto_known_vec,
17793 : : &dtls_test_data_3des_cbc_sha1_hmac),
17794 : : TEST_CASE_NAMED_WITH_DATA(
17795 : : "Write record known vector NULL-SHA1-HMAC",
17796 : : ut_setup_security, ut_teardown,
17797 : : test_tls_record_proto_known_vec,
17798 : : &dtls_test_data_null_cipher_sha1_hmac),
17799 : : TEST_CASE_NAMED_WITH_DATA(
17800 : : "Write record known vector CHACHA20-POLY1305",
17801 : : ut_setup_security, ut_teardown,
17802 : : test_tls_record_proto_known_vec, &dtls_test_data_chacha20_poly1305),
17803 : : TEST_CASE_NAMED_WITH_DATA(
17804 : : "Read record known vector AES-GCM-128",
17805 : : ut_setup_security, ut_teardown,
17806 : : test_tls_record_proto_known_vec_read, &dtls_test_data_aes_128_gcm),
17807 : : TEST_CASE_NAMED_WITH_DATA(
17808 : : "Read record known vector AES-GCM-256",
17809 : : ut_setup_security, ut_teardown,
17810 : : test_tls_record_proto_known_vec_read, &dtls_test_data_aes_256_gcm),
17811 : : TEST_CASE_NAMED_WITH_DATA(
17812 : : "Read record known vector AES-128-CBC-SHA1",
17813 : : ut_setup_security, ut_teardown,
17814 : : test_tls_record_proto_known_vec_read,
17815 : : &dtls_test_data_aes_128_cbc_sha1_hmac),
17816 : : TEST_CASE_NAMED_WITH_DATA(
17817 : : "Read record known vector AES-128-CBC-SHA256",
17818 : : ut_setup_security, ut_teardown,
17819 : : test_tls_record_proto_known_vec_read,
17820 : : &dtls_test_data_aes_128_cbc_sha256_hmac),
17821 : : TEST_CASE_NAMED_WITH_DATA(
17822 : : "Read record known vector AES-256-CBC-SHA1",
17823 : : ut_setup_security, ut_teardown,
17824 : : test_tls_record_proto_known_vec_read,
17825 : : &dtls_test_data_aes_256_cbc_sha1_hmac),
17826 : : TEST_CASE_NAMED_WITH_DATA(
17827 : : "Read record known vector AES-256-CBC-SHA256",
17828 : : ut_setup_security, ut_teardown,
17829 : : test_tls_record_proto_known_vec_read,
17830 : : &dtls_test_data_aes_256_cbc_sha256_hmac),
17831 : : TEST_CASE_NAMED_WITH_DATA(
17832 : : "Read record known vector AES-256-CBC-SHA384",
17833 : : ut_setup_security, ut_teardown,
17834 : : test_tls_record_proto_known_vec_read,
17835 : : &dtls_test_data_aes_256_cbc_sha384_hmac),
17836 : : TEST_CASE_NAMED_WITH_DATA(
17837 : : "Read record known vector 3DES-CBC-SHA1-HMAC",
17838 : : ut_setup_security, ut_teardown,
17839 : : test_tls_record_proto_known_vec_read,
17840 : : &dtls_test_data_3des_cbc_sha1_hmac),
17841 : : TEST_CASE_NAMED_WITH_DATA(
17842 : : "Read record known vector NULL-SHA1-HMAC",
17843 : : ut_setup_security, ut_teardown,
17844 : : test_tls_record_proto_known_vec_read,
17845 : : &dtls_test_data_null_cipher_sha1_hmac),
17846 : : TEST_CASE_NAMED_WITH_DATA(
17847 : : "Read record known vector CHACHA20-POLY1305",
17848 : : ut_setup_security, ut_teardown,
17849 : : test_tls_record_proto_known_vec_read, &dtls_test_data_chacha20_poly1305),
17850 : :
17851 : : TEST_CASE_NAMED_ST(
17852 : : "Combined test alg list",
17853 : : ut_setup_security, ut_teardown,
17854 : : test_dtls_1_2_record_proto_display_list),
17855 : : TEST_CASE_NAMED_ST(
17856 : : "Data walkthrough combined test alg list",
17857 : : ut_setup_security, ut_teardown,
17858 : : test_dtls_1_2_record_proto_data_walkthrough),
17859 : : TEST_CASE_NAMED_ST(
17860 : : "Multi-segmented mode",
17861 : : ut_setup_security, ut_teardown,
17862 : : test_dtls_1_2_record_proto_sgl),
17863 : : TEST_CASE_NAMED_ST(
17864 : : "Multi-segmented mode data walkthrough",
17865 : : ut_setup_security, ut_teardown,
17866 : : test_dtls_1_2_record_proto_sgl_data_walkthrough),
17867 : : TEST_CASE_NAMED_ST(
17868 : : "Packet corruption",
17869 : : ut_setup_security, ut_teardown,
17870 : : test_dtls_1_2_record_proto_corrupt_pkt),
17871 : : TEST_CASE_NAMED_ST(
17872 : : "Custom content type",
17873 : : ut_setup_security, ut_teardown,
17874 : : test_dtls_1_2_record_proto_custom_content_type),
17875 : : TEST_CASE_NAMED_ST(
17876 : : "Zero len DTLS record with content type as app",
17877 : : ut_setup_security, ut_teardown,
17878 : : test_dtls_1_2_record_proto_zero_len),
17879 : : TEST_CASE_NAMED_ST(
17880 : : "Zero len DTLS record with content type as ctrl",
17881 : : ut_setup_security, ut_teardown,
17882 : : test_dtls_1_2_record_proto_zero_len_non_app),
17883 : : TEST_CASE_NAMED_ST(
17884 : : "Antireplay with window size 64",
17885 : : ut_setup_security, ut_teardown,
17886 : : test_dtls_1_2_record_proto_antireplay64),
17887 : : TEST_CASE_NAMED_ST(
17888 : : "Antireplay with window size 128",
17889 : : ut_setup_security, ut_teardown,
17890 : : test_dtls_1_2_record_proto_antireplay128),
17891 : : TEST_CASE_NAMED_ST(
17892 : : "Antireplay with window size 256",
17893 : : ut_setup_security, ut_teardown,
17894 : : test_dtls_1_2_record_proto_antireplay256),
17895 : : TEST_CASE_NAMED_ST(
17896 : : "Antireplay with window size 512",
17897 : : ut_setup_security, ut_teardown,
17898 : : test_dtls_1_2_record_proto_antireplay512),
17899 : : TEST_CASE_NAMED_ST(
17900 : : "Antireplay with window size 1024",
17901 : : ut_setup_security, ut_teardown,
17902 : : test_dtls_1_2_record_proto_antireplay1024),
17903 : : TEST_CASE_NAMED_ST(
17904 : : "Antireplay with window size 2048",
17905 : : ut_setup_security, ut_teardown,
17906 : : test_dtls_1_2_record_proto_antireplay2048),
17907 : : TEST_CASE_NAMED_ST(
17908 : : "Antireplay with window size 4096",
17909 : : ut_setup_security, ut_teardown,
17910 : : test_dtls_1_2_record_proto_antireplay4096),
17911 : : TEST_CASE_NAMED_ST(
17912 : : "DTLS record DM mode with optional padding < 2 blocks",
17913 : : ut_setup_security, ut_teardown,
17914 : : test_dtls_1_2_record_proto_dm_opt_padding),
17915 : : TEST_CASE_NAMED_ST(
17916 : : "DTLS record DM mode with optional padding > 2 blocks",
17917 : : ut_setup_security, ut_teardown,
17918 : : test_dtls_1_2_record_proto_dm_opt_padding_1),
17919 : : TEST_CASE_NAMED_ST(
17920 : : "DTLS record SG mode with optional padding < 2 blocks",
17921 : : ut_setup_security, ut_teardown,
17922 : : test_dtls_1_2_record_proto_sg_opt_padding),
17923 : : TEST_CASE_NAMED_ST(
17924 : : "DTLS record SG mode with optional padding > 2 blocks",
17925 : : ut_setup_security, ut_teardown,
17926 : : test_dtls_1_2_record_proto_sg_opt_padding_1),
17927 : : TEST_CASE_NAMED_ST(
17928 : : "DTLS record SG mode with optional padding > 2 blocks",
17929 : : ut_setup_security, ut_teardown,
17930 : : test_dtls_1_2_record_proto_sg_opt_padding_2),
17931 : : TEST_CASE_NAMED_ST(
17932 : : "DTLS record SG mode with optional padding > max range",
17933 : : ut_setup_security, ut_teardown,
17934 : : test_dtls_1_2_record_proto_sg_opt_padding_max),
17935 : : TEST_CASES_END() /**< NULL terminate unit test array */
17936 : : }
17937 : : };
17938 : :
17939 : : static struct unit_test_suite tls13_record_proto_testsuite = {
17940 : : .suite_name = "TLS 1.3 Record Protocol Unit Test Suite",
17941 : : .setup = tls_record_proto_testsuite_setup,
17942 : : .unit_test_cases = {
17943 : : TEST_CASE_NAMED_WITH_DATA(
17944 : : "Write record known vector AES-GCM-128",
17945 : : ut_setup_security, ut_teardown,
17946 : : test_tls_record_proto_known_vec, &tls13_test_data_aes_128_gcm),
17947 : : TEST_CASE_NAMED_WITH_DATA(
17948 : : "Write record known vector AES-GCM-256",
17949 : : ut_setup_security, ut_teardown,
17950 : : test_tls_record_proto_known_vec, &tls13_test_data_aes_256_gcm),
17951 : : TEST_CASE_NAMED_WITH_DATA(
17952 : : "Write record known vector CHACHA20-POLY1305",
17953 : : ut_setup_security, ut_teardown,
17954 : : test_tls_record_proto_known_vec, &tls13_test_data_chacha20_poly1305),
17955 : :
17956 : : TEST_CASE_NAMED_WITH_DATA(
17957 : : "Read record known vector AES-GCM-128",
17958 : : ut_setup_security, ut_teardown,
17959 : : test_tls_record_proto_known_vec_read, &tls13_test_data_aes_128_gcm),
17960 : : TEST_CASE_NAMED_WITH_DATA(
17961 : : "Read record known vector AES-GCM-256",
17962 : : ut_setup_security, ut_teardown,
17963 : : test_tls_record_proto_known_vec_read, &tls13_test_data_aes_256_gcm),
17964 : : TEST_CASE_NAMED_WITH_DATA(
17965 : : "Read record known vector CHACHA20-POLY1305",
17966 : : ut_setup_security, ut_teardown,
17967 : : test_tls_record_proto_known_vec_read, &tls13_test_data_chacha20_poly1305),
17968 : : TEST_CASE_NAMED_ST(
17969 : : "TLS-1.3 record header corruption",
17970 : : ut_setup_security, ut_teardown,
17971 : : test_tls_1_3_record_proto_corrupt_pkt),
17972 : : TEST_CASE_NAMED_ST(
17973 : : "TLS-1.3 record header with custom content type",
17974 : : ut_setup_security, ut_teardown,
17975 : : test_tls_1_3_record_proto_custom_content_type),
17976 : : TEST_CASE_NAMED_ST(
17977 : : "TLS-1.3 record with zero len and content type as app",
17978 : : ut_setup_security, ut_teardown,
17979 : : test_tls_1_3_record_proto_zero_len),
17980 : : TEST_CASE_NAMED_ST(
17981 : : "TLS-1.3 record with zero len and content type as ctrl",
17982 : : ut_setup_security, ut_teardown,
17983 : : test_tls_1_3_record_proto_zero_len_non_app),
17984 : : TEST_CASES_END() /**< NULL terminate unit test array */
17985 : : }
17986 : : };
17987 : :
17988 : : #define ADD_UPLINK_TESTCASE(data) \
17989 : : TEST_CASE_NAMED_WITH_DATA(data.test_descr_uplink, ut_setup_security, \
17990 : : ut_teardown, test_docsis_proto_uplink, (const void *) &data), \
17991 : :
17992 : : #define ADD_DOWNLINK_TESTCASE(data) \
17993 : : TEST_CASE_NAMED_WITH_DATA(data.test_descr_downlink, ut_setup_security, \
17994 : : ut_teardown, test_docsis_proto_downlink, (const void *) &data), \
17995 : :
17996 : : static struct unit_test_suite docsis_proto_testsuite = {
17997 : : .suite_name = "DOCSIS Proto Unit Test Suite",
17998 : : .setup = docsis_proto_testsuite_setup,
17999 : : .unit_test_cases = {
18000 : : /* Uplink */
18001 : : ADD_UPLINK_TESTCASE(docsis_test_case_1)
18002 : : ADD_UPLINK_TESTCASE(docsis_test_case_2)
18003 : : ADD_UPLINK_TESTCASE(docsis_test_case_3)
18004 : : ADD_UPLINK_TESTCASE(docsis_test_case_4)
18005 : : ADD_UPLINK_TESTCASE(docsis_test_case_5)
18006 : : ADD_UPLINK_TESTCASE(docsis_test_case_6)
18007 : : ADD_UPLINK_TESTCASE(docsis_test_case_7)
18008 : : ADD_UPLINK_TESTCASE(docsis_test_case_8)
18009 : : ADD_UPLINK_TESTCASE(docsis_test_case_9)
18010 : : ADD_UPLINK_TESTCASE(docsis_test_case_10)
18011 : : ADD_UPLINK_TESTCASE(docsis_test_case_11)
18012 : : ADD_UPLINK_TESTCASE(docsis_test_case_12)
18013 : : ADD_UPLINK_TESTCASE(docsis_test_case_13)
18014 : : ADD_UPLINK_TESTCASE(docsis_test_case_14)
18015 : : ADD_UPLINK_TESTCASE(docsis_test_case_15)
18016 : : ADD_UPLINK_TESTCASE(docsis_test_case_16)
18017 : : ADD_UPLINK_TESTCASE(docsis_test_case_17)
18018 : : ADD_UPLINK_TESTCASE(docsis_test_case_18)
18019 : : ADD_UPLINK_TESTCASE(docsis_test_case_19)
18020 : : ADD_UPLINK_TESTCASE(docsis_test_case_20)
18021 : : ADD_UPLINK_TESTCASE(docsis_test_case_21)
18022 : : ADD_UPLINK_TESTCASE(docsis_test_case_22)
18023 : : ADD_UPLINK_TESTCASE(docsis_test_case_23)
18024 : : ADD_UPLINK_TESTCASE(docsis_test_case_24)
18025 : : ADD_UPLINK_TESTCASE(docsis_test_case_25)
18026 : : ADD_UPLINK_TESTCASE(docsis_test_case_26)
18027 : : /* Downlink */
18028 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_1)
18029 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_2)
18030 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_3)
18031 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_4)
18032 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_5)
18033 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_6)
18034 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_7)
18035 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_8)
18036 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_9)
18037 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_10)
18038 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_11)
18039 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_12)
18040 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_13)
18041 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_14)
18042 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_15)
18043 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_16)
18044 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_17)
18045 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_18)
18046 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_19)
18047 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_20)
18048 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_21)
18049 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_22)
18050 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_23)
18051 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_24)
18052 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_25)
18053 : : ADD_DOWNLINK_TESTCASE(docsis_test_case_26)
18054 : : TEST_CASES_END() /**< NULL terminate unit test array */
18055 : : }
18056 : : };
18057 : : #endif
18058 : :
18059 : : static struct unit_test_suite cryptodev_gen_testsuite = {
18060 : : .suite_name = "Crypto General Unit Test Suite",
18061 : : .setup = crypto_gen_testsuite_setup,
18062 : : .unit_test_cases = {
18063 : : TEST_CASE_ST(ut_setup, ut_teardown,
18064 : : test_device_reconfigure),
18065 : : TEST_CASE_ST(ut_setup, ut_teardown,
18066 : : test_device_configure_invalid_dev_id),
18067 : : TEST_CASE_ST(ut_setup, ut_teardown,
18068 : : test_queue_pair_descriptor_setup),
18069 : : TEST_CASE_ST(ut_setup, ut_teardown,
18070 : : test_device_configure_invalid_queue_pair_ids),
18071 : : TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
18072 : : TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
18073 : : TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
18074 : : TEST_CASES_END() /**< NULL terminate unit test array */
18075 : : }
18076 : : };
18077 : :
18078 : : static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
18079 : : .suite_name = "Negative HMAC SHA1 Unit Test Suite",
18080 : : .setup = negative_hmac_sha1_testsuite_setup,
18081 : : .unit_test_cases = {
18082 : : /** Negative tests */
18083 : : TEST_CASE_ST(ut_setup, ut_teardown,
18084 : : authentication_verify_HMAC_SHA1_fail_data_corrupt),
18085 : : TEST_CASE_ST(ut_setup, ut_teardown,
18086 : : authentication_verify_HMAC_SHA1_fail_tag_corrupt),
18087 : : TEST_CASE_ST(ut_setup, ut_teardown,
18088 : : auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
18089 : : TEST_CASE_ST(ut_setup, ut_teardown,
18090 : : auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
18091 : :
18092 : : TEST_CASES_END() /**< NULL terminate unit test array */
18093 : : }
18094 : : };
18095 : :
18096 : : static struct unit_test_suite cryptodev_multi_session_testsuite = {
18097 : : .suite_name = "Multi Session Unit Test Suite",
18098 : : .setup = multi_session_testsuite_setup,
18099 : : .unit_test_cases = {
18100 : : TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
18101 : : TEST_CASE_ST(ut_setup, ut_teardown,
18102 : : test_multi_session_random_usage),
18103 : :
18104 : : TEST_CASES_END() /**< NULL terminate unit test array */
18105 : : }
18106 : : };
18107 : :
18108 : : static struct unit_test_suite cryptodev_null_testsuite = {
18109 : : .suite_name = "NULL Test Suite",
18110 : : .setup = null_testsuite_setup,
18111 : : .unit_test_cases = {
18112 : : TEST_CASE_ST(ut_setup, ut_teardown,
18113 : : test_null_invalid_operation),
18114 : : TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
18115 : : TEST_CASES_END()
18116 : : }
18117 : : };
18118 : :
18119 : : static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite = {
18120 : : .suite_name = "AES CCM Authenticated Test Suite",
18121 : : .setup = aes_ccm_auth_testsuite_setup,
18122 : : .unit_test_cases = {
18123 : : /** AES CCM Authenticated Encryption 128 bits key*/
18124 : : TEST_CASE_ST(ut_setup, ut_teardown,
18125 : : test_AES_CCM_authenticated_encryption_test_case_128_1),
18126 : : TEST_CASE_ST(ut_setup, ut_teardown,
18127 : : test_AES_CCM_authenticated_encryption_test_case_128_2),
18128 : : TEST_CASE_ST(ut_setup, ut_teardown,
18129 : : test_AES_CCM_authenticated_encryption_test_case_128_3),
18130 : :
18131 : : /** AES CCM Authenticated Decryption 128 bits key*/
18132 : : TEST_CASE_ST(ut_setup, ut_teardown,
18133 : : test_AES_CCM_authenticated_decryption_test_case_128_1),
18134 : : TEST_CASE_ST(ut_setup, ut_teardown,
18135 : : test_AES_CCM_authenticated_decryption_test_case_128_2),
18136 : : TEST_CASE_ST(ut_setup, ut_teardown,
18137 : : test_AES_CCM_authenticated_decryption_test_case_128_3),
18138 : :
18139 : : /** AES CCM Authenticated Encryption 192 bits key */
18140 : : TEST_CASE_ST(ut_setup, ut_teardown,
18141 : : test_AES_CCM_authenticated_encryption_test_case_192_1),
18142 : : TEST_CASE_ST(ut_setup, ut_teardown,
18143 : : test_AES_CCM_authenticated_encryption_test_case_192_2),
18144 : : TEST_CASE_ST(ut_setup, ut_teardown,
18145 : : test_AES_CCM_authenticated_encryption_test_case_192_3),
18146 : :
18147 : : /** AES CCM Authenticated Decryption 192 bits key*/
18148 : : TEST_CASE_ST(ut_setup, ut_teardown,
18149 : : test_AES_CCM_authenticated_decryption_test_case_192_1),
18150 : : TEST_CASE_ST(ut_setup, ut_teardown,
18151 : : test_AES_CCM_authenticated_decryption_test_case_192_2),
18152 : : TEST_CASE_ST(ut_setup, ut_teardown,
18153 : : test_AES_CCM_authenticated_decryption_test_case_192_3),
18154 : :
18155 : : /** AES CCM Authenticated Encryption 256 bits key */
18156 : : TEST_CASE_ST(ut_setup, ut_teardown,
18157 : : test_AES_CCM_authenticated_encryption_test_case_256_1),
18158 : : TEST_CASE_ST(ut_setup, ut_teardown,
18159 : : test_AES_CCM_authenticated_encryption_test_case_256_2),
18160 : : TEST_CASE_ST(ut_setup, ut_teardown,
18161 : : test_AES_CCM_authenticated_encryption_test_case_256_3),
18162 : :
18163 : : /** AES CCM Authenticated Decryption 256 bits key*/
18164 : : TEST_CASE_ST(ut_setup, ut_teardown,
18165 : : test_AES_CCM_authenticated_decryption_test_case_256_1),
18166 : : TEST_CASE_ST(ut_setup, ut_teardown,
18167 : : test_AES_CCM_authenticated_decryption_test_case_256_2),
18168 : : TEST_CASE_ST(ut_setup, ut_teardown,
18169 : : test_AES_CCM_authenticated_decryption_test_case_256_3),
18170 : : TEST_CASES_END()
18171 : : }
18172 : : };
18173 : :
18174 : : static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite = {
18175 : : .suite_name = "AES GCM Authenticated Test Suite",
18176 : : .setup = aes_gcm_auth_testsuite_setup,
18177 : : .unit_test_cases = {
18178 : : /** AES GCM Authenticated Encryption */
18179 : : TEST_CASE_ST(ut_setup, ut_teardown,
18180 : : test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
18181 : : TEST_CASE_ST(ut_setup, ut_teardown,
18182 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
18183 : : TEST_CASE_ST(ut_setup, ut_teardown,
18184 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
18185 : : TEST_CASE_ST(ut_setup, ut_teardown,
18186 : : test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
18187 : : TEST_CASE_ST(ut_setup, ut_teardown,
18188 : : test_AES_GCM_authenticated_encryption_test_case_1),
18189 : : TEST_CASE_ST(ut_setup, ut_teardown,
18190 : : test_AES_GCM_authenticated_encryption_test_case_2),
18191 : : TEST_CASE_ST(ut_setup, ut_teardown,
18192 : : test_AES_GCM_authenticated_encryption_test_case_3),
18193 : : TEST_CASE_ST(ut_setup, ut_teardown,
18194 : : test_AES_GCM_authenticated_encryption_test_case_4),
18195 : : TEST_CASE_ST(ut_setup, ut_teardown,
18196 : : test_AES_GCM_authenticated_encryption_test_case_5),
18197 : : TEST_CASE_ST(ut_setup, ut_teardown,
18198 : : test_AES_GCM_authenticated_encryption_test_case_6),
18199 : : TEST_CASE_ST(ut_setup, ut_teardown,
18200 : : test_AES_GCM_authenticated_encryption_test_case_7),
18201 : : TEST_CASE_ST(ut_setup, ut_teardown,
18202 : : test_AES_GCM_authenticated_encryption_test_case_8),
18203 : : TEST_CASE_ST(ut_setup, ut_teardown,
18204 : : test_AES_GCM_J0_authenticated_encryption_test_case_1),
18205 : :
18206 : : /** AES GCM Authenticated Decryption */
18207 : : TEST_CASE_ST(ut_setup, ut_teardown,
18208 : : test_AES_GCM_authenticated_decryption_test_case_1),
18209 : : TEST_CASE_ST(ut_setup, ut_teardown,
18210 : : test_AES_GCM_authenticated_decryption_test_case_2),
18211 : : TEST_CASE_ST(ut_setup, ut_teardown,
18212 : : test_AES_GCM_authenticated_decryption_test_case_3),
18213 : : TEST_CASE_ST(ut_setup, ut_teardown,
18214 : : test_AES_GCM_authenticated_decryption_test_case_4),
18215 : : TEST_CASE_ST(ut_setup, ut_teardown,
18216 : : test_AES_GCM_authenticated_decryption_test_case_5),
18217 : : TEST_CASE_ST(ut_setup, ut_teardown,
18218 : : test_AES_GCM_authenticated_decryption_test_case_6),
18219 : : TEST_CASE_ST(ut_setup, ut_teardown,
18220 : : test_AES_GCM_authenticated_decryption_test_case_7),
18221 : : TEST_CASE_ST(ut_setup, ut_teardown,
18222 : : test_AES_GCM_authenticated_decryption_test_case_8),
18223 : : TEST_CASE_ST(ut_setup, ut_teardown,
18224 : : test_AES_GCM_J0_authenticated_decryption_test_case_1),
18225 : :
18226 : : /** AES GCM Authenticated Encryption 192 bits key */
18227 : : TEST_CASE_ST(ut_setup, ut_teardown,
18228 : : test_AES_GCM_auth_encryption_test_case_192_1),
18229 : : TEST_CASE_ST(ut_setup, ut_teardown,
18230 : : test_AES_GCM_auth_encryption_test_case_192_2),
18231 : : TEST_CASE_ST(ut_setup, ut_teardown,
18232 : : test_AES_GCM_auth_encryption_test_case_192_3),
18233 : : TEST_CASE_ST(ut_setup, ut_teardown,
18234 : : test_AES_GCM_auth_encryption_test_case_192_4),
18235 : : TEST_CASE_ST(ut_setup, ut_teardown,
18236 : : test_AES_GCM_auth_encryption_test_case_192_5),
18237 : : TEST_CASE_ST(ut_setup, ut_teardown,
18238 : : test_AES_GCM_auth_encryption_test_case_192_6),
18239 : : TEST_CASE_ST(ut_setup, ut_teardown,
18240 : : test_AES_GCM_auth_encryption_test_case_192_7),
18241 : :
18242 : : /** AES GCM Authenticated Decryption 192 bits key */
18243 : : TEST_CASE_ST(ut_setup, ut_teardown,
18244 : : test_AES_GCM_auth_decryption_test_case_192_1),
18245 : : TEST_CASE_ST(ut_setup, ut_teardown,
18246 : : test_AES_GCM_auth_decryption_test_case_192_2),
18247 : : TEST_CASE_ST(ut_setup, ut_teardown,
18248 : : test_AES_GCM_auth_decryption_test_case_192_3),
18249 : : TEST_CASE_ST(ut_setup, ut_teardown,
18250 : : test_AES_GCM_auth_decryption_test_case_192_4),
18251 : : TEST_CASE_ST(ut_setup, ut_teardown,
18252 : : test_AES_GCM_auth_decryption_test_case_192_5),
18253 : : TEST_CASE_ST(ut_setup, ut_teardown,
18254 : : test_AES_GCM_auth_decryption_test_case_192_6),
18255 : : TEST_CASE_ST(ut_setup, ut_teardown,
18256 : : test_AES_GCM_auth_decryption_test_case_192_7),
18257 : :
18258 : : /** AES GCM Authenticated Encryption 256 bits key */
18259 : : TEST_CASE_ST(ut_setup, ut_teardown,
18260 : : test_AES_GCM_auth_encryption_test_case_256_1),
18261 : : TEST_CASE_ST(ut_setup, ut_teardown,
18262 : : test_AES_GCM_auth_encryption_test_case_256_2),
18263 : : TEST_CASE_ST(ut_setup, ut_teardown,
18264 : : test_AES_GCM_auth_encryption_test_case_256_3),
18265 : : TEST_CASE_ST(ut_setup, ut_teardown,
18266 : : test_AES_GCM_auth_encryption_test_case_256_4),
18267 : : TEST_CASE_ST(ut_setup, ut_teardown,
18268 : : test_AES_GCM_auth_encryption_test_case_256_5),
18269 : : TEST_CASE_ST(ut_setup, ut_teardown,
18270 : : test_AES_GCM_auth_encryption_test_case_256_6),
18271 : : TEST_CASE_ST(ut_setup, ut_teardown,
18272 : : test_AES_GCM_auth_encryption_test_case_256_7),
18273 : : TEST_CASE_ST(ut_setup, ut_teardown,
18274 : : test_AES_GCM_auth_encryption_test_case_256_8),
18275 : :
18276 : : /** AES GCM Authenticated Decryption 256 bits key */
18277 : : TEST_CASE_ST(ut_setup, ut_teardown,
18278 : : test_AES_GCM_auth_decryption_test_case_256_1),
18279 : : TEST_CASE_ST(ut_setup, ut_teardown,
18280 : : test_AES_GCM_auth_decryption_test_case_256_2),
18281 : : TEST_CASE_ST(ut_setup, ut_teardown,
18282 : : test_AES_GCM_auth_decryption_test_case_256_3),
18283 : : TEST_CASE_ST(ut_setup, ut_teardown,
18284 : : test_AES_GCM_auth_decryption_test_case_256_4),
18285 : : TEST_CASE_ST(ut_setup, ut_teardown,
18286 : : test_AES_GCM_auth_decryption_test_case_256_5),
18287 : : TEST_CASE_ST(ut_setup, ut_teardown,
18288 : : test_AES_GCM_auth_decryption_test_case_256_6),
18289 : : TEST_CASE_ST(ut_setup, ut_teardown,
18290 : : test_AES_GCM_auth_decryption_test_case_256_7),
18291 : : TEST_CASE_ST(ut_setup, ut_teardown,
18292 : : test_AES_GCM_auth_decryption_test_case_256_8),
18293 : :
18294 : : /** AES GCM Authenticated Encryption big aad size */
18295 : : TEST_CASE_ST(ut_setup, ut_teardown,
18296 : : test_AES_GCM_auth_encryption_test_case_aad_1),
18297 : : TEST_CASE_ST(ut_setup, ut_teardown,
18298 : : test_AES_GCM_auth_encryption_test_case_aad_2),
18299 : :
18300 : : /** AES GCM Authenticated Decryption big aad size */
18301 : : TEST_CASE_ST(ut_setup, ut_teardown,
18302 : : test_AES_GCM_auth_decryption_test_case_aad_1),
18303 : : TEST_CASE_ST(ut_setup, ut_teardown,
18304 : : test_AES_GCM_auth_decryption_test_case_aad_2),
18305 : :
18306 : : /** Out of place tests */
18307 : : TEST_CASE_ST(ut_setup, ut_teardown,
18308 : : test_AES_GCM_authenticated_encryption_oop_test_case_1),
18309 : : TEST_CASE_ST(ut_setup, ut_teardown,
18310 : : test_AES_GCM_authenticated_decryption_oop_test_case_1),
18311 : :
18312 : : /** Session-less tests */
18313 : : TEST_CASE_ST(ut_setup, ut_teardown,
18314 : : test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
18315 : : TEST_CASE_ST(ut_setup, ut_teardown,
18316 : : test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
18317 : :
18318 : : /** AES GCM external mbuf tests */
18319 : : TEST_CASE_ST(ut_setup, ut_teardown,
18320 : : test_AES_GCM_authenticated_encryption_test_case_3_ext_mbuf),
18321 : : TEST_CASE_ST(ut_setup, ut_teardown,
18322 : : test_AES_GCM_authenticated_decryption_test_case_3_ext_mbuf),
18323 : :
18324 : : TEST_CASES_END()
18325 : : }
18326 : : };
18327 : :
18328 : : static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite = {
18329 : : .suite_name = "AES GMAC Authentication Test Suite",
18330 : : .setup = aes_gmac_auth_testsuite_setup,
18331 : : .unit_test_cases = {
18332 : : TEST_CASE_ST(ut_setup, ut_teardown,
18333 : : test_AES_GMAC_authentication_test_case_1),
18334 : : TEST_CASE_ST(ut_setup, ut_teardown,
18335 : : test_AES_GMAC_authentication_verify_test_case_1),
18336 : : TEST_CASE_ST(ut_setup, ut_teardown,
18337 : : test_AES_GMAC_authentication_test_case_2),
18338 : : TEST_CASE_ST(ut_setup, ut_teardown,
18339 : : test_AES_GMAC_authentication_verify_test_case_2),
18340 : : TEST_CASE_ST(ut_setup, ut_teardown,
18341 : : test_AES_GMAC_authentication_test_case_3),
18342 : : TEST_CASE_ST(ut_setup, ut_teardown,
18343 : : test_AES_GMAC_authentication_verify_test_case_3),
18344 : : TEST_CASE_ST(ut_setup, ut_teardown,
18345 : : test_AES_GMAC_authentication_test_case_4),
18346 : : TEST_CASE_ST(ut_setup, ut_teardown,
18347 : : test_AES_GMAC_authentication_verify_test_case_4),
18348 : : TEST_CASE_ST(ut_setup, ut_teardown,
18349 : : test_AES_GMAC_authentication_SGL_40B),
18350 : : TEST_CASE_ST(ut_setup, ut_teardown,
18351 : : test_AES_GMAC_authentication_SGL_80B),
18352 : : TEST_CASE_ST(ut_setup, ut_teardown,
18353 : : test_AES_GMAC_authentication_SGL_2048B),
18354 : : TEST_CASE_ST(ut_setup, ut_teardown,
18355 : : test_AES_GMAC_authentication_SGL_2047B),
18356 : :
18357 : : TEST_CASES_END()
18358 : : }
18359 : : };
18360 : :
18361 : : static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite = {
18362 : : .suite_name = "Chacha20-Poly1305 Test Suite",
18363 : : .setup = chacha20_poly1305_testsuite_setup,
18364 : : .unit_test_cases = {
18365 : : TEST_CASE_ST(ut_setup, ut_teardown,
18366 : : test_chacha20_poly1305_encrypt_test_case_rfc8439),
18367 : : TEST_CASE_ST(ut_setup, ut_teardown,
18368 : : test_chacha20_poly1305_decrypt_test_case_rfc8439),
18369 : : TEST_CASE_ST(ut_setup, ut_teardown,
18370 : : test_chacha20_poly1305_encrypt_SGL_out_of_place),
18371 : : TEST_CASES_END()
18372 : : }
18373 : : };
18374 : :
18375 : : static struct unit_test_suite cryptodev_snow3g_testsuite = {
18376 : : .suite_name = "SNOW 3G Test Suite",
18377 : : .setup = snow3g_testsuite_setup,
18378 : : .unit_test_cases = {
18379 : : /** SNOW 3G encrypt only (UEA2) */
18380 : : TEST_CASE_ST(ut_setup, ut_teardown,
18381 : : test_snow3g_encryption_test_case_1),
18382 : : TEST_CASE_ST(ut_setup, ut_teardown,
18383 : : test_snow3g_encryption_test_case_2),
18384 : : TEST_CASE_ST(ut_setup, ut_teardown,
18385 : : test_snow3g_encryption_test_case_3),
18386 : : TEST_CASE_ST(ut_setup, ut_teardown,
18387 : : test_snow3g_encryption_test_case_4),
18388 : : TEST_CASE_ST(ut_setup, ut_teardown,
18389 : : test_snow3g_encryption_test_case_5),
18390 : :
18391 : : TEST_CASE_ST(ut_setup, ut_teardown,
18392 : : test_snow3g_encryption_test_case_1_oop),
18393 : : TEST_CASE_ST(ut_setup, ut_teardown,
18394 : : test_snow3g_encryption_test_case_1_oop_sgl),
18395 : : TEST_CASE_ST(ut_setup, ut_teardown,
18396 : : test_snow3g_encryption_test_case_1_oop_lb_in_sgl_out),
18397 : : TEST_CASE_ST(ut_setup, ut_teardown,
18398 : : test_snow3g_encryption_test_case_1_oop_sgl_in_lb_out),
18399 : : TEST_CASE_ST(ut_setup, ut_teardown,
18400 : : test_snow3g_encryption_test_case_1_offset_oop),
18401 : : TEST_CASE_ST(ut_setup, ut_teardown,
18402 : : test_snow3g_decryption_test_case_1_oop),
18403 : :
18404 : : /** SNOW 3G generate auth, then encrypt (UEA2) */
18405 : : TEST_CASE_ST(ut_setup, ut_teardown,
18406 : : test_snow3g_auth_cipher_test_case_1),
18407 : : TEST_CASE_ST(ut_setup, ut_teardown,
18408 : : test_snow3g_auth_cipher_test_case_2),
18409 : : TEST_CASE_ST(ut_setup, ut_teardown,
18410 : : test_snow3g_auth_cipher_test_case_2_oop),
18411 : : TEST_CASE_ST(ut_setup, ut_teardown,
18412 : : test_snow3g_auth_cipher_part_digest_enc),
18413 : : TEST_CASE_ST(ut_setup, ut_teardown,
18414 : : test_snow3g_auth_cipher_part_digest_enc_oop),
18415 : : TEST_CASE_ST(ut_setup, ut_teardown,
18416 : : test_snow3g_auth_cipher_test_case_3_sgl),
18417 : : TEST_CASE_ST(ut_setup, ut_teardown,
18418 : : test_snow3g_auth_cipher_test_case_3_oop_sgl),
18419 : : TEST_CASE_ST(ut_setup, ut_teardown,
18420 : : test_snow3g_auth_cipher_part_digest_enc_sgl),
18421 : : TEST_CASE_ST(ut_setup, ut_teardown,
18422 : : test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
18423 : : TEST_CASE_ST(ut_setup, ut_teardown,
18424 : : test_snow3g_auth_cipher_total_digest_enc_1),
18425 : : TEST_CASE_ST(ut_setup, ut_teardown,
18426 : : test_snow3g_auth_cipher_total_digest_enc_1_oop),
18427 : : TEST_CASE_ST(ut_setup, ut_teardown,
18428 : : test_snow3g_auth_cipher_total_digest_enc_1_sgl),
18429 : : TEST_CASE_ST(ut_setup, ut_teardown,
18430 : : test_snow3g_auth_cipher_total_digest_enc_1_oop_sgl),
18431 : :
18432 : : /** SNOW 3G decrypt (UEA2), then verify auth */
18433 : : TEST_CASE_ST(ut_setup, ut_teardown,
18434 : : test_snow3g_auth_cipher_verify_test_case_1),
18435 : : TEST_CASE_ST(ut_setup, ut_teardown,
18436 : : test_snow3g_auth_cipher_verify_test_case_2),
18437 : : TEST_CASE_ST(ut_setup, ut_teardown,
18438 : : test_snow3g_auth_cipher_verify_test_case_2_oop),
18439 : : TEST_CASE_ST(ut_setup, ut_teardown,
18440 : : test_snow3g_auth_cipher_verify_part_digest_enc),
18441 : : TEST_CASE_ST(ut_setup, ut_teardown,
18442 : : test_snow3g_auth_cipher_verify_part_digest_enc_oop),
18443 : : TEST_CASE_ST(ut_setup, ut_teardown,
18444 : : test_snow3g_auth_cipher_verify_test_case_3_sgl),
18445 : : TEST_CASE_ST(ut_setup, ut_teardown,
18446 : : test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
18447 : : TEST_CASE_ST(ut_setup, ut_teardown,
18448 : : test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
18449 : : TEST_CASE_ST(ut_setup, ut_teardown,
18450 : : test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
18451 : : TEST_CASE_ST(ut_setup, ut_teardown,
18452 : : test_snow3g_auth_cipher_verify_total_digest_enc_1),
18453 : : TEST_CASE_ST(ut_setup, ut_teardown,
18454 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop),
18455 : : TEST_CASE_ST(ut_setup, ut_teardown,
18456 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_sgl),
18457 : : TEST_CASE_ST(ut_setup, ut_teardown,
18458 : : test_snow3g_auth_cipher_verify_total_digest_enc_1_oop_sgl),
18459 : :
18460 : : /** SNOW 3G decrypt only (UEA2) */
18461 : : TEST_CASE_ST(ut_setup, ut_teardown,
18462 : : test_snow3g_decryption_test_case_1),
18463 : : TEST_CASE_ST(ut_setup, ut_teardown,
18464 : : test_snow3g_decryption_test_case_2),
18465 : : TEST_CASE_ST(ut_setup, ut_teardown,
18466 : : test_snow3g_decryption_test_case_3),
18467 : : TEST_CASE_ST(ut_setup, ut_teardown,
18468 : : test_snow3g_decryption_test_case_4),
18469 : : TEST_CASE_ST(ut_setup, ut_teardown,
18470 : : test_snow3g_decryption_test_case_5),
18471 : : TEST_CASE_ST(ut_setup, ut_teardown,
18472 : : test_snow3g_decryption_with_digest_test_case_1),
18473 : : TEST_CASE_ST(ut_setup, ut_teardown,
18474 : : test_snow3g_hash_generate_test_case_1),
18475 : : TEST_CASE_ST(ut_setup, ut_teardown,
18476 : : test_snow3g_hash_generate_test_case_2),
18477 : : TEST_CASE_ST(ut_setup, ut_teardown,
18478 : : test_snow3g_hash_generate_test_case_3),
18479 : :
18480 : : /* Tests with buffers which length is not byte-aligned */
18481 : : TEST_CASE_ST(ut_setup, ut_teardown,
18482 : : test_snow3g_hash_generate_test_case_4),
18483 : : TEST_CASE_ST(ut_setup, ut_teardown,
18484 : : test_snow3g_hash_generate_test_case_5),
18485 : : TEST_CASE_ST(ut_setup, ut_teardown,
18486 : : test_snow3g_hash_generate_test_case_6),
18487 : : TEST_CASE_ST(ut_setup, ut_teardown,
18488 : : test_snow3g_hash_verify_test_case_1),
18489 : : TEST_CASE_ST(ut_setup, ut_teardown,
18490 : : test_snow3g_hash_verify_test_case_2),
18491 : : TEST_CASE_ST(ut_setup, ut_teardown,
18492 : : test_snow3g_hash_verify_test_case_3),
18493 : :
18494 : : /* Tests with buffers which length is not byte-aligned */
18495 : : TEST_CASE_ST(ut_setup, ut_teardown,
18496 : : test_snow3g_hash_verify_test_case_4),
18497 : : TEST_CASE_ST(ut_setup, ut_teardown,
18498 : : test_snow3g_hash_verify_test_case_5),
18499 : : TEST_CASE_ST(ut_setup, ut_teardown,
18500 : : test_snow3g_hash_verify_test_case_6),
18501 : : TEST_CASE_ST(ut_setup, ut_teardown,
18502 : : test_snow3g_cipher_auth_test_case_1),
18503 : : TEST_CASE_ST(ut_setup, ut_teardown,
18504 : : test_snow3g_auth_cipher_with_digest_test_case_1),
18505 : : TEST_CASES_END()
18506 : : }
18507 : : };
18508 : :
18509 : : static struct unit_test_suite cryptodev_zuc_testsuite = {
18510 : : .suite_name = "ZUC Test Suite",
18511 : : .setup = zuc_testsuite_setup,
18512 : : .unit_test_cases = {
18513 : : /** ZUC encrypt only (EEA3) */
18514 : : TEST_CASE_ST(ut_setup, ut_teardown,
18515 : : test_zuc_encryption_test_case_1),
18516 : : TEST_CASE_ST(ut_setup, ut_teardown,
18517 : : test_zuc_encryption_test_case_2),
18518 : : TEST_CASE_ST(ut_setup, ut_teardown,
18519 : : test_zuc_encryption_test_case_3),
18520 : : TEST_CASE_ST(ut_setup, ut_teardown,
18521 : : test_zuc_encryption_test_case_4),
18522 : : TEST_CASE_ST(ut_setup, ut_teardown,
18523 : : test_zuc_encryption_test_case_5),
18524 : : TEST_CASE_ST(ut_setup, ut_teardown,
18525 : : test_zuc_encryption_test_case_6_sgl),
18526 : :
18527 : : /** ZUC decrypt only (EEA3) */
18528 : : TEST_CASE_ST(ut_setup, ut_teardown,
18529 : : test_zuc_decryption_test_case_1),
18530 : : TEST_CASE_ST(ut_setup, ut_teardown,
18531 : : test_zuc_decryption_test_case_2),
18532 : : TEST_CASE_ST(ut_setup, ut_teardown,
18533 : : test_zuc_decryption_test_case_3),
18534 : : TEST_CASE_ST(ut_setup, ut_teardown,
18535 : : test_zuc_decryption_test_case_4),
18536 : : TEST_CASE_ST(ut_setup, ut_teardown,
18537 : : test_zuc_decryption_test_case_5),
18538 : : TEST_CASE_ST(ut_setup, ut_teardown,
18539 : : test_zuc_decryption_test_case_6_sgl),
18540 : :
18541 : : /** ZUC authenticate (EIA3) */
18542 : : TEST_CASE_ST(ut_setup, ut_teardown,
18543 : : test_zuc_hash_generate_test_case_1),
18544 : : TEST_CASE_ST(ut_setup, ut_teardown,
18545 : : test_zuc_hash_generate_test_case_2),
18546 : : TEST_CASE_ST(ut_setup, ut_teardown,
18547 : : test_zuc_hash_generate_test_case_3),
18548 : : TEST_CASE_ST(ut_setup, ut_teardown,
18549 : : test_zuc_hash_generate_test_case_4),
18550 : : TEST_CASE_ST(ut_setup, ut_teardown,
18551 : : test_zuc_hash_generate_test_case_5),
18552 : : TEST_CASE_ST(ut_setup, ut_teardown,
18553 : : test_zuc_hash_generate_test_case_6),
18554 : : TEST_CASE_ST(ut_setup, ut_teardown,
18555 : : test_zuc_hash_generate_test_case_7),
18556 : : TEST_CASE_ST(ut_setup, ut_teardown,
18557 : : test_zuc_hash_generate_test_case_8),
18558 : :
18559 : : /** ZUC verify (EIA3) */
18560 : : TEST_CASE_ST(ut_setup, ut_teardown,
18561 : : test_zuc_hash_verify_test_case_1),
18562 : : TEST_CASE_ST(ut_setup, ut_teardown,
18563 : : test_zuc_hash_verify_test_case_2),
18564 : : TEST_CASE_ST(ut_setup, ut_teardown,
18565 : : test_zuc_hash_verify_test_case_3),
18566 : : TEST_CASE_ST(ut_setup, ut_teardown,
18567 : : test_zuc_hash_verify_test_case_4),
18568 : : TEST_CASE_ST(ut_setup, ut_teardown,
18569 : : test_zuc_hash_verify_test_case_5),
18570 : : TEST_CASE_ST(ut_setup, ut_teardown,
18571 : : test_zuc_hash_verify_test_case_6),
18572 : : TEST_CASE_ST(ut_setup, ut_teardown,
18573 : : test_zuc_hash_verify_test_case_7),
18574 : : TEST_CASE_ST(ut_setup, ut_teardown,
18575 : : test_zuc_hash_verify_test_case_8),
18576 : :
18577 : : /** ZUC alg-chain (EEA3/EIA3) */
18578 : : TEST_CASE_ST(ut_setup, ut_teardown,
18579 : : test_zuc_cipher_auth_test_case_1),
18580 : : TEST_CASE_ST(ut_setup, ut_teardown,
18581 : : test_zuc_cipher_auth_test_case_2),
18582 : :
18583 : : /** ZUC generate auth, then encrypt (EEA3) */
18584 : : TEST_CASE_ST(ut_setup, ut_teardown,
18585 : : test_zuc_auth_cipher_test_case_1),
18586 : : TEST_CASE_ST(ut_setup, ut_teardown,
18587 : : test_zuc_auth_cipher_test_case_1_oop),
18588 : : TEST_CASE_ST(ut_setup, ut_teardown,
18589 : : test_zuc_auth_cipher_test_case_1_sgl),
18590 : : TEST_CASE_ST(ut_setup, ut_teardown,
18591 : : test_zuc_auth_cipher_test_case_1_oop_sgl),
18592 : : TEST_CASE_ST(ut_setup, ut_teardown,
18593 : : test_zuc_auth_cipher_test_case_2),
18594 : : TEST_CASE_ST(ut_setup, ut_teardown,
18595 : : test_zuc_auth_cipher_test_case_2_oop),
18596 : :
18597 : : /** ZUC decrypt (EEA3), then verify auth */
18598 : : TEST_CASE_ST(ut_setup, ut_teardown,
18599 : : test_zuc_auth_cipher_verify_test_case_1),
18600 : : TEST_CASE_ST(ut_setup, ut_teardown,
18601 : : test_zuc_auth_cipher_verify_test_case_1_oop),
18602 : : TEST_CASE_ST(ut_setup, ut_teardown,
18603 : : test_zuc_auth_cipher_verify_test_case_1_sgl),
18604 : : TEST_CASE_ST(ut_setup, ut_teardown,
18605 : : test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
18606 : : TEST_CASE_ST(ut_setup, ut_teardown,
18607 : : test_zuc_auth_cipher_verify_test_case_2),
18608 : : TEST_CASE_ST(ut_setup, ut_teardown,
18609 : : test_zuc_auth_cipher_verify_test_case_2_oop),
18610 : :
18611 : : /** ZUC-256 encrypt only **/
18612 : : TEST_CASE_ST(ut_setup, ut_teardown,
18613 : : test_zuc256_encryption_test_case_1),
18614 : : TEST_CASE_ST(ut_setup, ut_teardown,
18615 : : test_zuc256_encryption_test_case_2),
18616 : :
18617 : : /** ZUC-256 decrypt only **/
18618 : : TEST_CASE_ST(ut_setup, ut_teardown,
18619 : : test_zuc256_decryption_test_case_1),
18620 : : TEST_CASE_ST(ut_setup, ut_teardown,
18621 : : test_zuc256_decryption_test_case_2),
18622 : :
18623 : : /** ZUC-256 authentication only **/
18624 : : TEST_CASE_ST(ut_setup, ut_teardown,
18625 : : test_zuc256_hash_generate_4b_tag_test_case_1),
18626 : : TEST_CASE_ST(ut_setup, ut_teardown,
18627 : : test_zuc256_hash_generate_4b_tag_test_case_2),
18628 : : TEST_CASE_ST(ut_setup, ut_teardown,
18629 : : test_zuc256_hash_generate_4b_tag_test_case_3),
18630 : : TEST_CASE_ST(ut_setup, ut_teardown,
18631 : : test_zuc256_hash_generate_8b_tag_test_case_1),
18632 : : TEST_CASE_ST(ut_setup, ut_teardown,
18633 : : test_zuc256_hash_generate_16b_tag_test_case_1),
18634 : :
18635 : : /** ZUC-256 authentication verify only **/
18636 : : TEST_CASE_ST(ut_setup, ut_teardown,
18637 : : test_zuc256_hash_verify_4b_tag_test_case_1),
18638 : : TEST_CASE_ST(ut_setup, ut_teardown,
18639 : : test_zuc256_hash_verify_4b_tag_test_case_2),
18640 : : TEST_CASE_ST(ut_setup, ut_teardown,
18641 : : test_zuc256_hash_verify_4b_tag_test_case_3),
18642 : : TEST_CASE_ST(ut_setup, ut_teardown,
18643 : : test_zuc256_hash_verify_8b_tag_test_case_1),
18644 : : TEST_CASE_ST(ut_setup, ut_teardown,
18645 : : test_zuc256_hash_verify_16b_tag_test_case_1),
18646 : :
18647 : : /** ZUC-256 encrypt and authenticate **/
18648 : : TEST_CASE_ST(ut_setup, ut_teardown,
18649 : : test_zuc256_cipher_auth_4b_tag_test_case_1),
18650 : : TEST_CASE_ST(ut_setup, ut_teardown,
18651 : : test_zuc256_cipher_auth_4b_tag_test_case_2),
18652 : : TEST_CASE_ST(ut_setup, ut_teardown,
18653 : : test_zuc256_cipher_auth_8b_tag_test_case_1),
18654 : : TEST_CASE_ST(ut_setup, ut_teardown,
18655 : : test_zuc256_cipher_auth_16b_tag_test_case_1),
18656 : :
18657 : : /** ZUC-256 generate auth, then encrypt */
18658 : : TEST_CASE_ST(ut_setup, ut_teardown,
18659 : : test_zuc256_auth_cipher_4b_tag_test_case_1),
18660 : : TEST_CASE_ST(ut_setup, ut_teardown,
18661 : : test_zuc256_auth_cipher_4b_tag_test_case_2),
18662 : : TEST_CASE_ST(ut_setup, ut_teardown,
18663 : : test_zuc256_auth_cipher_8b_tag_test_case_1),
18664 : : TEST_CASE_ST(ut_setup, ut_teardown,
18665 : : test_zuc256_auth_cipher_16b_tag_test_case_1),
18666 : :
18667 : : /** ZUC-256 decrypt, then verify auth */
18668 : : TEST_CASE_ST(ut_setup, ut_teardown,
18669 : : test_zuc256_auth_cipher_verify_4b_tag_test_case_1),
18670 : : TEST_CASE_ST(ut_setup, ut_teardown,
18671 : : test_zuc256_auth_cipher_verify_4b_tag_test_case_2),
18672 : : TEST_CASE_ST(ut_setup, ut_teardown,
18673 : : test_zuc256_auth_cipher_verify_8b_tag_test_case_1),
18674 : : TEST_CASE_ST(ut_setup, ut_teardown,
18675 : : test_zuc256_auth_cipher_verify_16b_tag_test_case_1),
18676 : :
18677 : : TEST_CASES_END()
18678 : : }
18679 : : };
18680 : :
18681 : : static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite = {
18682 : : .suite_name = "HMAC_MD5 Authentication Test Suite",
18683 : : .setup = hmac_md5_auth_testsuite_setup,
18684 : : .unit_test_cases = {
18685 : : TEST_CASE_ST(ut_setup, ut_teardown,
18686 : : test_MD5_HMAC_generate_case_1),
18687 : : TEST_CASE_ST(ut_setup, ut_teardown,
18688 : : test_MD5_HMAC_verify_case_1),
18689 : : TEST_CASE_ST(ut_setup, ut_teardown,
18690 : : test_MD5_HMAC_generate_case_2),
18691 : : TEST_CASE_ST(ut_setup, ut_teardown,
18692 : : test_MD5_HMAC_verify_case_2),
18693 : : TEST_CASES_END()
18694 : : }
18695 : : };
18696 : :
18697 : : static struct unit_test_suite cryptodev_kasumi_testsuite = {
18698 : : .suite_name = "Kasumi Test Suite",
18699 : : .setup = kasumi_testsuite_setup,
18700 : : .unit_test_cases = {
18701 : : /** KASUMI hash only (UIA1) */
18702 : : TEST_CASE_ST(ut_setup, ut_teardown,
18703 : : test_kasumi_hash_generate_test_case_1),
18704 : : TEST_CASE_ST(ut_setup, ut_teardown,
18705 : : test_kasumi_hash_generate_test_case_2),
18706 : : TEST_CASE_ST(ut_setup, ut_teardown,
18707 : : test_kasumi_hash_generate_test_case_3),
18708 : : TEST_CASE_ST(ut_setup, ut_teardown,
18709 : : test_kasumi_hash_generate_test_case_4),
18710 : : TEST_CASE_ST(ut_setup, ut_teardown,
18711 : : test_kasumi_hash_generate_test_case_5),
18712 : : TEST_CASE_ST(ut_setup, ut_teardown,
18713 : : test_kasumi_hash_generate_test_case_6),
18714 : :
18715 : : TEST_CASE_ST(ut_setup, ut_teardown,
18716 : : test_kasumi_hash_verify_test_case_1),
18717 : : TEST_CASE_ST(ut_setup, ut_teardown,
18718 : : test_kasumi_hash_verify_test_case_2),
18719 : : TEST_CASE_ST(ut_setup, ut_teardown,
18720 : : test_kasumi_hash_verify_test_case_3),
18721 : : TEST_CASE_ST(ut_setup, ut_teardown,
18722 : : test_kasumi_hash_verify_test_case_4),
18723 : : TEST_CASE_ST(ut_setup, ut_teardown,
18724 : : test_kasumi_hash_verify_test_case_5),
18725 : :
18726 : : /** KASUMI encrypt only (UEA1) */
18727 : : TEST_CASE_ST(ut_setup, ut_teardown,
18728 : : test_kasumi_encryption_test_case_1),
18729 : : TEST_CASE_ST(ut_setup, ut_teardown,
18730 : : test_kasumi_encryption_test_case_1_sgl),
18731 : : TEST_CASE_ST(ut_setup, ut_teardown,
18732 : : test_kasumi_encryption_test_case_1_oop),
18733 : : TEST_CASE_ST(ut_setup, ut_teardown,
18734 : : test_kasumi_encryption_test_case_1_oop_sgl),
18735 : : TEST_CASE_ST(ut_setup, ut_teardown,
18736 : : test_kasumi_encryption_test_case_2),
18737 : : TEST_CASE_ST(ut_setup, ut_teardown,
18738 : : test_kasumi_encryption_test_case_3),
18739 : : TEST_CASE_ST(ut_setup, ut_teardown,
18740 : : test_kasumi_encryption_test_case_4),
18741 : : TEST_CASE_ST(ut_setup, ut_teardown,
18742 : : test_kasumi_encryption_test_case_5),
18743 : :
18744 : : /** KASUMI decrypt only (UEA1) */
18745 : : TEST_CASE_ST(ut_setup, ut_teardown,
18746 : : test_kasumi_decryption_test_case_1),
18747 : : TEST_CASE_ST(ut_setup, ut_teardown,
18748 : : test_kasumi_decryption_test_case_2),
18749 : : TEST_CASE_ST(ut_setup, ut_teardown,
18750 : : test_kasumi_decryption_test_case_3),
18751 : : TEST_CASE_ST(ut_setup, ut_teardown,
18752 : : test_kasumi_decryption_test_case_4),
18753 : : TEST_CASE_ST(ut_setup, ut_teardown,
18754 : : test_kasumi_decryption_test_case_5),
18755 : : TEST_CASE_ST(ut_setup, ut_teardown,
18756 : : test_kasumi_decryption_test_case_1_oop),
18757 : : TEST_CASE_ST(ut_setup, ut_teardown,
18758 : : test_kasumi_cipher_auth_test_case_1),
18759 : :
18760 : : /** KASUMI generate auth, then encrypt (F8) */
18761 : : TEST_CASE_ST(ut_setup, ut_teardown,
18762 : : test_kasumi_auth_cipher_test_case_1),
18763 : : TEST_CASE_ST(ut_setup, ut_teardown,
18764 : : test_kasumi_auth_cipher_test_case_2),
18765 : : TEST_CASE_ST(ut_setup, ut_teardown,
18766 : : test_kasumi_auth_cipher_test_case_2_oop),
18767 : : TEST_CASE_ST(ut_setup, ut_teardown,
18768 : : test_kasumi_auth_cipher_test_case_2_sgl),
18769 : : TEST_CASE_ST(ut_setup, ut_teardown,
18770 : : test_kasumi_auth_cipher_test_case_2_oop_sgl),
18771 : :
18772 : : /** KASUMI decrypt (F8), then verify auth */
18773 : : TEST_CASE_ST(ut_setup, ut_teardown,
18774 : : test_kasumi_auth_cipher_verify_test_case_1),
18775 : : TEST_CASE_ST(ut_setup, ut_teardown,
18776 : : test_kasumi_auth_cipher_verify_test_case_2),
18777 : : TEST_CASE_ST(ut_setup, ut_teardown,
18778 : : test_kasumi_auth_cipher_verify_test_case_2_oop),
18779 : : TEST_CASE_ST(ut_setup, ut_teardown,
18780 : : test_kasumi_auth_cipher_verify_test_case_2_sgl),
18781 : : TEST_CASE_ST(ut_setup, ut_teardown,
18782 : : test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
18783 : :
18784 : : TEST_CASES_END()
18785 : : }
18786 : : };
18787 : :
18788 : : static struct unit_test_suite cryptodev_esn_testsuite = {
18789 : : .suite_name = "ESN Test Suite",
18790 : : .setup = esn_testsuite_setup,
18791 : : .unit_test_cases = {
18792 : : TEST_CASE_ST(ut_setup, ut_teardown,
18793 : : auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
18794 : : TEST_CASE_ST(ut_setup, ut_teardown,
18795 : : auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
18796 : : TEST_CASES_END()
18797 : : }
18798 : : };
18799 : :
18800 : : static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite = {
18801 : : .suite_name = "Negative AES GCM Test Suite",
18802 : : .setup = negative_aes_gcm_testsuite_setup,
18803 : : .unit_test_cases = {
18804 : : TEST_CASE_ST(ut_setup, ut_teardown,
18805 : : test_AES_GCM_auth_encryption_fail_iv_corrupt),
18806 : : TEST_CASE_ST(ut_setup, ut_teardown,
18807 : : test_AES_GCM_auth_encryption_fail_in_data_corrupt),
18808 : : TEST_CASE_ST(ut_setup, ut_teardown,
18809 : : test_AES_GCM_auth_encryption_fail_out_data_corrupt),
18810 : : TEST_CASE_ST(ut_setup, ut_teardown,
18811 : : test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
18812 : : TEST_CASE_ST(ut_setup, ut_teardown,
18813 : : test_AES_GCM_auth_encryption_fail_aad_corrupt),
18814 : : TEST_CASE_ST(ut_setup, ut_teardown,
18815 : : test_AES_GCM_auth_encryption_fail_tag_corrupt),
18816 : : TEST_CASE_ST(ut_setup, ut_teardown,
18817 : : test_AES_GCM_auth_decryption_fail_iv_corrupt),
18818 : : TEST_CASE_ST(ut_setup, ut_teardown,
18819 : : test_AES_GCM_auth_decryption_fail_in_data_corrupt),
18820 : : TEST_CASE_ST(ut_setup, ut_teardown,
18821 : : test_AES_GCM_auth_decryption_fail_out_data_corrupt),
18822 : : TEST_CASE_ST(ut_setup, ut_teardown,
18823 : : test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
18824 : : TEST_CASE_ST(ut_setup, ut_teardown,
18825 : : test_AES_GCM_auth_decryption_fail_aad_corrupt),
18826 : : TEST_CASE_ST(ut_setup, ut_teardown,
18827 : : test_AES_GCM_auth_decryption_fail_tag_corrupt),
18828 : :
18829 : : TEST_CASES_END()
18830 : : }
18831 : : };
18832 : :
18833 : : static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite = {
18834 : : .suite_name = "Negative AES GMAC Test Suite",
18835 : : .setup = negative_aes_gmac_testsuite_setup,
18836 : : .unit_test_cases = {
18837 : : TEST_CASE_ST(ut_setup, ut_teardown,
18838 : : authentication_verify_AES128_GMAC_fail_data_corrupt),
18839 : : TEST_CASE_ST(ut_setup, ut_teardown,
18840 : : authentication_verify_AES128_GMAC_fail_tag_corrupt),
18841 : :
18842 : : TEST_CASES_END()
18843 : : }
18844 : : };
18845 : :
18846 : : static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = {
18847 : : .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
18848 : : .setup = mixed_cipher_hash_testsuite_setup,
18849 : : .unit_test_cases = {
18850 : : /** AUTH AES CMAC + CIPHER AES CTR */
18851 : : TEST_CASE_ST(ut_setup, ut_teardown,
18852 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1),
18853 : : TEST_CASE_ST(ut_setup, ut_teardown,
18854 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
18855 : : TEST_CASE_ST(ut_setup, ut_teardown,
18856 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
18857 : : TEST_CASE_ST(ut_setup, ut_teardown,
18858 : : test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
18859 : : TEST_CASE_ST(ut_setup, ut_teardown,
18860 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
18861 : : TEST_CASE_ST(ut_setup, ut_teardown,
18862 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
18863 : : TEST_CASE_ST(ut_setup, ut_teardown,
18864 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
18865 : : TEST_CASE_ST(ut_setup, ut_teardown,
18866 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
18867 : : TEST_CASE_ST(ut_setup, ut_teardown,
18868 : : test_aes_cmac_aes_ctr_digest_enc_test_case_2),
18869 : : TEST_CASE_ST(ut_setup, ut_teardown,
18870 : : test_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
18871 : : TEST_CASE_ST(ut_setup, ut_teardown,
18872 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2),
18873 : : TEST_CASE_ST(ut_setup, ut_teardown,
18874 : : test_verify_aes_cmac_aes_ctr_digest_enc_test_case_2_oop),
18875 : :
18876 : : /** AUTH ZUC + CIPHER SNOW3G */
18877 : : TEST_CASE_ST(ut_setup, ut_teardown,
18878 : : test_auth_zuc_cipher_snow_test_case_1),
18879 : : TEST_CASE_ST(ut_setup, ut_teardown,
18880 : : test_verify_auth_zuc_cipher_snow_test_case_1),
18881 : : TEST_CASE_ST(ut_setup, ut_teardown,
18882 : : test_auth_zuc_cipher_snow_test_case_1_inplace),
18883 : : TEST_CASE_ST(ut_setup, ut_teardown,
18884 : : test_verify_auth_zuc_cipher_snow_test_case_1_inplace),
18885 : : /** AUTH AES CMAC + CIPHER SNOW3G */
18886 : : TEST_CASE_ST(ut_setup, ut_teardown,
18887 : : test_auth_aes_cmac_cipher_snow_test_case_1),
18888 : : TEST_CASE_ST(ut_setup, ut_teardown,
18889 : : test_verify_auth_aes_cmac_cipher_snow_test_case_1),
18890 : : TEST_CASE_ST(ut_setup, ut_teardown,
18891 : : test_auth_aes_cmac_cipher_snow_test_case_1_inplace),
18892 : : TEST_CASE_ST(ut_setup, ut_teardown,
18893 : : test_verify_auth_aes_cmac_cipher_snow_test_case_1_inplace),
18894 : : /** AUTH ZUC + CIPHER AES CTR */
18895 : : TEST_CASE_ST(ut_setup, ut_teardown,
18896 : : test_auth_zuc_cipher_aes_ctr_test_case_1),
18897 : : TEST_CASE_ST(ut_setup, ut_teardown,
18898 : : test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
18899 : : TEST_CASE_ST(ut_setup, ut_teardown,
18900 : : test_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
18901 : : TEST_CASE_ST(ut_setup, ut_teardown,
18902 : : test_verify_auth_zuc_cipher_aes_ctr_test_case_1_inplace),
18903 : : /** AUTH SNOW3G + CIPHER AES CTR */
18904 : : TEST_CASE_ST(ut_setup, ut_teardown,
18905 : : test_auth_snow_cipher_aes_ctr_test_case_1),
18906 : : TEST_CASE_ST(ut_setup, ut_teardown,
18907 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1),
18908 : : TEST_CASE_ST(ut_setup, ut_teardown,
18909 : : test_auth_snow_cipher_aes_ctr_test_case_1_inplace),
18910 : : TEST_CASE_ST(ut_setup, ut_teardown,
18911 : : test_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
18912 : : TEST_CASE_ST(ut_setup, ut_teardown,
18913 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace),
18914 : : TEST_CASE_ST(ut_setup, ut_teardown,
18915 : : test_verify_auth_snow_cipher_aes_ctr_test_case_1_inplace_sgl),
18916 : : /** AUTH SNOW3G + CIPHER ZUC */
18917 : : TEST_CASE_ST(ut_setup, ut_teardown,
18918 : : test_auth_snow_cipher_zuc_test_case_1),
18919 : : TEST_CASE_ST(ut_setup, ut_teardown,
18920 : : test_verify_auth_snow_cipher_zuc_test_case_1),
18921 : : TEST_CASE_ST(ut_setup, ut_teardown,
18922 : : test_auth_snow_cipher_zuc_test_case_1_inplace),
18923 : : TEST_CASE_ST(ut_setup, ut_teardown,
18924 : : test_verify_auth_snow_cipher_zuc_test_case_1_inplace),
18925 : : /** AUTH AES CMAC + CIPHER ZUC */
18926 : : TEST_CASE_ST(ut_setup, ut_teardown,
18927 : : test_auth_aes_cmac_cipher_zuc_test_case_1),
18928 : : TEST_CASE_ST(ut_setup, ut_teardown,
18929 : : test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
18930 : : TEST_CASE_ST(ut_setup, ut_teardown,
18931 : : test_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
18932 : : TEST_CASE_ST(ut_setup, ut_teardown,
18933 : : test_verify_auth_aes_cmac_cipher_zuc_test_case_1_inplace),
18934 : :
18935 : : /** AUTH NULL + CIPHER SNOW3G */
18936 : : TEST_CASE_ST(ut_setup, ut_teardown,
18937 : : test_auth_null_cipher_snow_test_case_1),
18938 : : TEST_CASE_ST(ut_setup, ut_teardown,
18939 : : test_verify_auth_null_cipher_snow_test_case_1),
18940 : : /** AUTH NULL + CIPHER ZUC */
18941 : : TEST_CASE_ST(ut_setup, ut_teardown,
18942 : : test_auth_null_cipher_zuc_test_case_1),
18943 : : TEST_CASE_ST(ut_setup, ut_teardown,
18944 : : test_verify_auth_null_cipher_zuc_test_case_1),
18945 : : /** AUTH SNOW3G + CIPHER NULL */
18946 : : TEST_CASE_ST(ut_setup, ut_teardown,
18947 : : test_auth_snow_cipher_null_test_case_1),
18948 : : TEST_CASE_ST(ut_setup, ut_teardown,
18949 : : test_verify_auth_snow_cipher_null_test_case_1),
18950 : : /** AUTH ZUC + CIPHER NULL */
18951 : : TEST_CASE_ST(ut_setup, ut_teardown,
18952 : : test_auth_zuc_cipher_null_test_case_1),
18953 : : TEST_CASE_ST(ut_setup, ut_teardown,
18954 : : test_verify_auth_zuc_cipher_null_test_case_1),
18955 : : /** AUTH NULL + CIPHER AES CTR */
18956 : : TEST_CASE_ST(ut_setup, ut_teardown,
18957 : : test_auth_null_cipher_aes_ctr_test_case_1),
18958 : : TEST_CASE_ST(ut_setup, ut_teardown,
18959 : : test_verify_auth_null_cipher_aes_ctr_test_case_1),
18960 : : /** AUTH AES CMAC + CIPHER NULL */
18961 : : TEST_CASE_ST(ut_setup, ut_teardown,
18962 : : test_auth_aes_cmac_cipher_null_test_case_1),
18963 : : TEST_CASE_ST(ut_setup, ut_teardown,
18964 : : test_verify_auth_aes_cmac_cipher_null_test_case_1),
18965 : : TEST_CASES_END()
18966 : : }
18967 : : };
18968 : :
18969 : : static int
18970 : 1 : run_cryptodev_testsuite(const char *pmd_name)
18971 : : {
18972 : : uint8_t ret, j, i = 0, blk_start_idx = 0;
18973 : 1 : const enum blockcipher_test_type blk_suites[] = {
18974 : : BLKCIPHER_AES_CHAIN_TYPE,
18975 : : BLKCIPHER_AES_CIPHERONLY_TYPE,
18976 : : BLKCIPHER_AES_DOCSIS_TYPE,
18977 : : BLKCIPHER_3DES_CHAIN_TYPE,
18978 : : BLKCIPHER_3DES_CIPHERONLY_TYPE,
18979 : : BLKCIPHER_DES_CIPHERONLY_TYPE,
18980 : : BLKCIPHER_DES_DOCSIS_TYPE,
18981 : : BLKCIPHER_SM4_CHAIN_TYPE,
18982 : : BLKCIPHER_SM4_CIPHERONLY_TYPE,
18983 : : BLKCIPHER_AUTHONLY_TYPE};
18984 : 1 : struct unit_test_suite *static_suites[] = {
18985 : : &cryptodev_multi_session_testsuite,
18986 : : &cryptodev_null_testsuite,
18987 : : &cryptodev_aes_ccm_auth_testsuite,
18988 : : &cryptodev_aes_gcm_auth_testsuite,
18989 : : &cryptodev_aes_gmac_auth_testsuite,
18990 : : &cryptodev_snow3g_testsuite,
18991 : : &cryptodev_chacha20_poly1305_testsuite,
18992 : : &cryptodev_zuc_testsuite,
18993 : : &cryptodev_hmac_md5_auth_testsuite,
18994 : : &cryptodev_kasumi_testsuite,
18995 : : &cryptodev_esn_testsuite,
18996 : : &cryptodev_negative_aes_gcm_testsuite,
18997 : : &cryptodev_negative_aes_gmac_testsuite,
18998 : : &cryptodev_mixed_cipher_hash_testsuite,
18999 : : &cryptodev_negative_hmac_sha1_testsuite,
19000 : : &cryptodev_gen_testsuite,
19001 : : #ifdef RTE_LIB_SECURITY
19002 : : &ipsec_proto_testsuite,
19003 : : &pdcp_proto_testsuite,
19004 : : &docsis_proto_testsuite,
19005 : : &tls12_record_proto_testsuite,
19006 : : &dtls12_record_proto_testsuite,
19007 : : &tls13_record_proto_testsuite,
19008 : : #endif
19009 : : &end_testsuite
19010 : : };
19011 : : static struct unit_test_suite ts = {
19012 : : .suite_name = "Cryptodev Unit Test Suite",
19013 : : .setup = testsuite_setup,
19014 : : .teardown = testsuite_teardown,
19015 : : .unit_test_cases = {TEST_CASES_END()}
19016 : : };
19017 : :
19018 : 1 : gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
19019 : :
19020 [ - + ]: 1 : if (gbl_driver_id == -1) {
19021 : 0 : RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
19022 : 0 : return TEST_SKIPPED;
19023 : : }
19024 : :
19025 : 1 : ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
19026 : : (RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
19027 : :
19028 [ + + ]: 11 : ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
19029 [ + + ]: 24 : ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
19030 : 1 : ret = unit_test_suite_runner(&ts);
19031 : :
19032 [ + + ]: 11 : FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
19033 : 1 : free(ts.unit_test_suites);
19034 : 1 : return ret;
19035 : : }
19036 : :
19037 : : static int
19038 : 0 : require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
19039 : : {
19040 : : struct rte_cryptodev_info dev_info;
19041 : : uint8_t i, nb_devs;
19042 : : int driver_id;
19043 : :
19044 : 0 : driver_id = rte_cryptodev_driver_id_get(pmd_name);
19045 [ # # ]: 0 : if (driver_id == -1) {
19046 : 0 : RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
19047 : 0 : return TEST_SKIPPED;
19048 : : }
19049 : :
19050 : 0 : nb_devs = rte_cryptodev_count();
19051 [ # # ]: 0 : if (nb_devs < 1) {
19052 : 0 : RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
19053 : 0 : return TEST_SKIPPED;
19054 : : }
19055 : :
19056 [ # # ]: 0 : for (i = 0; i < nb_devs; i++) {
19057 : 0 : rte_cryptodev_info_get(i, &dev_info);
19058 [ # # ]: 0 : if (dev_info.driver_id == driver_id) {
19059 [ # # ]: 0 : if (!(dev_info.feature_flags & flag)) {
19060 : 0 : RTE_LOG(INFO, USER1, "%s not supported\n",
19061 : : flag_name);
19062 : 0 : return TEST_SKIPPED;
19063 : : }
19064 : : return 0; /* found */
19065 : : }
19066 : : }
19067 : :
19068 : 0 : RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
19069 : 0 : return TEST_SKIPPED;
19070 : : }
19071 : :
19072 : : static int
19073 : 0 : test_cryptodev_qat(void)
19074 : : {
19075 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
19076 : : }
19077 : :
19078 : : static int
19079 : 0 : test_cryptodev_uadk(void)
19080 : : {
19081 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_UADK_PMD));
19082 : : }
19083 : :
19084 : : static int
19085 : 0 : test_cryptodev_virtio(void)
19086 : : {
19087 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
19088 : : }
19089 : :
19090 : : static int
19091 : 0 : test_cryptodev_aesni_mb(void)
19092 : : {
19093 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
19094 : : }
19095 : :
19096 : : static int
19097 : 0 : test_cryptodev_cpu_aesni_mb(void)
19098 : : {
19099 : : int32_t rc;
19100 : 0 : enum rte_security_session_action_type at = gbl_action_type;
19101 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
19102 : 0 : rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
19103 : 0 : gbl_action_type = at;
19104 : 0 : return rc;
19105 : : }
19106 : :
19107 : : static int
19108 : 0 : test_cryptodev_chacha_poly_mb(void)
19109 : : {
19110 : : int32_t rc;
19111 : 0 : enum rte_security_session_action_type at = gbl_action_type;
19112 : 0 : rc = run_cryptodev_testsuite(
19113 : : RTE_STR(CRYPTODEV_NAME_CHACHA20_POLY1305_PMD));
19114 : 0 : gbl_action_type = at;
19115 : 0 : return rc;
19116 : : }
19117 : :
19118 : : static int
19119 : 1 : test_cryptodev_openssl(void)
19120 : : {
19121 : 1 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
19122 : : }
19123 : :
19124 : : static int
19125 : 0 : test_cryptodev_aesni_gcm(void)
19126 : : {
19127 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
19128 : : }
19129 : :
19130 : : static int
19131 : 0 : test_cryptodev_cpu_aesni_gcm(void)
19132 : : {
19133 : : int32_t rc;
19134 : 0 : enum rte_security_session_action_type at = gbl_action_type;
19135 : 0 : gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
19136 : 0 : rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
19137 : 0 : gbl_action_type = at;
19138 : 0 : return rc;
19139 : : }
19140 : :
19141 : : static int
19142 : 0 : test_cryptodev_mlx5(void)
19143 : : {
19144 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
19145 : : }
19146 : :
19147 : : static int
19148 : 0 : test_cryptodev_null(void)
19149 : : {
19150 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
19151 : : }
19152 : :
19153 : : static int
19154 : 0 : test_cryptodev_sw_snow3g(void)
19155 : : {
19156 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
19157 : : }
19158 : :
19159 : : static int
19160 : 0 : test_cryptodev_sw_kasumi(void)
19161 : : {
19162 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
19163 : : }
19164 : :
19165 : : static int
19166 : 0 : test_cryptodev_sw_zuc(void)
19167 : : {
19168 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
19169 : : }
19170 : :
19171 : : static int
19172 : 0 : test_cryptodev_armv8(void)
19173 : : {
19174 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
19175 : : }
19176 : :
19177 : : static int
19178 : 0 : test_cryptodev_mrvl(void)
19179 : : {
19180 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
19181 : : }
19182 : :
19183 : : #ifdef RTE_CRYPTO_SCHEDULER
19184 : :
19185 : : static int
19186 : 0 : test_cryptodev_scheduler(void)
19187 : : {
19188 : : uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
19189 : 0 : const enum blockcipher_test_type blk_suites[] = {
19190 : : BLKCIPHER_AES_CHAIN_TYPE,
19191 : : BLKCIPHER_AES_CIPHERONLY_TYPE,
19192 : : BLKCIPHER_AUTHONLY_TYPE
19193 : : };
19194 : : static struct unit_test_suite scheduler_multicore = {
19195 : : .suite_name = "Scheduler Multicore Unit Test Suite",
19196 : : .setup = scheduler_multicore_testsuite_setup,
19197 : : .teardown = scheduler_mode_testsuite_teardown,
19198 : : .unit_test_cases = {TEST_CASES_END()}
19199 : : };
19200 : : static struct unit_test_suite scheduler_round_robin = {
19201 : : .suite_name = "Scheduler Round Robin Unit Test Suite",
19202 : : .setup = scheduler_roundrobin_testsuite_setup,
19203 : : .teardown = scheduler_mode_testsuite_teardown,
19204 : : .unit_test_cases = {TEST_CASES_END()}
19205 : : };
19206 : : static struct unit_test_suite scheduler_failover = {
19207 : : .suite_name = "Scheduler Failover Unit Test Suite",
19208 : : .setup = scheduler_failover_testsuite_setup,
19209 : : .teardown = scheduler_mode_testsuite_teardown,
19210 : : .unit_test_cases = {TEST_CASES_END()}
19211 : : };
19212 : : static struct unit_test_suite scheduler_pkt_size_distr = {
19213 : : .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
19214 : : .setup = scheduler_pkt_size_distr_testsuite_setup,
19215 : : .teardown = scheduler_mode_testsuite_teardown,
19216 : : .unit_test_cases = {TEST_CASES_END()}
19217 : : };
19218 : 0 : struct unit_test_suite *sched_mode_suites[] = {
19219 : : &scheduler_multicore,
19220 : : &scheduler_round_robin,
19221 : : &scheduler_failover,
19222 : : &scheduler_pkt_size_distr
19223 : : };
19224 : : static struct unit_test_suite scheduler_config = {
19225 : : .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
19226 : : .unit_test_cases = {
19227 : : TEST_CASE(test_scheduler_attach_worker_op),
19228 : : TEST_CASE(test_scheduler_mode_multicore_op),
19229 : : TEST_CASE(test_scheduler_mode_roundrobin_op),
19230 : : TEST_CASE(test_scheduler_mode_failover_op),
19231 : : TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
19232 : : TEST_CASE(test_scheduler_detach_worker_op),
19233 : :
19234 : : TEST_CASES_END() /**< NULL terminate array */
19235 : : }
19236 : : };
19237 : 0 : struct unit_test_suite *static_suites[] = {
19238 : : &scheduler_config,
19239 : : &end_testsuite
19240 : : };
19241 : 0 : struct unit_test_suite *sched_mode_static_suites[] = {
19242 : : #ifdef RTE_LIB_SECURITY
19243 : : &docsis_proto_testsuite,
19244 : : #endif
19245 : : &end_testsuite
19246 : : };
19247 : : static struct unit_test_suite ts = {
19248 : : .suite_name = "Scheduler Unit Test Suite",
19249 : : .setup = scheduler_testsuite_setup,
19250 : : .teardown = testsuite_teardown,
19251 : : .unit_test_cases = {TEST_CASES_END()}
19252 : : };
19253 : :
19254 : 0 : gbl_driver_id = rte_cryptodev_driver_id_get(
19255 : : RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
19256 : :
19257 [ # # ]: 0 : if (gbl_driver_id == -1) {
19258 : 0 : RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
19259 : 0 : return TEST_SKIPPED;
19260 : : }
19261 : :
19262 [ # # ]: 0 : if (rte_cryptodev_driver_id_get(
19263 : : RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
19264 : 0 : RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
19265 : 0 : return TEST_SKIPPED;
19266 : : }
19267 : :
19268 [ # # ]: 0 : for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
19269 : : uint8_t blk_i = 0;
19270 : 0 : sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
19271 : : (struct unit_test_suite *) *
19272 : : (RTE_DIM(blk_suites) +
19273 : : RTE_DIM(sched_mode_static_suites) + 1));
19274 [ # # ]: 0 : ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
19275 : : blk_suites, RTE_DIM(blk_suites));
19276 [ # # ]: 0 : ADD_STATIC_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
19277 : : sched_mode_static_suites,
19278 : : RTE_DIM(sched_mode_static_suites));
19279 : 0 : sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
19280 : : }
19281 : :
19282 : 0 : ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
19283 : : (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
19284 [ # # ]: 0 : ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
19285 : : RTE_DIM(sched_mode_suites));
19286 [ # # ]: 0 : ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
19287 : 0 : ret = unit_test_suite_runner(&ts);
19288 : :
19289 [ # # ]: 0 : for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
19290 [ # # ]: 0 : FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
19291 : : (*sched_mode_suites[sched_i]),
19292 : : RTE_DIM(blk_suites));
19293 : 0 : free(sched_mode_suites[sched_i]->unit_test_suites);
19294 : : }
19295 : 0 : free(ts.unit_test_suites);
19296 : 0 : return ret;
19297 : : }
19298 : :
19299 : 238 : REGISTER_DRIVER_TEST(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
19300 : :
19301 : : #endif
19302 : :
19303 : : static int
19304 : 0 : test_cryptodev_dpaa2_sec(void)
19305 : : {
19306 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
19307 : : }
19308 : :
19309 : : static int
19310 : 0 : test_cryptodev_dpaa_sec(void)
19311 : : {
19312 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
19313 : : }
19314 : :
19315 : : static int
19316 : 0 : test_cryptodev_ccp(void)
19317 : : {
19318 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
19319 : : }
19320 : :
19321 : : static int
19322 : 0 : test_cryptodev_octeontx(void)
19323 : : {
19324 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
19325 : : }
19326 : :
19327 : : static int
19328 : 0 : test_cryptodev_caam_jr(void)
19329 : : {
19330 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
19331 : : }
19332 : :
19333 : : static int
19334 : 0 : test_cryptodev_nitrox(void)
19335 : : {
19336 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
19337 : : }
19338 : :
19339 : : static int
19340 : 0 : test_cryptodev_bcmfs(void)
19341 : : {
19342 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
19343 : : }
19344 : :
19345 : : static int
19346 : 0 : run_cryptodev_raw_testsuite(const char *pmd_name)
19347 : : {
19348 : : int ret;
19349 : :
19350 : 0 : ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP, "RAW API");
19351 [ # # ]: 0 : if (ret)
19352 : : return ret;
19353 : :
19354 : 0 : global_api_test_type = CRYPTODEV_RAW_API_TEST;
19355 : 0 : ret = run_cryptodev_testsuite(pmd_name);
19356 : 0 : global_api_test_type = CRYPTODEV_API_TEST;
19357 : :
19358 : 0 : return ret;
19359 : : }
19360 : :
19361 : : static int
19362 : 0 : test_cryptodev_qat_raw_api(void)
19363 : : {
19364 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
19365 : : }
19366 : :
19367 : : static int
19368 : 0 : test_cryptodev_cn9k(void)
19369 : : {
19370 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
19371 : : }
19372 : :
19373 : : static int
19374 : 0 : test_cryptodev_cn10k(void)
19375 : : {
19376 : 0 : return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
19377 : : }
19378 : :
19379 : : static int
19380 : 0 : test_cryptodev_cn10k_raw_api(void)
19381 : : {
19382 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
19383 : : }
19384 : :
19385 : : static int
19386 : 0 : test_cryptodev_dpaa2_sec_raw_api(void)
19387 : : {
19388 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
19389 : : }
19390 : :
19391 : : static int
19392 : 0 : test_cryptodev_dpaa_sec_raw_api(void)
19393 : : {
19394 : 0 : return run_cryptodev_raw_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
19395 : : }
19396 : :
19397 : 238 : REGISTER_DRIVER_TEST(cryptodev_cn10k_raw_api_autotest,
19398 : : test_cryptodev_cn10k_raw_api);
19399 : 238 : REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_raw_api_autotest,
19400 : : test_cryptodev_dpaa2_sec_raw_api);
19401 : 238 : REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_raw_api_autotest,
19402 : : test_cryptodev_dpaa_sec_raw_api);
19403 : 238 : REGISTER_DRIVER_TEST(cryptodev_qat_raw_api_autotest,
19404 : : test_cryptodev_qat_raw_api);
19405 : 238 : REGISTER_DRIVER_TEST(cryptodev_qat_autotest, test_cryptodev_qat);
19406 : 238 : REGISTER_DRIVER_TEST(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
19407 : 238 : REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_mb_autotest,
19408 : : test_cryptodev_cpu_aesni_mb);
19409 : 238 : REGISTER_DRIVER_TEST(cryptodev_chacha_poly_mb_autotest,
19410 : : test_cryptodev_chacha_poly_mb);
19411 : 238 : REGISTER_DRIVER_TEST(cryptodev_openssl_autotest, test_cryptodev_openssl);
19412 : 238 : REGISTER_DRIVER_TEST(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
19413 : 238 : REGISTER_DRIVER_TEST(cryptodev_cpu_aesni_gcm_autotest,
19414 : : test_cryptodev_cpu_aesni_gcm);
19415 : 238 : REGISTER_DRIVER_TEST(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
19416 : 238 : REGISTER_DRIVER_TEST(cryptodev_null_autotest, test_cryptodev_null);
19417 : 238 : REGISTER_DRIVER_TEST(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
19418 : 238 : REGISTER_DRIVER_TEST(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
19419 : 238 : REGISTER_DRIVER_TEST(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
19420 : 238 : REGISTER_DRIVER_TEST(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
19421 : 238 : REGISTER_DRIVER_TEST(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
19422 : 238 : REGISTER_DRIVER_TEST(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
19423 : 238 : REGISTER_DRIVER_TEST(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
19424 : 238 : REGISTER_DRIVER_TEST(cryptodev_ccp_autotest, test_cryptodev_ccp);
19425 : 238 : REGISTER_DRIVER_TEST(cryptodev_uadk_autotest, test_cryptodev_uadk);
19426 : 238 : REGISTER_DRIVER_TEST(cryptodev_virtio_autotest, test_cryptodev_virtio);
19427 : 238 : REGISTER_DRIVER_TEST(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
19428 : 238 : REGISTER_DRIVER_TEST(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
19429 : 238 : REGISTER_DRIVER_TEST(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
19430 : 238 : REGISTER_DRIVER_TEST(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
19431 : 238 : REGISTER_DRIVER_TEST(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
19432 : 238 : REGISTER_DRIVER_TEST(cryptodev_cn10k_autotest, test_cryptodev_cn10k);
|