Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2015-2017 Intel Corporation
3 : : */
4 : :
5 : : #include <rte_common.h>
6 : : #include <rte_hexdump.h>
7 : : #include <rte_mbuf.h>
8 : : #include <rte_malloc.h>
9 : : #include <rte_memcpy.h>
10 : : #include <rte_pause.h>
11 : :
12 : : #include <rte_crypto.h>
13 : : #include <rte_cryptodev.h>
14 : :
15 : : #include "test.h"
16 : : #include "test_cryptodev.h"
17 : : #include "test_cryptodev_blockcipher.h"
18 : : #include "test_cryptodev_aes_test_vectors.h"
19 : : #include "test_cryptodev_des_test_vectors.h"
20 : : #include "test_cryptodev_hash_test_vectors.h"
21 : : #include "test_cryptodev_sm4_test_vectors.h"
22 : :
23 : : static int
24 : 210 : verify_algo_support(const struct blockcipher_test_case *t,
25 : : const uint8_t dev_id, const uint32_t digest_len)
26 : : {
27 : : int ret = 0;
28 : 210 : const struct blockcipher_test_data *tdata = t->test_data;
29 : : struct rte_cryptodev_sym_capability_idx cap_idx;
30 : : const struct rte_cryptodev_symmetric_capability *capability;
31 : :
32 [ + + ]: 210 : if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER) {
33 : 148 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
34 : 148 : cap_idx.algo.cipher = tdata->crypto_algo;
35 : 148 : capability = rte_cryptodev_sym_capability_get(dev_id, &cap_idx);
36 [ + + ]: 148 : if (capability == NULL)
37 : : return -1;
38 : :
39 [ + - ]: 106 : if (cap_idx.algo.cipher != RTE_CRYPTO_CIPHER_NULL &&
40 [ + - ]: 106 : !(t->test_data->wrapped_key))
41 : 106 : ret = rte_cryptodev_sym_capability_check_cipher(capability,
42 : 106 : tdata->cipher_key.len,
43 : 106 : tdata->iv.len);
44 [ + + ]: 106 : if (ret != 0)
45 : : return -1;
46 : : }
47 : :
48 [ + + ]: 165 : if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH) {
49 : 121 : cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
50 : 121 : cap_idx.algo.auth = tdata->auth_algo;
51 : 121 : capability = rte_cryptodev_sym_capability_get(dev_id, &cap_idx);
52 [ + + ]: 121 : if (capability == NULL)
53 : : return -1;
54 : :
55 [ + - ]: 83 : if (cap_idx.algo.auth != RTE_CRYPTO_AUTH_NULL)
56 : 83 : ret = rte_cryptodev_sym_capability_check_auth(capability,
57 : 83 : tdata->auth_key.len,
58 : : digest_len,
59 : : 0);
60 [ - + ]: 83 : if (ret != 0)
61 : 0 : return -1;
62 : : }
63 : :
64 : : return 0;
65 : : }
66 : :
67 : : static int
68 : 255 : test_blockcipher_one_case(const struct blockcipher_test_case *t,
69 : : struct rte_mempool *mbuf_pool,
70 : : struct rte_mempool *op_mpool,
71 : : struct rte_mempool *sess_mpool,
72 : : uint8_t dev_id,
73 : : char *test_msg)
74 : : {
75 : : struct rte_mbuf *ibuf = NULL;
76 : : struct rte_mbuf *obuf = NULL;
77 : : struct rte_mbuf *iobuf;
78 : : struct rte_crypto_sym_xform *cipher_xform = NULL;
79 : : struct rte_crypto_sym_xform *auth_xform = NULL;
80 : : struct rte_crypto_sym_xform *init_xform = NULL;
81 : : struct rte_crypto_sym_op *sym_op = NULL;
82 : 255 : struct rte_crypto_op *op = NULL;
83 : : struct rte_cryptodev_info dev_info;
84 : : void *sess = NULL;
85 : :
86 : : int status = TEST_SUCCESS;
87 : 255 : const struct blockcipher_test_data *tdata = t->test_data;
88 : 255 : uint8_t *cipher_key = alloca(tdata->cipher_key.len);
89 : 255 : uint8_t *auth_key = alloca(tdata->auth_key.len);
90 : 255 : uint32_t buf_len = tdata->ciphertext.len;
91 : 255 : uint32_t digest_len = tdata->digest.len;
92 : : char *buf_p = NULL;
93 : : uint8_t src_pattern = 0xa5;
94 : : uint8_t dst_pattern = 0xb6;
95 : : uint8_t tmp_src_buf[MBUF_SIZE];
96 : : uint8_t tmp_dst_buf[MBUF_SIZE];
97 : : uint32_t pad_len;
98 : :
99 : : int nb_segs_in = 1;
100 : : int nb_segs_out = 1;
101 : 255 : uint64_t sgl_type = t->sgl_flag;
102 : : uint32_t nb_iterates = 0;
103 : :
104 : 255 : rte_cryptodev_info_get(dev_id, &dev_info);
105 : 255 : uint64_t feat_flags = dev_info.feature_flags;
106 : :
107 [ + + ]: 255 : if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS) {
108 [ - + ]: 14 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
109 : : printf("Device doesn't support sessionless operations "
110 : : "Test Skipped.\n");
111 : : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
112 : : "SKIPPED");
113 : 0 : return TEST_SKIPPED;
114 : : }
115 : : }
116 [ + + ]: 255 : if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_DIGEST_ENCRYPTED) {
117 [ + - ]: 11 : if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
118 : : printf("Device doesn't support encrypted digest "
119 : : "Test Skipped.\n");
120 : : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
121 : : "SKIPPED");
122 : 11 : return TEST_SKIPPED;
123 : : }
124 : : }
125 [ + + ]: 244 : if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SG) {
126 [ + + ]: 46 : if (sgl_type == 0) {
127 [ + - ]: 2 : if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP)
128 : : sgl_type = RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT;
129 : : else
130 : : sgl_type = RTE_CRYPTODEV_FF_IN_PLACE_SGL;
131 : : }
132 : :
133 [ + + ]: 46 : if (!(feat_flags & sgl_type)) {
134 : : printf("Device doesn't support scatter-gather type."
135 : : " Test Skipped.\n");
136 : : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
137 : : "SKIPPED");
138 : 18 : return TEST_SKIPPED;
139 : : }
140 : :
141 : 28 : if (sgl_type == RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT ||
142 [ + + + - ]: 28 : sgl_type == RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT ||
143 : : sgl_type == RTE_CRYPTODEV_FF_IN_PLACE_SGL)
144 [ + + ]: 28 : nb_segs_in = t->sgl_segs == 0 ? 3 : t->sgl_segs;
145 : :
146 [ - + ]: 28 : if (sgl_type == RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT ||
147 : : sgl_type == RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)
148 [ # # ]: 0 : nb_segs_out = t->sgl_segs == 0 ? 3 : t->sgl_segs;
149 : : }
150 : :
151 : 226 : if (!!(feat_flags & RTE_CRYPTODEV_FF_CIPHER_WRAPPED_KEY) ^
152 [ + + ]: 226 : tdata->wrapped_key) {
153 : : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
154 : : "SKIPPED");
155 : 16 : return TEST_SKIPPED;
156 : : }
157 : :
158 [ - + ]: 210 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST &&
159 [ # # ]: 0 : !(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)) {
160 : : printf("Device doesn't support raw data-path APIs. "
161 : : "Test Skipped.\n");
162 : : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "SKIPPED");
163 : 0 : return TEST_SKIPPED;
164 : : }
165 : :
166 [ + + ]: 210 : if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP) {
167 : : uint64_t oop_flags = RTE_CRYPTODEV_FF_OOP_LB_IN_LB_OUT |
168 : : RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT |
169 : : RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT |
170 : : RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT;
171 [ - + ]: 32 : if (!(feat_flags & oop_flags)) {
172 : : printf("Device doesn't support out-of-place operations."
173 : : "Test Skipped.\n");
174 : : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
175 : : "SKIPPED");
176 : 0 : return TEST_SKIPPED;
177 : : }
178 [ - + ]: 32 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
179 : : printf("Raw Data Path APIs do not support OOP, "
180 : : "Test Skipped.\n");
181 : : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "SKIPPED");
182 : : status = TEST_SKIPPED;
183 : 0 : goto error_exit;
184 : : }
185 : : }
186 : :
187 [ + + ]: 210 : if (tdata->cipher_key.len)
188 : 128 : memcpy(cipher_key, tdata->cipher_key.data,
189 : : tdata->cipher_key.len);
190 [ + + ]: 210 : if (tdata->auth_key.len)
191 : 96 : memcpy(auth_key, tdata->auth_key.data,
192 : : tdata->auth_key.len);
193 : :
194 : : /* Check if PMD is capable of performing that test */
195 [ + + ]: 210 : if (verify_algo_support(t, dev_id, digest_len) < 0) {
196 : 83 : RTE_LOG(DEBUG, USER1,
197 : : "Device does not support this algorithm."
198 : : "Test Skipped.\n");
199 : : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "SKIPPED");
200 : 83 : return TEST_SKIPPED;
201 : : }
202 : :
203 : : /* preparing data */
204 [ + + ]: 127 : if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH)
205 : 83 : buf_len += digest_len;
206 : :
207 : 127 : pad_len = RTE_ALIGN(buf_len, 16) - buf_len;
208 [ - + ]: 127 : if (t->op_mask & BLOCKCIPHER_TEST_OP_DIGEST_ENCRYPTED)
209 : : buf_len += pad_len;
210 : :
211 : : /* for contiguous mbuf, nb_segs is 1 */
212 : 127 : ibuf = create_segmented_mbuf(mbuf_pool,
213 : 127 : tdata->ciphertext.len, nb_segs_in, src_pattern);
214 [ - + ]: 127 : if (ibuf == NULL) {
215 : : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
216 : : "line %u FAILED: %s",
217 : : __LINE__, "Cannot create source mbuf");
218 : : status = TEST_FAILED;
219 : 0 : goto error_exit;
220 : : }
221 : :
222 : : /* only encryption requires plaintext.data input,
223 : : * decryption/(digest gen)/(digest verify) use ciphertext.data
224 : : * to be computed
225 : : */
226 [ + + ]: 127 : if (t->op_mask & BLOCKCIPHER_TEST_OP_ENCRYPT)
227 : 50 : pktmbuf_write(ibuf, 0, tdata->plaintext.len,
228 : 50 : tdata->plaintext.data);
229 : : else
230 : 77 : pktmbuf_write(ibuf, 0, tdata->ciphertext.len,
231 : 77 : tdata->ciphertext.data);
232 : :
233 : 127 : buf_p = rte_pktmbuf_append(ibuf, digest_len);
234 [ + + ]: 127 : if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_VERIFY)
235 [ - + ]: 41 : if (t->op_mask & BLOCKCIPHER_TEST_OP_DIGEST_ENCRYPTED)
236 : 0 : rte_memcpy(buf_p,
237 [ # # ]: 0 : tdata->ciphertext.data + tdata->ciphertext.len,
238 : : digest_len);
239 : : else
240 [ - + ]: 41 : rte_memcpy(buf_p, tdata->digest.data, digest_len);
241 : : else
242 : 86 : memset(buf_p, 0, digest_len);
243 [ - + ]: 127 : if (t->op_mask & BLOCKCIPHER_TEST_OP_DIGEST_ENCRYPTED) {
244 : 0 : buf_p = rte_pktmbuf_append(ibuf, pad_len);
245 [ # # ]: 0 : if (!buf_p) {
246 : : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
247 : : "FAILED: %s", __LINE__,
248 : : "No room to append mbuf");
249 : : status = TEST_FAILED;
250 : 0 : goto error_exit;
251 : : }
252 [ # # ]: 0 : if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_VERIFY) {
253 : 0 : const uint8_t *temp_p = tdata->ciphertext.data +
254 : 0 : tdata->ciphertext.len +
255 : : digest_len;
256 [ # # ]: 0 : rte_memcpy(buf_p, temp_p, pad_len);
257 : : } else
258 : 0 : memset(buf_p, 0xa5, pad_len);
259 : : }
260 : :
261 [ + + ]: 127 : if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP) {
262 : 21 : obuf = create_segmented_mbuf(mbuf_pool,
263 : 21 : tdata->ciphertext.len, nb_segs_out, dst_pattern);
264 [ - + ]: 21 : if (!obuf) {
265 : : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
266 : : "FAILED: %s", __LINE__,
267 : : "Allocation of rte_mbuf failed");
268 : : status = TEST_FAILED;
269 : 0 : goto error_exit;
270 : : }
271 [ - + ]: 21 : memset(obuf->buf_addr, dst_pattern, obuf->buf_len);
272 : :
273 [ - + ]: 21 : if (t->op_mask & BLOCKCIPHER_TEST_OP_DIGEST_ENCRYPTED)
274 : 0 : buf_p = rte_pktmbuf_append(obuf, buf_len + pad_len);
275 : : else
276 : 21 : buf_p = rte_pktmbuf_append(obuf, buf_len);
277 [ - + ]: 21 : if (!buf_p) {
278 : : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
279 : : "FAILED: %s", __LINE__,
280 : : "No room to append mbuf");
281 : : status = TEST_FAILED;
282 : 0 : goto error_exit;
283 : : }
284 : 21 : memset(buf_p, 0, buf_len);
285 : : }
286 : :
287 : : /* Generate Crypto op data structure */
288 : 127 : op = rte_crypto_op_alloc(op_mpool, RTE_CRYPTO_OP_TYPE_SYMMETRIC);
289 [ - + ]: 127 : if (!op) {
290 : : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
291 : : "line %u FAILED: %s",
292 : : __LINE__, "Failed to allocate symmetric crypto "
293 : : "operation struct");
294 : : status = TEST_FAILED;
295 : 0 : goto error_exit;
296 : : }
297 : :
298 : : sym_op = op->sym;
299 : :
300 : 148 : iterate:
301 [ + + ]: 148 : if (nb_iterates) {
302 : : struct rte_mbuf *tmp_buf = ibuf;
303 : :
304 : : ibuf = obuf;
305 : : obuf = tmp_buf;
306 : :
307 : : rte_pktmbuf_reset(ibuf);
308 : : rte_pktmbuf_reset(obuf);
309 : :
310 : 21 : rte_pktmbuf_append(ibuf, tdata->ciphertext.len);
311 : :
312 : : /* only encryption requires plaintext.data input,
313 : : * decryption/(digest gen)/(digest verify) use ciphertext.data
314 : : * to be computed
315 : : */
316 [ + + ]: 21 : if (t->op_mask & BLOCKCIPHER_TEST_OP_ENCRYPT)
317 : 11 : pktmbuf_write(ibuf, 0, tdata->plaintext.len,
318 : 11 : tdata->plaintext.data);
319 : : else
320 : 10 : pktmbuf_write(ibuf, 0, tdata->ciphertext.len,
321 : 10 : tdata->ciphertext.data);
322 : :
323 : : buf_p = rte_pktmbuf_append(ibuf, digest_len);
324 [ + + ]: 21 : if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_VERIFY)
325 [ - + ]: 5 : rte_memcpy(buf_p, tdata->digest.data, digest_len);
326 : : else
327 : 16 : memset(buf_p, 0, digest_len);
328 : :
329 : 21 : memset(obuf->buf_addr, dst_pattern, obuf->buf_len);
330 : :
331 : 21 : buf_p = rte_pktmbuf_append(obuf, buf_len);
332 [ - + ]: 21 : if (!buf_p) {
333 : : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
334 : : "FAILED: %s", __LINE__,
335 : : "No room to append mbuf");
336 : : status = TEST_FAILED;
337 : 0 : goto error_exit;
338 : : }
339 : 21 : memset(buf_p, 0, buf_len);
340 : : }
341 : :
342 : 148 : sym_op->m_src = ibuf;
343 : :
344 [ + + ]: 148 : if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP) {
345 : 42 : sym_op->m_dst = obuf;
346 : : iobuf = obuf;
347 : : } else {
348 : 106 : sym_op->m_dst = NULL;
349 : : iobuf = ibuf;
350 : : }
351 : :
352 : : /* sessionless op requires allocate xform using
353 : : * rte_crypto_op_sym_xforms_alloc(), otherwise rte_zmalloc()
354 : : * is used
355 : : */
356 [ + + ]: 148 : if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS) {
357 : : uint32_t n_xforms = 0;
358 : :
359 [ + - ]: 8 : if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER)
360 : : n_xforms++;
361 [ + - ]: 8 : if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH)
362 : 8 : n_xforms++;
363 : :
364 [ - + ]: 8 : if (rte_crypto_op_sym_xforms_alloc(op, n_xforms)
365 : : == NULL) {
366 : : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
367 : : "FAILED: %s", __LINE__, "Failed to "
368 : : "allocate space for crypto transforms");
369 : : status = TEST_FAILED;
370 : 0 : goto error_exit;
371 : : }
372 : : } else {
373 : 140 : cipher_xform = rte_zmalloc(NULL,
374 : : sizeof(struct rte_crypto_sym_xform), 0);
375 : :
376 : 140 : auth_xform = rte_zmalloc(NULL,
377 : : sizeof(struct rte_crypto_sym_xform), 0);
378 : :
379 [ - + ]: 140 : if (!cipher_xform || !auth_xform) {
380 : : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
381 : : "FAILED: %s", __LINE__, "Failed to "
382 : : "allocate memory for crypto transforms");
383 : : status = TEST_FAILED;
384 : 0 : goto error_exit;
385 : : }
386 : : }
387 : :
388 : : /* preparing xform, for sessioned op, init_xform is initialized
389 : : * here and later as param in rte_cryptodev_sym_session_create() call
390 : : */
391 [ + + ]: 148 : if (t->op_mask == BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN) {
392 [ + + ]: 32 : if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS) {
393 : 6 : cipher_xform = op->sym->xform;
394 : 6 : auth_xform = cipher_xform->next;
395 : 6 : auth_xform->next = NULL;
396 : : } else {
397 : 26 : cipher_xform->next = auth_xform;
398 : 26 : auth_xform->next = NULL;
399 : : init_xform = cipher_xform;
400 : : }
401 : : } else if (t->op_mask == BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC) {
402 [ + + ]: 31 : if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS) {
403 : 2 : auth_xform = op->sym->xform;
404 : 2 : cipher_xform = auth_xform->next;
405 : 2 : cipher_xform->next = NULL;
406 : : } else {
407 : 29 : auth_xform->next = cipher_xform;
408 : 29 : cipher_xform->next = NULL;
409 : : init_xform = auth_xform;
410 : : }
411 : : } else if (t->op_mask == BLOCKCIPHER_TEST_OP_AUTH_GEN_ENC) {
412 [ # # ]: 0 : if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS) {
413 : 0 : auth_xform = op->sym->xform;
414 : 0 : cipher_xform = auth_xform->next;
415 : 0 : cipher_xform->next = NULL;
416 : : } else {
417 : 0 : auth_xform->next = cipher_xform;
418 : 0 : cipher_xform->next = NULL;
419 : : init_xform = auth_xform;
420 : : }
421 : : } else if (t->op_mask == BLOCKCIPHER_TEST_OP_DEC_AUTH_VERIFY) {
422 [ # # ]: 0 : if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS) {
423 : 0 : cipher_xform = op->sym->xform;
424 : 0 : auth_xform = cipher_xform->next;
425 : 0 : auth_xform->next = NULL;
426 : : } else {
427 : 0 : cipher_xform->next = auth_xform;
428 : 0 : auth_xform->next = NULL;
429 : : init_xform = cipher_xform;
430 : : }
431 : : } else if ((t->op_mask == BLOCKCIPHER_TEST_OP_ENCRYPT) ||
432 : : (t->op_mask == BLOCKCIPHER_TEST_OP_DECRYPT)) {
433 [ - + ]: 55 : if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)
434 : 0 : cipher_xform = op->sym->xform;
435 : : else
436 : : init_xform = cipher_xform;
437 : 55 : cipher_xform->next = NULL;
438 : : } else if ((t->op_mask == BLOCKCIPHER_TEST_OP_AUTH_GEN) ||
439 : : (t->op_mask == BLOCKCIPHER_TEST_OP_AUTH_VERIFY)) {
440 [ - + ]: 30 : if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)
441 : 0 : auth_xform = op->sym->xform;
442 : : else
443 : : init_xform = auth_xform;
444 : 30 : auth_xform->next = NULL;
445 : : } else {
446 : : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
447 : : "line %u FAILED: %s",
448 : : __LINE__, "Unrecognized operation");
449 : : status = TEST_FAILED;
450 : 0 : goto error_exit;
451 : : }
452 : :
453 : : /*configure xforms & sym_op cipher and auth data*/
454 [ + + ]: 148 : if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER) {
455 : 118 : cipher_xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
456 : 118 : cipher_xform->cipher.algo = tdata->crypto_algo;
457 [ + + ]: 118 : if (t->op_mask & BLOCKCIPHER_TEST_OP_ENCRYPT)
458 : 61 : cipher_xform->cipher.op =
459 : : RTE_CRYPTO_CIPHER_OP_ENCRYPT;
460 : : else
461 : 57 : cipher_xform->cipher.op =
462 : : RTE_CRYPTO_CIPHER_OP_DECRYPT;
463 : 118 : cipher_xform->cipher.key.data = cipher_key;
464 : 118 : cipher_xform->cipher.key.length = tdata->cipher_key.len;
465 : 118 : cipher_xform->cipher.iv.offset = IV_OFFSET;
466 : 118 : cipher_xform->cipher.dataunit_len = tdata->xts_dataunit_len;
467 : :
468 [ - + ]: 118 : if (tdata->crypto_algo == RTE_CRYPTO_CIPHER_NULL)
469 : 0 : cipher_xform->cipher.iv.length = 0;
470 : : else
471 : 118 : cipher_xform->cipher.iv.length = tdata->iv.len;
472 : :
473 : 118 : sym_op->cipher.data.offset = tdata->cipher_offset;
474 : 118 : sym_op->cipher.data.length = tdata->ciphertext.len -
475 : : tdata->cipher_offset;
476 [ - + ]: 118 : if (t->op_mask & BLOCKCIPHER_TEST_OP_DIGEST_ENCRYPTED) {
477 : 0 : sym_op->cipher.data.length += tdata->digest.len;
478 : 0 : sym_op->cipher.data.length += pad_len;
479 : : }
480 : 118 : rte_memcpy(rte_crypto_op_ctod_offset(op, uint8_t *, IV_OFFSET),
481 : 118 : tdata->iv.data,
482 [ - + ]: 118 : tdata->iv.len);
483 : : }
484 : :
485 [ + + ]: 148 : if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH) {
486 : 93 : uint32_t digest_offset = tdata->ciphertext.len;
487 : :
488 : 93 : auth_xform->type = RTE_CRYPTO_SYM_XFORM_AUTH;
489 : 93 : auth_xform->auth.algo = tdata->auth_algo;
490 : 93 : auth_xform->auth.key.length = tdata->auth_key.len;
491 : 93 : auth_xform->auth.key.data = auth_key;
492 : 93 : auth_xform->auth.digest_length = digest_len;
493 : :
494 [ + + ]: 93 : if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN) {
495 : 47 : auth_xform->auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
496 : 47 : sym_op->auth.digest.data = pktmbuf_mtod_offset
497 : : (iobuf, digest_offset);
498 : 47 : sym_op->auth.digest.phys_addr =
499 : 47 : pktmbuf_iova_offset(iobuf,
500 : : digest_offset);
501 : : } else {
502 : 46 : auth_xform->auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
503 : 46 : sym_op->auth.digest.data = pktmbuf_mtod_offset
504 : : (sym_op->m_src, digest_offset);
505 : 46 : sym_op->auth.digest.phys_addr =
506 : 46 : pktmbuf_iova_offset(sym_op->m_src,
507 : : digest_offset);
508 : : }
509 : :
510 : 93 : sym_op->auth.data.offset = tdata->auth_offset;
511 : 93 : sym_op->auth.data.length = tdata->ciphertext.len -
512 : : tdata->auth_offset;
513 : : }
514 : :
515 : : /**
516 : : * Create session for sessioned op. For mbuf iteration test,
517 : : * skip the session creation for the second iteration.
518 : : */
519 [ + + + + ]: 148 : if (!(t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS) &&
520 : : nb_iterates == 0) {
521 : 120 : sess = rte_cryptodev_sym_session_create(dev_id, init_xform,
522 : : sess_mpool);
523 [ - + ]: 120 : if (sess == NULL) {
524 : : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "UNSUPPORTED");
525 : : status = TEST_SKIPPED;
526 : 0 : goto error_exit;
527 : : }
528 [ - + ]: 120 : if (!sess || status < 0) {
529 : : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
530 : : "FAILED: %s", __LINE__,
531 : : "Session creation failed");
532 : : status = TEST_FAILED;
533 : 0 : goto error_exit;
534 : : }
535 : :
536 : : /* attach symmetric crypto session to crypto operations */
537 [ + - ]: 120 : rte_crypto_op_attach_sym_session(op, sess);
538 : : }
539 : :
540 : 148 : debug_hexdump(stdout, "m_src(before):",
541 : 148 : sym_op->m_src->buf_addr, sym_op->m_src->buf_len);
542 : 148 : rte_memcpy(tmp_src_buf, sym_op->m_src->buf_addr,
543 [ - + ]: 148 : sym_op->m_src->buf_len);
544 [ + + ]: 148 : if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP) {
545 : 42 : debug_hexdump(stdout, "m_dst(before):",
546 : 42 : sym_op->m_dst->buf_addr, sym_op->m_dst->buf_len);
547 : 42 : rte_memcpy(tmp_dst_buf, sym_op->m_dst->buf_addr,
548 [ - + ]: 42 : sym_op->m_dst->buf_len);
549 : : }
550 : :
551 : : /* Process crypto operation */
552 [ - + ]: 148 : if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
553 : : uint8_t is_cipher = 0, is_auth = 0;
554 [ # # ]: 0 : if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER)
555 : : is_cipher = 1;
556 [ # # ]: 0 : if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH)
557 : : is_auth = 1;
558 : :
559 : 0 : status = process_sym_raw_dp_op(dev_id, 0, op, is_cipher, is_auth,
560 : 0 : 0, tdata->iv.len);
561 [ # # ]: 0 : if (status != TEST_SUCCESS) {
562 [ # # ]: 0 : if (status == TEST_SKIPPED)
563 : : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "SKIPPED");
564 : : else
565 : : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "FAILED");
566 : :
567 : 0 : goto error_exit;
568 : : }
569 : : } else {
570 [ - + ]: 148 : if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
571 : : int32_t n_src, n_dst, st, n;
572 : : struct rte_crypto_sym_op *sop;
573 : : union rte_crypto_sym_ofs ofs;
574 : : struct rte_crypto_sgl sgl_src, sgl_dst;
575 : 0 : struct rte_crypto_sym_vec symvec = {0};
576 : : struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
577 : : struct rte_crypto_vec vec_src[UINT8_MAX];
578 : : struct rte_crypto_vec vec_dst[UINT8_MAX];
579 : : uint32_t cipher_offset, cipher_len, auth_offset, auth_len, max_len;
580 : 0 : bool is_oop = op->sym->m_dst != NULL;
581 : :
582 [ # # ]: 0 : if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS) {
583 : : status = TEST_SKIPPED;
584 : 0 : goto error_exit;
585 : : }
586 : :
587 : : sop = op->sym;
588 : 0 : cipher_offset = sop->cipher.data.offset;
589 : 0 : cipher_len = sop->cipher.data.length;
590 : 0 : auth_offset = sop->auth.data.offset;
591 : 0 : auth_len = sop->auth.data.length;
592 : 0 : max_len = RTE_MAX(cipher_offset + cipher_len, auth_offset + auth_len);
593 : :
594 : 0 : n_src = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
595 : : vec_src, RTE_DIM(vec_src));
596 [ # # # # ]: 0 : if (n_src < 0 || n_src != sop->m_src->nb_segs) {
597 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
598 : : status = TEST_FAILED;
599 : 0 : goto error_exit;
600 : : }
601 : 0 : sgl_src.vec = vec_src;
602 : 0 : sgl_src.num = n_src;
603 : 0 : symvec.src_sgl = &sgl_src;
604 [ # # ]: 0 : if (is_oop) {
605 : 0 : n_dst = rte_crypto_mbuf_to_vec(sop->m_dst, 0, max_len,
606 : : vec_dst, RTE_DIM(vec_dst));
607 : 0 : sgl_dst.vec = vec_dst;
608 : 0 : sgl_dst.num = n_dst;
609 : 0 : symvec.dest_sgl = &sgl_dst;
610 : : } else {
611 : 0 : symvec.dest_sgl = NULL;
612 : : }
613 : :
614 : 0 : symvec.iv = &iv_ptr;
615 : 0 : symvec.digest = &digest_ptr;
616 : 0 : symvec.status = &st;
617 : 0 : symvec.num = 1;
618 : 0 : iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
619 : 0 : digest_ptr.va = (void *)sop->auth.digest.data;
620 : 0 : ofs.ofs.cipher.head = cipher_offset;
621 : 0 : ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
622 : 0 : ofs.ofs.auth.head = auth_offset;
623 : 0 : ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
624 : :
625 : 0 : n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
626 : : &symvec);
627 [ # # ]: 0 : if (st == -ENOTSUP) {
628 : : status = TEST_SKIPPED;
629 : 0 : goto error_exit;
630 : : }
631 [ # # ]: 0 : if (n != 1) {
632 : : status = TEST_FAILED;
633 : 0 : op->status = RTE_CRYPTO_OP_STATUS_ERROR;
634 : 0 : goto error_exit;
635 : : } else {
636 : 0 : op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
637 : : }
638 : : } else {
639 [ - + ]: 148 : if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
640 : : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
641 : : "line %u FAILED: %s",
642 : : __LINE__, "Error sending packet for encryption");
643 : : status = TEST_FAILED;
644 : 0 : goto error_exit;
645 : : }
646 : :
647 : 148 : op = NULL;
648 : :
649 [ - + ]: 148 : while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
650 : : rte_pause();
651 : :
652 [ - + ]: 148 : if (!op) {
653 : : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
654 : : "line %u FAILED: %s",
655 : : __LINE__, "Failed to process sym crypto op");
656 : : status = TEST_FAILED;
657 : 0 : goto error_exit;
658 : : }
659 : : }
660 : : }
661 : :
662 : 148 : debug_hexdump(stdout, "m_src(after):",
663 : 148 : sym_op->m_src->buf_addr, sym_op->m_src->buf_len);
664 [ + + ]: 148 : if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP)
665 : 42 : debug_hexdump(stdout, "m_dst(after):",
666 : 42 : sym_op->m_dst->buf_addr, sym_op->m_dst->buf_len);
667 : :
668 : : /* Verify results */
669 [ - + ]: 148 : if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
670 [ # # # # ]: 0 : if ((t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_VERIFY) &&
671 : : (op->status == RTE_CRYPTO_OP_STATUS_AUTH_FAILED))
672 : : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
673 : : "FAILED: Digest verification failed "
674 : : "(0x%X)", __LINE__, op->status);
675 : : else
676 : 0 : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
677 : : "FAILED: Operation failed "
678 : : "(0x%X)", __LINE__, op->status);
679 : : status = TEST_FAILED;
680 : 0 : goto error_exit;
681 : : }
682 : :
683 [ + + ]: 148 : if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER) {
684 : : uint8_t buffer[2048];
685 : : const uint8_t *compare_ref;
686 : : uint32_t compare_len;
687 : :
688 [ + + ]: 118 : if (t->op_mask & BLOCKCIPHER_TEST_OP_ENCRYPT) {
689 : 61 : compare_ref = tdata->ciphertext.data +
690 : 61 : tdata->cipher_offset;
691 : 61 : compare_len = tdata->ciphertext.len -
692 : : tdata->cipher_offset;
693 [ - + ]: 61 : if (t->op_mask & BLOCKCIPHER_TEST_OP_DIGEST_ENCRYPTED)
694 : 0 : compare_len += tdata->digest.len;
695 : : } else {
696 : 57 : compare_ref = tdata->plaintext.data +
697 : 57 : tdata->cipher_offset;
698 : 57 : compare_len = tdata->plaintext.len -
699 : : tdata->cipher_offset;
700 : : }
701 : :
702 [ + + - + ]: 236 : if (memcmp(rte_pktmbuf_read(iobuf, tdata->cipher_offset,
703 : : compare_len, buffer), compare_ref,
704 : : compare_len)) {
705 : : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
706 : : "FAILED: %s", __LINE__,
707 : : "Crypto data not as expected");
708 : : status = TEST_FAILED;
709 : 0 : goto error_exit;
710 : : }
711 : : }
712 : :
713 : : /* Check digest data only in enc-then-auth_gen case.
714 : : * In auth_gen-then-enc case, cipher text contains both encrypted
715 : : * plain text and encrypted digest value. If cipher text is correct,
716 : : * it implies digest is also generated properly.
717 : : */
718 [ + - ]: 148 : if (!(t->op_mask & BLOCKCIPHER_TEST_OP_DIGEST_ENCRYPTED))
719 [ + + ]: 148 : if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN) {
720 : 47 : uint8_t *auth_res = pktmbuf_mtod_offset(iobuf,
721 : 47 : tdata->ciphertext.len);
722 [ - + ]: 47 : if (memcmp(auth_res, tdata->digest.data, digest_len)) {
723 : : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
724 : : "FAILED: %s", __LINE__, "Generated "
725 : : "digest data not as expected");
726 : : status = TEST_FAILED;
727 : 0 : goto error_exit;
728 : : }
729 : : }
730 : :
731 : : /* The only parts that should have changed in the buffer are
732 : : * plaintext/ciphertext and digest.
733 : : * In OOP only the dest buffer should change.
734 : : */
735 [ + + ]: 148 : if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP) {
736 : : struct rte_mbuf *mbuf;
737 : : uint8_t value;
738 : : uint32_t head_unchanged_len, changed_len = 0;
739 : : uint32_t i;
740 : : uint32_t hdroom_used = 0, tlroom_used = 0;
741 : : uint32_t hdroom = 0;
742 : :
743 : 42 : mbuf = sym_op->m_src;
744 : : /*
745 : : * Crypto PMDs specify the headroom & tailroom it would use
746 : : * when processing the crypto operation. PMD is free to modify
747 : : * this space, and so the verification check should skip that
748 : : * block.
749 : : */
750 : 42 : hdroom_used = dev_info.min_mbuf_headroom_req;
751 : 42 : tlroom_used = dev_info.min_mbuf_tailroom_req;
752 : :
753 : : /* Get headroom */
754 : 42 : hdroom = rte_pktmbuf_headroom(mbuf);
755 : :
756 : 42 : head_unchanged_len = mbuf->buf_len;
757 : :
758 [ + + ]: 185514 : for (i = 0; i < mbuf->buf_len; i++) {
759 : :
760 : : /* Skip headroom used by PMD */
761 [ + + ]: 185472 : if (i == hdroom - hdroom_used)
762 : 42 : i += hdroom_used;
763 : :
764 : : /* Skip tailroom used by PMD */
765 [ + + ]: 185472 : if (i == (hdroom + mbuf->data_len))
766 : 42 : i += tlroom_used;
767 : :
768 : 185472 : value = *((uint8_t *)(mbuf->buf_addr)+i);
769 [ - + ]: 185472 : if (value != tmp_src_buf[i]) {
770 : 0 : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
771 : : "line %u FAILED: OOP src outer mbuf data (0x%x) not as expected (0x%x)",
772 : : __LINE__, value, tmp_src_buf[i]);
773 : : status = TEST_FAILED;
774 : 0 : goto error_exit;
775 : : }
776 : : }
777 : :
778 : 42 : mbuf = sym_op->m_dst;
779 [ + + ]: 42 : if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH) {
780 : 20 : head_unchanged_len = hdroom + sym_op->auth.data.offset;
781 : 20 : changed_len = sym_op->auth.data.length;
782 [ + + ]: 20 : if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN)
783 : 10 : changed_len += digest_len;
784 : : } else {
785 : : /* cipher-only */
786 : 22 : head_unchanged_len = hdroom +
787 : 22 : sym_op->cipher.data.offset;
788 : 22 : changed_len = sym_op->cipher.data.length;
789 : : }
790 : :
791 [ - + ]: 42 : if (t->op_mask & BLOCKCIPHER_TEST_OP_DIGEST_ENCRYPTED)
792 : 0 : changed_len = sym_op->cipher.data.length +
793 : : digest_len + pad_len;
794 : :
795 [ + + ]: 169442 : for (i = 0; i < mbuf->buf_len; i++) {
796 [ + + ]: 169400 : if (i == head_unchanged_len)
797 : 42 : i += changed_len;
798 : 169400 : value = *((uint8_t *)(mbuf->buf_addr)+i);
799 [ - + ]: 169400 : if (value != tmp_dst_buf[i]) {
800 : 0 : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
801 : : "line %u FAILED: OOP dst outer mbuf data "
802 : : "(0x%x) not as expected (0x%x)",
803 : : __LINE__, value, tmp_dst_buf[i]);
804 : : status = TEST_FAILED;
805 : 0 : goto error_exit;
806 : : }
807 : : }
808 : :
809 [ + + ]: 42 : if (!nb_iterates) {
810 : : nb_iterates++;
811 : 21 : goto iterate;
812 : : }
813 : : } else {
814 : : /* In-place operation */
815 : : struct rte_mbuf *mbuf;
816 : : uint8_t value;
817 : : uint32_t head_unchanged_len = 0, changed_len = 0;
818 : : uint32_t i;
819 : : uint32_t hdroom_used = 0, tlroom_used = 0;
820 : : uint32_t hdroom = 0;
821 : :
822 : : /*
823 : : * Crypto PMDs specify the headroom & tailroom it would use
824 : : * when processing the crypto operation. PMD is free to modify
825 : : * this space, and so the verification check should skip that
826 : : * block.
827 : : */
828 : 106 : hdroom_used = dev_info.min_mbuf_headroom_req;
829 : 106 : tlroom_used = dev_info.min_mbuf_tailroom_req;
830 : :
831 [ + + ]: 106 : mbuf = sym_op->m_src;
832 : :
833 : : /* Get headroom */
834 : 106 : hdroom = rte_pktmbuf_headroom(mbuf);
835 : :
836 [ + + ]: 106 : if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER) {
837 : 76 : head_unchanged_len = hdroom +
838 : 76 : sym_op->cipher.data.offset;
839 : 76 : changed_len = sym_op->cipher.data.length;
840 : : } else {
841 : : /* auth-only */
842 : 30 : head_unchanged_len = hdroom +
843 : 30 : sym_op->auth.data.offset +
844 : 30 : sym_op->auth.data.length;
845 : : changed_len = 0;
846 : : }
847 : :
848 [ + + ]: 106 : if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH_GEN)
849 : 37 : changed_len += digest_len;
850 : :
851 [ - + ]: 106 : if (t->op_mask & BLOCKCIPHER_TEST_OP_DIGEST_ENCRYPTED)
852 : 0 : changed_len = sym_op->cipher.data.length;
853 : :
854 [ + + ]: 436078 : for (i = 0; i < mbuf->buf_len; i++) {
855 : :
856 : : /* Skip headroom used by PMD */
857 [ + + ]: 435972 : if (i == hdroom - hdroom_used)
858 : 106 : i += hdroom_used;
859 : :
860 [ + + ]: 435972 : if (i == head_unchanged_len)
861 : 106 : i += changed_len;
862 : :
863 : : /* Skip tailroom used by PMD */
864 [ + + ]: 435972 : if (i == (hdroom + mbuf->data_len))
865 : 99 : i += tlroom_used;
866 : :
867 : 435972 : value = *((uint8_t *)(mbuf->buf_addr)+i);
868 [ - + ]: 435972 : if (value != tmp_src_buf[i]) {
869 : 0 : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
870 : : "line %u FAILED: outer mbuf data (0x%x) "
871 : : "not as expected (0x%x)",
872 : : __LINE__, value, tmp_src_buf[i]);
873 : : status = TEST_FAILED;
874 : 0 : goto error_exit;
875 : : }
876 : : }
877 : : }
878 : :
879 : : snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "PASS");
880 : :
881 : 127 : error_exit:
882 [ + + ]: 127 : if (!(t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS)) {
883 [ + - ]: 120 : if (sess)
884 : 120 : rte_cryptodev_sym_session_free(dev_id, sess);
885 : 120 : rte_free(cipher_xform);
886 : 120 : rte_free(auth_xform);
887 : : }
888 : :
889 : 127 : rte_crypto_op_free(op);
890 : :
891 : 127 : rte_pktmbuf_free(obuf);
892 : :
893 : 127 : rte_pktmbuf_free(ibuf);
894 : :
895 : 127 : return status;
896 : : }
897 : :
898 : : static int
899 : 255 : blockcipher_test_case_run(const void *data)
900 : : {
901 : : const struct blockcipher_test_case *tc_data = data;
902 : : int status;
903 : : char test_msg[BLOCKCIPHER_TEST_MSG_LEN + 1];
904 : :
905 : 255 : status = test_blockcipher_one_case(tc_data,
906 : : p_testsuite_params->mbuf_pool,
907 : : p_testsuite_params->op_mpool,
908 : : p_testsuite_params->session_mpool,
909 : 255 : p_testsuite_params->valid_devs[0],
910 : : test_msg);
911 : 255 : return status;
912 : : }
913 : :
914 : : static int
915 : 1 : aes_chain_setup(void)
916 : : {
917 : 1 : uint8_t dev_id = p_testsuite_params->valid_devs[0];
918 : : struct rte_cryptodev_info dev_info;
919 : : uint64_t feat_flags;
920 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
921 : : RTE_CRYPTO_CIPHER_NULL,
922 : : RTE_CRYPTO_CIPHER_AES_CTR,
923 : : RTE_CRYPTO_CIPHER_AES_CBC
924 : : };
925 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
926 : : RTE_CRYPTO_AUTH_NULL,
927 : : RTE_CRYPTO_AUTH_SHA1_HMAC,
928 : : RTE_CRYPTO_AUTH_AES_XCBC_MAC,
929 : : RTE_CRYPTO_AUTH_SHA256_HMAC,
930 : : RTE_CRYPTO_AUTH_SHA512_HMAC,
931 : : RTE_CRYPTO_AUTH_SHA224_HMAC,
932 : : RTE_CRYPTO_AUTH_SHA384_HMAC
933 : : };
934 : :
935 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
936 : 1 : feat_flags = dev_info.feature_flags;
937 : :
938 [ + - ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
939 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
940 [ # # ]: 0 : !(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
941 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for AES Chain "
942 : : "testsuite not met\n");
943 : 0 : return TEST_SKIPPED;
944 : : }
945 : :
946 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
947 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
948 : : RTE_DIM(auths)) != 0) {
949 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for AES Chain "
950 : : "testsuite not met\n");
951 : 0 : return TEST_SKIPPED;
952 : : }
953 : :
954 : : return 0;
955 : : }
956 : :
957 : : static int
958 : 1 : aes_cipheronly_setup(void)
959 : : {
960 : 1 : uint8_t dev_id = p_testsuite_params->valid_devs[0];
961 : : struct rte_cryptodev_info dev_info;
962 : : uint64_t feat_flags;
963 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
964 : : RTE_CRYPTO_CIPHER_NULL,
965 : : RTE_CRYPTO_CIPHER_AES_CTR,
966 : : RTE_CRYPTO_CIPHER_AES_CBC,
967 : : RTE_CRYPTO_CIPHER_AES_ECB,
968 : : RTE_CRYPTO_CIPHER_AES_XTS
969 : : };
970 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
971 : : RTE_CRYPTO_AUTH_NULL,
972 : : RTE_CRYPTO_AUTH_SHA1_HMAC,
973 : : RTE_CRYPTO_AUTH_AES_XCBC_MAC
974 : : };
975 : :
976 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
977 : 1 : feat_flags = dev_info.feature_flags;
978 : :
979 [ + - ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
980 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
981 [ # # ]: 0 : !(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
982 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for AES Cipheronly "
983 : : "testsuite not met\n");
984 : 0 : return TEST_SKIPPED;
985 : : }
986 : :
987 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
988 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
989 : : RTE_DIM(auths)) != 0) {
990 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for AES Cipheronly "
991 : : "testsuite not met\n");
992 : 0 : return TEST_SKIPPED;
993 : : }
994 : :
995 : : return 0;
996 : : }
997 : :
998 : : static int
999 : 1 : aes_docsis_setup(void)
1000 : : {
1001 : 1 : uint8_t dev_id = p_testsuite_params->valid_devs[0];
1002 : : struct rte_cryptodev_info dev_info;
1003 : : uint64_t feat_flags;
1004 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1005 : : RTE_CRYPTO_CIPHER_AES_DOCSISBPI
1006 : : };
1007 : :
1008 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1009 : 1 : feat_flags = dev_info.feature_flags;
1010 : :
1011 : : /* Data-path service does not support DOCSIS yet */
1012 [ + - ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1013 [ - + ]: 1 : (global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1014 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for AES Docsis "
1015 : : "testsuite not met\n");
1016 : 0 : return TEST_SKIPPED;
1017 : : }
1018 : :
1019 [ + - ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
1020 : 1 : RTE_LOG(INFO, USER1, "Capability requirements for AES Docsis "
1021 : : "testsuite not met\n");
1022 : 1 : return TEST_SKIPPED;
1023 : : }
1024 : :
1025 : : return 0;
1026 : : }
1027 : :
1028 : : static int
1029 : 1 : triple_des_chain_setup(void)
1030 : : {
1031 : 1 : uint8_t dev_id = p_testsuite_params->valid_devs[0];
1032 : : struct rte_cryptodev_info dev_info;
1033 : : uint64_t feat_flags;
1034 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1035 : : RTE_CRYPTO_CIPHER_3DES_CTR,
1036 : : RTE_CRYPTO_CIPHER_3DES_CBC
1037 : : };
1038 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1039 : : RTE_CRYPTO_AUTH_SHA1_HMAC,
1040 : : RTE_CRYPTO_AUTH_SHA1
1041 : : };
1042 : :
1043 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1044 : 1 : feat_flags = dev_info.feature_flags;
1045 : :
1046 [ + - ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1047 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1048 [ # # ]: 0 : !(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1049 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for 3DES Chain "
1050 : : "testsuite not met\n");
1051 : 0 : return TEST_SKIPPED;
1052 : : }
1053 : :
1054 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1055 [ # # ]: 0 : && check_auth_capabilities_supported(auths,
1056 : : RTE_DIM(auths)) != 0) {
1057 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for 3DES Chain "
1058 : : "testsuite not met\n");
1059 : 0 : return TEST_SKIPPED;
1060 : : }
1061 : :
1062 : : return 0;
1063 : : }
1064 : :
1065 : : static int
1066 : 1 : triple_des_cipheronly_setup(void)
1067 : : {
1068 : 1 : uint8_t dev_id = p_testsuite_params->valid_devs[0];
1069 : : struct rte_cryptodev_info dev_info;
1070 : : uint64_t feat_flags;
1071 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1072 : : RTE_CRYPTO_CIPHER_3DES_CTR,
1073 : : RTE_CRYPTO_CIPHER_3DES_CBC
1074 : : };
1075 : :
1076 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1077 : 1 : feat_flags = dev_info.feature_flags;
1078 : :
1079 [ + - ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1080 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1081 [ # # ]: 0 : !(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1082 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for 3DES "
1083 : : "Cipheronly testsuite not met\n");
1084 : 0 : return TEST_SKIPPED;
1085 : : }
1086 : :
1087 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
1088 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for 3DES "
1089 : : "Cipheronly testsuite not met\n");
1090 : 0 : return TEST_SKIPPED;
1091 : : }
1092 : :
1093 : : return 0;
1094 : : }
1095 : :
1096 : : static int
1097 : 1 : des_cipheronly_setup(void)
1098 : : {
1099 : 1 : uint8_t dev_id = p_testsuite_params->valid_devs[0];
1100 : : struct rte_cryptodev_info dev_info;
1101 : : uint64_t feat_flags;
1102 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1103 : : RTE_CRYPTO_CIPHER_DES_CBC
1104 : : };
1105 : :
1106 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1107 : 1 : feat_flags = dev_info.feature_flags;
1108 : :
1109 [ + - ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1110 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1111 [ # # ]: 0 : !(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1112 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for DES "
1113 : : "Cipheronly testsuite not met\n");
1114 : 0 : return TEST_SKIPPED;
1115 : : }
1116 : :
1117 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
1118 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for DES "
1119 : : "Cipheronly testsuite not met\n");
1120 : 0 : return TEST_SKIPPED;
1121 : : }
1122 : :
1123 : : return 0;
1124 : : }
1125 : :
1126 : : static int
1127 : 1 : des_docsis_setup(void)
1128 : : {
1129 : 1 : uint8_t dev_id = p_testsuite_params->valid_devs[0];
1130 : : struct rte_cryptodev_info dev_info;
1131 : : uint64_t feat_flags;
1132 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1133 : : RTE_CRYPTO_CIPHER_DES_DOCSISBPI
1134 : : };
1135 : :
1136 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1137 : 1 : feat_flags = dev_info.feature_flags;
1138 : :
1139 : : /* Data-path service does not support DOCSIS yet */
1140 [ + - ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1141 [ - + ]: 1 : (global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1142 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for DES Docsis "
1143 : : "testsuite not met\n");
1144 : 0 : return TEST_SKIPPED;
1145 : : }
1146 : :
1147 [ - + ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
1148 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for DES Docsis "
1149 : : "testsuite not met\n");
1150 : 0 : return TEST_SKIPPED;
1151 : : }
1152 : :
1153 : : return 0;
1154 : : }
1155 : :
1156 : : static int
1157 : 1 : authonly_setup(void)
1158 : : {
1159 : 1 : uint8_t dev_id = p_testsuite_params->valid_devs[0];
1160 : : struct rte_cryptodev_info dev_info;
1161 : : uint64_t feat_flags;
1162 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1163 : : RTE_CRYPTO_AUTH_MD5,
1164 : : RTE_CRYPTO_AUTH_MD5_HMAC,
1165 : : RTE_CRYPTO_AUTH_SHA1,
1166 : : RTE_CRYPTO_AUTH_SHA1_HMAC,
1167 : : RTE_CRYPTO_AUTH_SHA224,
1168 : : RTE_CRYPTO_AUTH_SHA224_HMAC,
1169 : : RTE_CRYPTO_AUTH_SHA256,
1170 : : RTE_CRYPTO_AUTH_SHA256_HMAC,
1171 : : RTE_CRYPTO_AUTH_SHA384,
1172 : : RTE_CRYPTO_AUTH_SHA384_HMAC,
1173 : : RTE_CRYPTO_AUTH_SHA512,
1174 : : RTE_CRYPTO_AUTH_SHA512_HMAC,
1175 : : RTE_CRYPTO_AUTH_AES_CMAC,
1176 : : RTE_CRYPTO_AUTH_NULL,
1177 : : RTE_CRYPTO_AUTH_AES_XCBC_MAC
1178 : : };
1179 : :
1180 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1181 : 1 : feat_flags = dev_info.feature_flags;
1182 : :
1183 [ + - ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1184 [ - + ]: 1 : ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1185 [ # # ]: 0 : !(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1186 : 0 : RTE_LOG(INFO, USER1, "Feature flag requirements for Auth Only "
1187 : : "testsuite not met\n");
1188 : 0 : return TEST_SKIPPED;
1189 : : }
1190 : :
1191 [ - + ]: 1 : if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1192 : 0 : RTE_LOG(INFO, USER1, "Capability requirements for Auth Only "
1193 : : "testsuite not met\n");
1194 : 0 : return TEST_SKIPPED;
1195 : : }
1196 : :
1197 : : return 0;
1198 : : }
1199 : :
1200 : : static int
1201 : 1 : sm4_chain_setup(void)
1202 : : {
1203 : 1 : uint8_t dev_id = p_testsuite_params->valid_devs[0];
1204 : : struct rte_cryptodev_info dev_info;
1205 : : uint64_t feat_flags;
1206 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1207 : : RTE_CRYPTO_CIPHER_SM4_CTR,
1208 : : RTE_CRYPTO_CIPHER_SM4_CBC,
1209 : : RTE_CRYPTO_CIPHER_SM4_OFB,
1210 : : RTE_CRYPTO_CIPHER_SM4_CFB
1211 : : };
1212 : 1 : const enum rte_crypto_auth_algorithm auths[] = {
1213 : : RTE_CRYPTO_AUTH_SM3,
1214 : : RTE_CRYPTO_AUTH_SM3_HMAC,
1215 : : };
1216 : :
1217 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1218 : 1 : feat_flags = dev_info.feature_flags;
1219 : :
1220 [ + - ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1221 [ - + ]: 1 : (global_api_test_type == CRYPTODEV_RAW_API_TEST &&
1222 [ # # ]: 0 : !(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1223 : 0 : RTE_LOG(INFO, USER1, "Feature flag for SM4 Chain testsuite not met\n");
1224 : 0 : return TEST_SKIPPED;
1225 : : }
1226 : :
1227 [ + - + - ]: 2 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0 &&
1228 : 1 : check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1229 : 1 : RTE_LOG(INFO, USER1, "Capability for SM4 Chain testsuite not met\n");
1230 : 1 : return TEST_SKIPPED;
1231 : : }
1232 : :
1233 : : return 0;
1234 : : }
1235 : :
1236 : : static int
1237 : 1 : sm4_cipheronly_setup(void)
1238 : : {
1239 : 1 : uint8_t dev_id = p_testsuite_params->valid_devs[0];
1240 : : struct rte_cryptodev_info dev_info;
1241 : : uint64_t feat_flags;
1242 : 1 : const enum rte_crypto_cipher_algorithm ciphers[] = {
1243 : : RTE_CRYPTO_CIPHER_SM4_CBC,
1244 : : RTE_CRYPTO_CIPHER_SM4_ECB,
1245 : : RTE_CRYPTO_CIPHER_SM4_CTR,
1246 : : RTE_CRYPTO_CIPHER_SM4_OFB,
1247 : : RTE_CRYPTO_CIPHER_SM4_CFB,
1248 : : RTE_CRYPTO_CIPHER_SM4_XTS
1249 : : };
1250 : :
1251 : 1 : rte_cryptodev_info_get(dev_id, &dev_info);
1252 : 1 : feat_flags = dev_info.feature_flags;
1253 : :
1254 [ + - ]: 1 : if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1255 [ - + ]: 1 : (global_api_test_type == CRYPTODEV_RAW_API_TEST &&
1256 [ # # ]: 0 : !(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1257 : 0 : RTE_LOG(INFO, USER1, "Feature flag for SM4 Cipheronly not met\n");
1258 : 0 : return TEST_SKIPPED;
1259 : : }
1260 : :
1261 [ + - ]: 1 : if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
1262 : 1 : RTE_LOG(INFO, USER1, "Capability for SM4 Cipheronly not met\n");
1263 : 1 : return TEST_SKIPPED;
1264 : : }
1265 : :
1266 : : return 0;
1267 : : }
1268 : :
1269 : : struct unit_test_suite *
1270 : 10 : build_blockcipher_test_suite(enum blockcipher_test_type test_type)
1271 : : {
1272 : : int i, n_test_cases = 0;
1273 : : struct unit_test_suite *ts;
1274 : : const char *ts_name = NULL;
1275 : : const struct blockcipher_test_case *blk_tcs;
1276 : : struct unit_test_case *tc;
1277 : : int (*ts_setup)(void) = NULL;
1278 : :
1279 [ + + + + : 10 : switch (test_type) {
+ + + + +
+ - ]
1280 : : case BLKCIPHER_AES_CHAIN_TYPE:
1281 : : n_test_cases = RTE_DIM(aes_chain_test_cases);
1282 : : blk_tcs = aes_chain_test_cases;
1283 : : ts_name = "AES Chain";
1284 : : ts_setup = aes_chain_setup;
1285 : : break;
1286 : 1 : case BLKCIPHER_AES_CIPHERONLY_TYPE:
1287 : : n_test_cases = RTE_DIM(aes_cipheronly_test_cases);
1288 : : blk_tcs = aes_cipheronly_test_cases;
1289 : : ts_name = "AES Cipher Only";
1290 : : ts_setup = aes_cipheronly_setup;
1291 : 1 : break;
1292 : 1 : case BLKCIPHER_AES_DOCSIS_TYPE:
1293 : : n_test_cases = RTE_DIM(aes_docsis_test_cases);
1294 : : blk_tcs = aes_docsis_test_cases;
1295 : : ts_name = "AES Docsis";
1296 : : ts_setup = aes_docsis_setup;
1297 : 1 : break;
1298 : 1 : case BLKCIPHER_3DES_CHAIN_TYPE:
1299 : : n_test_cases = RTE_DIM(triple_des_chain_test_cases);
1300 : : blk_tcs = triple_des_chain_test_cases;
1301 : : ts_name = "3DES Chain";
1302 : : ts_setup = triple_des_chain_setup;
1303 : 1 : break;
1304 : 1 : case BLKCIPHER_3DES_CIPHERONLY_TYPE:
1305 : : n_test_cases = RTE_DIM(triple_des_cipheronly_test_cases);
1306 : : blk_tcs = triple_des_cipheronly_test_cases;
1307 : : ts_name = "3DES Cipher Only";
1308 : : ts_setup = triple_des_cipheronly_setup;
1309 : 1 : break;
1310 : 1 : case BLKCIPHER_DES_CIPHERONLY_TYPE:
1311 : : n_test_cases = RTE_DIM(des_cipheronly_test_cases);
1312 : : blk_tcs = des_cipheronly_test_cases;
1313 : : ts_name = "DES Cipher Only";
1314 : : ts_setup = des_cipheronly_setup;
1315 : 1 : break;
1316 : 1 : case BLKCIPHER_DES_DOCSIS_TYPE:
1317 : : n_test_cases = RTE_DIM(des_docsis_test_cases);
1318 : : blk_tcs = des_docsis_test_cases;
1319 : : ts_name = "DES Docsis";
1320 : : ts_setup = des_docsis_setup;
1321 : 1 : break;
1322 : 1 : case BLKCIPHER_SM4_CHAIN_TYPE:
1323 : : n_test_cases = RTE_DIM(sm4_chain_test_cases);
1324 : : blk_tcs = sm4_chain_test_cases;
1325 : : ts_name = "SM4 Chain";
1326 : : ts_setup = sm4_chain_setup;
1327 : 1 : break;
1328 : 1 : case BLKCIPHER_SM4_CIPHERONLY_TYPE:
1329 : : n_test_cases = RTE_DIM(sm4_cipheronly_test_cases);
1330 : : blk_tcs = sm4_cipheronly_test_cases;
1331 : : ts_name = "SM4 Cipher Only";
1332 : : ts_setup = sm4_cipheronly_setup;
1333 : 1 : break;
1334 : 1 : case BLKCIPHER_AUTHONLY_TYPE:
1335 : : n_test_cases = RTE_DIM(hash_test_cases);
1336 : : blk_tcs = hash_test_cases;
1337 : : ts_name = "Auth Only";
1338 : : ts_setup = authonly_setup;
1339 : 1 : break;
1340 : : default:
1341 : : return NULL;
1342 : : }
1343 : :
1344 : 10 : ts = calloc(1, sizeof(struct unit_test_suite) +
1345 : : (sizeof(struct unit_test_case) * (n_test_cases + 1)));
1346 : 10 : ts->suite_name = ts_name;
1347 : 10 : ts->setup = ts_setup;
1348 : :
1349 [ + + ]: 325 : for (i = 0; i < n_test_cases; i++) {
1350 : : tc = &ts->unit_test_cases[i];
1351 : 315 : tc->name = blk_tcs[i].test_descr;
1352 : 315 : tc->enabled = 1;
1353 : 315 : tc->setup = ut_setup;
1354 : 315 : tc->teardown = ut_teardown;
1355 : 315 : tc->testcase = NULL;
1356 : 315 : tc->testcase_with_data = blockcipher_test_case_run;
1357 : 315 : tc->data = &blk_tcs[i];
1358 : : }
1359 : : tc = &ts->unit_test_cases[i];
1360 : 10 : tc->name = NULL;
1361 : 10 : tc->enabled = 0;
1362 : 10 : tc->setup = NULL;
1363 : 10 : tc->teardown = NULL;
1364 : 10 : tc->testcase = NULL;
1365 : 10 : tc->testcase_with_data = NULL;
1366 : 10 : tc->data = NULL;
1367 : :
1368 : 10 : return ts;
1369 : : }
1370 : :
1371 : : void
1372 : 10 : free_blockcipher_test_suite(struct unit_test_suite *ts)
1373 : : {
1374 : 10 : free(ts);
1375 : 10 : }
|