New upstream version 18.02
[deb_dpdk.git] / test / test / test_cryptodev_blockcipher.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2016-2017 Intel Corporation
3  */
4
5 #ifndef TEST_CRYPTODEV_BLOCKCIPHER_H_
6 #define TEST_CRYPTODEV_BLOCKCIPHER_H_
7
8 #ifndef BLOCKCIPHER_TEST_MSG_LEN
9 #define BLOCKCIPHER_TEST_MSG_LEN                256
10 #endif
11
12 #define BLOCKCIPHER_TEST_OP_ENCRYPT             0x01
13 #define BLOCKCIPHER_TEST_OP_DECRYPT             0x02
14 #define BLOCKCIPHER_TEST_OP_AUTH_GEN    0x04
15 #define BLOCKCIPHER_TEST_OP_AUTH_VERIFY 0x08
16
17 #define BLOCKCIPHER_TEST_FEATURE_OOP                    0x01
18 #define BLOCKCIPHER_TEST_FEATURE_SESSIONLESS    0x02
19 #define BLOCKCIPHER_TEST_FEATURE_STOPPER        0x04 /* stop upon failing */
20 #define BLOCKCIPHER_TEST_FEATURE_SG             0x08 /* Scatter Gather */
21
22 #define BLOCKCIPHER_TEST_TARGET_PMD_MB          0x0001 /* Multi-buffer flag */
23 #define BLOCKCIPHER_TEST_TARGET_PMD_QAT                 0x0002 /* QAT flag */
24 #define BLOCKCIPHER_TEST_TARGET_PMD_OPENSSL     0x0004 /* SW OPENSSL flag */
25 #define BLOCKCIPHER_TEST_TARGET_PMD_ARMV8       0x0008 /* ARMv8 flag */
26 #define BLOCKCIPHER_TEST_TARGET_PMD_SCHEDULER   0x0010 /* Scheduler */
27 #define BLOCKCIPHER_TEST_TARGET_PMD_DPAA2_SEC   0x0020 /* DPAA2_SEC flag */
28 #define BLOCKCIPHER_TEST_TARGET_PMD_DPAA_SEC    0x0040 /* DPAA_SEC flag */
29 #define BLOCKCIPHER_TEST_TARGET_PMD_MRVL        0x0080 /* Marvell flag */
30
31 #define BLOCKCIPHER_TEST_OP_CIPHER      (BLOCKCIPHER_TEST_OP_ENCRYPT | \
32                                         BLOCKCIPHER_TEST_OP_DECRYPT)
33
34 #define BLOCKCIPHER_TEST_OP_AUTH        (BLOCKCIPHER_TEST_OP_AUTH_GEN | \
35                                         BLOCKCIPHER_TEST_OP_AUTH_VERIFY)
36
37 #define BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN        (BLOCKCIPHER_TEST_OP_ENCRYPT | \
38                                         BLOCKCIPHER_TEST_OP_AUTH_GEN)
39
40 #define BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC     (BLOCKCIPHER_TEST_OP_DECRYPT | \
41                                         BLOCKCIPHER_TEST_OP_AUTH_VERIFY)
42
43 enum blockcipher_test_type {
44         BLKCIPHER_AES_CHAIN_TYPE,       /* use aes_chain_test_cases[] */
45         BLKCIPHER_AES_CIPHERONLY_TYPE,  /* use aes_cipheronly_test_cases[] */
46         BLKCIPHER_AES_DOCSIS_TYPE,      /* use aes_docsis_test_cases[] */
47         BLKCIPHER_3DES_CHAIN_TYPE,      /* use triple_des_chain_test_cases[] */
48         BLKCIPHER_3DES_CIPHERONLY_TYPE, /* triple_des_cipheronly_test_cases[] */
49         BLKCIPHER_AUTHONLY_TYPE,        /* use hash_test_cases[] */
50         BLKCIPHER_DES_CIPHERONLY_TYPE,  /* use des_cipheronly_test_cases[] */
51         BLKCIPHER_DES_DOCSIS_TYPE       /* use des_docsis_test_cases[] */
52 };
53
54 struct blockcipher_test_case {
55         const char *test_descr; /* test description */
56         const struct blockcipher_test_data *test_data;
57         uint8_t op_mask; /* operation mask */
58         uint8_t feature_mask;
59         uint32_t pmd_mask;
60 };
61
62 struct blockcipher_test_data {
63         enum rte_crypto_cipher_algorithm crypto_algo;
64
65         struct {
66                 uint8_t data[64];
67                 unsigned int len;
68         } cipher_key;
69
70         struct {
71                 uint8_t data[64] __rte_aligned(16);
72                 unsigned int len;
73         } iv;
74
75         struct {
76                 const uint8_t *data;
77                 unsigned int len;
78         } plaintext;
79
80         struct {
81                 const uint8_t *data;
82                 unsigned int len;
83         } ciphertext;
84
85         enum rte_crypto_auth_algorithm auth_algo;
86
87         struct {
88                 uint8_t data[128];
89                 unsigned int len;
90         } auth_key;
91
92         struct {
93                 uint8_t data[128];
94                 unsigned int len;               /* for qat */
95                 unsigned int truncated_len;     /* for mb */
96         } digest;
97 };
98
99 int
100 test_blockcipher_all_tests(struct rte_mempool *mbuf_pool,
101         struct rte_mempool *op_mpool,
102         struct rte_mempool *sess_mpool,
103         uint8_t dev_id,
104         int driver_id,
105         enum blockcipher_test_type test_type);
106
107 #endif /* TEST_CRYPTODEV_BLOCKCIPHER_H_ */