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_AUTH,
66 OPENSSL_CHAIN_AUTH_CIPHER,
67 OPENSSL_CHAIN_COMBINED,
68 OPENSSL_CHAIN_NOT_SUPPORTED
71 /** OPENSSL cipher mode enumerator */
72 enum openssl_cipher_mode {
74 OPENSSL_CIPHER_DES3CTR,
77 /** OPENSSL auth mode enumerator */
78 enum openssl_auth_mode {
83 /** private data structure for each OPENSSL crypto device */
84 struct openssl_private {
85 unsigned int max_nb_qpairs;
86 /**< Max number of queue pairs */
87 unsigned int max_nb_sessions;
88 /**< Max number of sessions */
91 /** OPENSSL crypto queue pair */
94 /**< Queue Pair Identifier */
95 char name[RTE_CRYPTODEV_NAME_LEN];
96 /**< Unique Queue Pair Name */
97 struct rte_ring *processed_ops;
98 /**< Ring for placing process packets */
99 struct rte_mempool *sess_mp;
100 /**< Session Mempool */
101 struct rte_cryptodev_stats stats;
102 /**< Queue pair statistics */
103 } __rte_cache_aligned;
105 /** OPENSSL crypto private session structure */
106 struct openssl_session {
107 enum openssl_chain_order chain_order;
108 /**< chain order mode */
110 /** Cipher Parameters */
112 enum rte_crypto_cipher_operation direction;
113 /**< cipher operation direction */
114 enum openssl_cipher_mode mode;
115 /**< cipher operation mode */
116 enum rte_crypto_cipher_algorithm algo;
117 /**< cipher algorithm */
123 /**< key length in bytes */
126 const EVP_CIPHER *evp_algo;
127 /**< pointer to EVP algorithm function */
129 /**< pointer to EVP context structure */
132 /** Authentication Parameters */
134 enum rte_crypto_auth_operation operation;
135 /**< auth operation generate or verify */
136 enum openssl_auth_mode mode;
137 /**< auth operation mode */
138 enum rte_crypto_auth_algorithm algo;
139 /**< cipher algorithm */
143 const EVP_MD *evp_algo;
144 /**< pointer to EVP algorithm function */
146 /**< pointer to EVP context structure */
151 /**< pointer to EVP key */
152 const EVP_MD *evp_algo;
153 /**< pointer to EVP algorithm function */
155 /**< pointer to EVP context structure */
160 } __rte_cache_aligned;
162 /** Set and validate OPENSSL crypto session parameters */
164 openssl_set_session_parameters(struct openssl_session *sess,
165 const struct rte_crypto_sym_xform *xform);
167 /** Reset OPENSSL crypto session parameters */
169 openssl_reset_session(struct openssl_session *sess);
171 /** device specific operations function pointer structure */
172 extern struct rte_cryptodev_ops *rte_openssl_pmd_ops;
174 #endif /* _OPENSSL_PMD_PRIVATE_H_ */