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>
15 #define CRYPTODEV_NAME_OPENSSL_PMD crypto_openssl
16 /**< Open SSL Crypto PMD device name */
18 /** OPENSSL PMD LOGTYPE DRIVER */
19 int openssl_logtype_driver;
20 #define OPENSSL_LOG(level, fmt, ...) \
21 rte_log(RTE_LOG_ ## level, openssl_logtype_driver, \
22 "%s() line %u: " fmt "\n", __func__, __LINE__, \
25 /* Maximum length for digest (SHA-512 needs 64 bytes) */
26 #define DIGEST_LENGTH_MAX 64
28 /** OPENSSL operation order mode enumerator */
29 enum openssl_chain_order {
30 OPENSSL_CHAIN_ONLY_CIPHER,
31 OPENSSL_CHAIN_ONLY_AUTH,
32 OPENSSL_CHAIN_CIPHER_BPI,
33 OPENSSL_CHAIN_CIPHER_AUTH,
34 OPENSSL_CHAIN_AUTH_CIPHER,
35 OPENSSL_CHAIN_COMBINED,
36 OPENSSL_CHAIN_NOT_SUPPORTED
39 /** OPENSSL cipher mode enumerator */
40 enum openssl_cipher_mode {
42 OPENSSL_CIPHER_DES3CTR,
45 /** OPENSSL auth mode enumerator */
46 enum openssl_auth_mode {
51 /** private data structure for each OPENSSL crypto device */
52 struct openssl_private {
53 unsigned int max_nb_qpairs;
54 /**< Max number of queue pairs */
57 /** OPENSSL crypto queue pair */
60 /**< Queue Pair Identifier */
61 char name[RTE_CRYPTODEV_NAME_MAX_LEN];
62 /**< Unique Queue Pair Name */
63 struct rte_ring *processed_ops;
64 /**< Ring for placing process packets */
65 struct rte_mempool *sess_mp;
66 /**< Session Mempool */
67 struct rte_mempool *sess_mp_priv;
68 /**< Session Private Data Mempool */
69 struct rte_cryptodev_stats stats;
70 /**< Queue pair statistics */
71 uint8_t temp_digest[DIGEST_LENGTH_MAX];
72 /**< Buffer used to store the digest generated
73 * by the driver when verifying a digest provided
74 * by the user (using authentication verify operation)
76 } __rte_cache_aligned;
78 /** OPENSSL crypto private session structure */
79 struct openssl_session {
80 enum openssl_chain_order chain_order;
81 /**< chain order mode */
89 enum rte_crypto_aead_algorithm aead_algo;
90 /**< AEAD algorithm */
92 /** Cipher Parameters */
94 enum rte_crypto_cipher_operation direction;
95 /**< cipher operation direction */
96 enum openssl_cipher_mode mode;
97 /**< cipher operation mode */
98 enum rte_crypto_cipher_algorithm algo;
99 /**< cipher algorithm */
105 /**< key length in bytes */
108 const EVP_CIPHER *evp_algo;
109 /**< pointer to EVP algorithm function */
111 /**< pointer to EVP context structure */
112 EVP_CIPHER_CTX *bpi_ctx;
115 /** Authentication Parameters */
117 enum rte_crypto_auth_operation operation;
118 /**< auth operation generate or verify */
119 enum openssl_auth_mode mode;
120 /**< auth operation mode */
121 enum rte_crypto_auth_algorithm algo;
122 /**< cipher algorithm */
126 const EVP_MD *evp_algo;
127 /**< pointer to EVP algorithm function */
129 /**< pointer to EVP context structure */
134 /**< pointer to EVP key */
135 const EVP_MD *evp_algo;
136 /**< pointer to EVP algorithm function */
138 /**< pointer to EVP context structure */
144 uint16_t digest_length;
145 /**< digest length */
148 } __rte_cache_aligned;
150 /** OPENSSL crypto private asymmetric session structure */
151 struct openssl_asym_session {
152 enum rte_crypto_asym_xform_type xfrm_type;
174 } __rte_cache_aligned;
175 /** Set and validate OPENSSL crypto session parameters */
177 openssl_set_session_parameters(struct openssl_session *sess,
178 const struct rte_crypto_sym_xform *xform);
180 /** Reset OPENSSL crypto session parameters */
182 openssl_reset_session(struct openssl_session *sess);
184 /** device specific operations function pointer structure */
185 extern struct rte_cryptodev_ops *rte_openssl_pmd_ops;
187 #endif /* _OPENSSL_PMD_PRIVATE_H_ */