4 * Copyright(c) 2016-2017 Intel Corporation. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Intel Corporation nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #ifndef _OPENSSL_PMD_PRIVATE_H_
34 #define _OPENSSL_PMD_PRIVATE_H_
36 #include <openssl/evp.h>
37 #include <openssl/des.h>
39 #define CRYPTODEV_NAME_OPENSSL_PMD crypto_openssl
40 /**< Open SSL Crypto PMD device name */
42 #define OPENSSL_LOG_ERR(fmt, args...) \
43 RTE_LOG(ERR, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
44 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD), \
45 __func__, __LINE__, ## args)
47 #ifdef RTE_LIBRTE_OPENSSL_DEBUG
48 #define OPENSSL_LOG_INFO(fmt, args...) \
49 RTE_LOG(INFO, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
50 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD), \
51 __func__, __LINE__, ## args)
53 #define OPENSSL_LOG_DBG(fmt, args...) \
54 RTE_LOG(DEBUG, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
55 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD), \
56 __func__, __LINE__, ## args)
58 #define OPENSSL_LOG_INFO(fmt, args...)
59 #define OPENSSL_LOG_DBG(fmt, args...)
63 /** OPENSSL operation order mode enumerator */
64 enum openssl_chain_order {
65 OPENSSL_CHAIN_ONLY_CIPHER,
66 OPENSSL_CHAIN_ONLY_AUTH,
67 OPENSSL_CHAIN_CIPHER_BPI,
68 OPENSSL_CHAIN_CIPHER_AUTH,
69 OPENSSL_CHAIN_AUTH_CIPHER,
70 OPENSSL_CHAIN_COMBINED,
71 OPENSSL_CHAIN_NOT_SUPPORTED
74 /** OPENSSL cipher mode enumerator */
75 enum openssl_cipher_mode {
77 OPENSSL_CIPHER_DES3CTR,
80 /** OPENSSL auth mode enumerator */
81 enum openssl_auth_mode {
86 /** private data structure for each OPENSSL crypto device */
87 struct openssl_private {
88 unsigned int max_nb_qpairs;
89 /**< Max number of queue pairs */
90 unsigned int max_nb_sessions;
91 /**< Max number of sessions */
94 /** OPENSSL crypto queue pair */
97 /**< Queue Pair Identifier */
98 char name[RTE_CRYPTODEV_NAME_LEN];
99 /**< Unique Queue Pair Name */
100 struct rte_ring *processed_ops;
101 /**< Ring for placing process packets */
102 struct rte_mempool *sess_mp;
103 /**< Session Mempool */
104 struct rte_cryptodev_stats stats;
105 /**< Queue pair statistics */
106 } __rte_cache_aligned;
108 /** OPENSSL crypto private session structure */
109 struct openssl_session {
110 enum openssl_chain_order chain_order;
111 /**< chain order mode */
117 /**< IV parameters */
119 enum rte_crypto_aead_algorithm aead_algo;
120 /**< AEAD algorithm */
122 /** Cipher Parameters */
124 enum rte_crypto_cipher_operation direction;
125 /**< cipher operation direction */
126 enum openssl_cipher_mode mode;
127 /**< cipher operation mode */
128 enum rte_crypto_cipher_algorithm algo;
129 /**< cipher algorithm */
135 /**< key length in bytes */
138 const EVP_CIPHER *evp_algo;
139 /**< pointer to EVP algorithm function */
141 /**< pointer to EVP context structure */
142 EVP_CIPHER_CTX *bpi_ctx;
145 /** Authentication Parameters */
147 enum rte_crypto_auth_operation operation;
148 /**< auth operation generate or verify */
149 enum openssl_auth_mode mode;
150 /**< auth operation mode */
151 enum rte_crypto_auth_algorithm algo;
152 /**< cipher algorithm */
156 const EVP_MD *evp_algo;
157 /**< pointer to EVP algorithm function */
159 /**< pointer to EVP context structure */
164 /**< pointer to EVP key */
165 const EVP_MD *evp_algo;
166 /**< pointer to EVP algorithm function */
168 /**< pointer to EVP context structure */
174 uint16_t digest_length;
175 /**< digest length */
178 } __rte_cache_aligned;
180 /** Set and validate OPENSSL crypto session parameters */
182 openssl_set_session_parameters(struct openssl_session *sess,
183 const struct rte_crypto_sym_xform *xform);
185 /** Reset OPENSSL crypto session parameters */
187 openssl_reset_session(struct openssl_session *sess);
189 /** device specific operations function pointer structure */
190 extern struct rte_cryptodev_ops *rte_openssl_pmd_ops;
192 #endif /* _OPENSSL_PMD_PRIVATE_H_ */