1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2016-2017 Intel Corporation
5 #ifndef _OPENSSL_PMD_PRIVATE_H_
6 #define _OPENSSL_PMD_PRIVATE_H_
8 #include <openssl/evp.h>
9 #include <openssl/hmac.h>
10 #include <openssl/des.h>
11 #include <openssl/rsa.h>
12 #include <openssl/dh.h>
13 #include <openssl/dsa.h>
14 #if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
15 #include <openssl/provider.h>
16 #include <openssl/core_names.h>
19 #define CRYPTODEV_NAME_OPENSSL_PMD crypto_openssl
20 /**< Open SSL Crypto PMD device name */
22 /** OPENSSL PMD LOGTYPE DRIVER */
23 extern int openssl_logtype_driver;
24 #define OPENSSL_LOG(level, fmt, ...) \
25 rte_log(RTE_LOG_ ## level, openssl_logtype_driver, \
26 "%s() line %u: " fmt "\n", __func__, __LINE__, \
29 /* Maximum length for digest (SHA-512 needs 64 bytes) */
30 #define DIGEST_LENGTH_MAX 64
32 /** OPENSSL operation order mode enumerator */
33 enum openssl_chain_order {
34 OPENSSL_CHAIN_ONLY_CIPHER,
35 OPENSSL_CHAIN_ONLY_AUTH,
36 OPENSSL_CHAIN_CIPHER_BPI,
37 OPENSSL_CHAIN_CIPHER_AUTH,
38 OPENSSL_CHAIN_AUTH_CIPHER,
39 OPENSSL_CHAIN_COMBINED,
40 OPENSSL_CHAIN_NOT_SUPPORTED
43 /** OPENSSL cipher mode enumerator */
44 enum openssl_cipher_mode {
46 OPENSSL_CIPHER_DES3CTR,
49 /** OPENSSL auth mode enumerator */
50 enum openssl_auth_mode {
55 /** private data structure for each OPENSSL crypto device */
56 struct openssl_private {
57 unsigned int max_nb_qpairs;
58 /**< Max number of queue pairs */
61 /** OPENSSL crypto queue pair */
64 /**< Queue Pair Identifier */
65 char name[RTE_CRYPTODEV_NAME_MAX_LEN];
66 /**< Unique Queue Pair Name */
67 struct rte_ring *processed_ops;
68 /**< Ring for placing process packets */
69 struct rte_mempool *sess_mp;
70 /**< Session Mempool */
71 struct rte_mempool *sess_mp_priv;
72 /**< Session Private Data Mempool */
73 struct rte_cryptodev_stats stats;
74 /**< Queue pair statistics */
75 uint8_t temp_digest[DIGEST_LENGTH_MAX];
76 /**< Buffer used to store the digest generated
77 * by the driver when verifying a digest provided
78 * by the user (using authentication verify operation)
80 } __rte_cache_aligned;
82 /** OPENSSL crypto private session structure */
83 struct openssl_session {
84 enum openssl_chain_order chain_order;
85 /**< chain order mode */
93 enum rte_crypto_aead_algorithm aead_algo;
94 /**< AEAD algorithm */
96 /** Cipher Parameters */
98 enum rte_crypto_cipher_operation direction;
99 /**< cipher operation direction */
100 enum openssl_cipher_mode mode;
101 /**< cipher operation mode */
102 enum rte_crypto_cipher_algorithm algo;
103 /**< cipher algorithm */
109 /**< key length in bytes */
112 const EVP_CIPHER *evp_algo;
113 /**< pointer to EVP algorithm function */
115 /**< pointer to EVP context structure */
116 EVP_CIPHER_CTX *bpi_ctx;
119 /** Authentication Parameters */
121 enum rte_crypto_auth_operation operation;
122 /**< auth operation generate or verify */
123 enum openssl_auth_mode mode;
124 /**< auth operation mode */
125 enum rte_crypto_auth_algorithm algo;
126 /**< cipher algorithm */
130 const EVP_MD *evp_algo;
131 /**< pointer to EVP algorithm function */
133 /**< pointer to EVP context structure */
138 /**< pointer to EVP key */
139 const EVP_MD *evp_algo;
140 /**< pointer to EVP algorithm function */
141 # if OPENSSL_VERSION_NUMBER >= 0x30000000L
146 /**< pointer to EVP context structure */
152 uint16_t digest_length;
153 /**< digest length */
156 } __rte_cache_aligned;
158 /** OPENSSL crypto private asymmetric session structure */
159 struct openssl_asym_session {
160 enum rte_crypto_asym_xform_type xfrm_type;
164 #if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
180 #if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
181 OSSL_PARAM_BLD * param_bld;
182 OSSL_PARAM_BLD *param_bld_peer;
187 #if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
188 OSSL_PARAM_BLD * param_bld;
192 } __rte_cache_aligned;
193 /** Set and validate OPENSSL crypto session parameters */
195 openssl_set_session_parameters(struct openssl_session *sess,
196 const struct rte_crypto_sym_xform *xform);
198 /** Reset OPENSSL crypto session parameters */
200 openssl_reset_session(struct openssl_session *sess);
202 /** device specific operations function pointer structure */
203 extern struct rte_cryptodev_ops *rte_openssl_pmd_ops;
205 #endif /* _OPENSSL_PMD_PRIVATE_H_ */