4 * Copyright(c) 2016 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>
40 #define OPENSSL_LOG_ERR(fmt, args...) \
41 RTE_LOG(ERR, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
42 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD), \
43 __func__, __LINE__, ## args)
45 #ifdef RTE_LIBRTE_OPENSSL_DEBUG
46 #define OPENSSL_LOG_INFO(fmt, args...) \
47 RTE_LOG(INFO, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
48 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD), \
49 __func__, __LINE__, ## args)
51 #define OPENSSL_LOG_DBG(fmt, args...) \
52 RTE_LOG(DEBUG, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
53 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD), \
54 __func__, __LINE__, ## args)
56 #define OPENSSL_LOG_INFO(fmt, args...)
57 #define OPENSSL_LOG_DBG(fmt, args...)
61 /** OPENSSL operation order mode enumerator */
62 enum openssl_chain_order {
63 OPENSSL_CHAIN_ONLY_CIPHER,
64 OPENSSL_CHAIN_ONLY_AUTH,
65 OPENSSL_CHAIN_CIPHER_BPI,
66 OPENSSL_CHAIN_CIPHER_AUTH,
67 OPENSSL_CHAIN_AUTH_CIPHER,
68 OPENSSL_CHAIN_COMBINED,
69 OPENSSL_CHAIN_NOT_SUPPORTED
72 /** OPENSSL cipher mode enumerator */
73 enum openssl_cipher_mode {
75 OPENSSL_CIPHER_DES3CTR,
78 /** OPENSSL auth mode enumerator */
79 enum openssl_auth_mode {
84 /** private data structure for each OPENSSL crypto device */
85 struct openssl_private {
86 unsigned int max_nb_qpairs;
87 /**< Max number of queue pairs */
88 unsigned int max_nb_sessions;
89 /**< Max number of sessions */
92 /** OPENSSL crypto queue pair */
95 /**< Queue Pair Identifier */
96 char name[RTE_CRYPTODEV_NAME_LEN];
97 /**< Unique Queue Pair Name */
98 struct rte_ring *processed_ops;
99 /**< Ring for placing process packets */
100 struct rte_mempool *sess_mp;
101 /**< Session Mempool */
102 struct rte_cryptodev_stats stats;
103 /**< Queue pair statistics */
104 } __rte_cache_aligned;
106 /** OPENSSL crypto private session structure */
107 struct openssl_session {
108 enum openssl_chain_order chain_order;
109 /**< chain order mode */
111 /** Cipher Parameters */
113 enum rte_crypto_cipher_operation direction;
114 /**< cipher operation direction */
115 enum openssl_cipher_mode mode;
116 /**< cipher operation mode */
117 enum rte_crypto_cipher_algorithm algo;
118 /**< cipher algorithm */
124 /**< key length in bytes */
127 const EVP_CIPHER *evp_algo;
128 /**< pointer to EVP algorithm function */
130 /**< pointer to EVP context structure */
131 EVP_CIPHER_CTX *bpi_ctx;
134 /** Authentication Parameters */
136 enum rte_crypto_auth_operation operation;
137 /**< auth operation generate or verify */
138 enum openssl_auth_mode mode;
139 /**< auth operation mode */
140 enum rte_crypto_auth_algorithm algo;
141 /**< cipher algorithm */
145 const EVP_MD *evp_algo;
146 /**< pointer to EVP algorithm function */
148 /**< pointer to EVP context structure */
153 /**< pointer to EVP key */
154 const EVP_MD *evp_algo;
155 /**< pointer to EVP algorithm function */
157 /**< pointer to EVP context structure */
162 } __rte_cache_aligned;
164 /** Set and validate OPENSSL crypto session parameters */
166 openssl_set_session_parameters(struct openssl_session *sess,
167 const struct rte_crypto_sym_xform *xform);
169 /** Reset OPENSSL crypto session parameters */
171 openssl_reset_session(struct openssl_session *sess);
173 /** device specific operations function pointer structure */
174 extern struct rte_cryptodev_ops *rte_openssl_pmd_ops;
176 #endif /* _OPENSSL_PMD_PRIVATE_H_ */