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>
13 #define CRYPTODEV_NAME_OPENSSL_PMD crypto_openssl
14 /**< Open SSL Crypto PMD device name */
16 /** OPENSSL PMD LOGTYPE DRIVER */
17 int openssl_logtype_driver;
18 #define OPENSSL_LOG(level, fmt, ...) \
19 rte_log(RTE_LOG_ ## level, openssl_logtype_driver, \
20 "%s() line %u: " fmt "\n", __func__, __LINE__, \
23 /* Maximum length for digest (SHA-512 needs 64 bytes) */
24 #define DIGEST_LENGTH_MAX 64
26 /** OPENSSL operation order mode enumerator */
27 enum openssl_chain_order {
28 OPENSSL_CHAIN_ONLY_CIPHER,
29 OPENSSL_CHAIN_ONLY_AUTH,
30 OPENSSL_CHAIN_CIPHER_BPI,
31 OPENSSL_CHAIN_CIPHER_AUTH,
32 OPENSSL_CHAIN_AUTH_CIPHER,
33 OPENSSL_CHAIN_COMBINED,
34 OPENSSL_CHAIN_NOT_SUPPORTED
37 /** OPENSSL cipher mode enumerator */
38 enum openssl_cipher_mode {
40 OPENSSL_CIPHER_DES3CTR,
43 /** OPENSSL auth mode enumerator */
44 enum openssl_auth_mode {
49 /** private data structure for each OPENSSL crypto device */
50 struct openssl_private {
51 unsigned int max_nb_qpairs;
52 /**< Max number of queue pairs */
55 /** OPENSSL crypto queue pair */
58 /**< Queue Pair Identifier */
59 char name[RTE_CRYPTODEV_NAME_MAX_LEN];
60 /**< Unique Queue Pair Name */
61 struct rte_ring *processed_ops;
62 /**< Ring for placing process packets */
63 struct rte_mempool *sess_mp;
64 /**< Session Mempool */
65 struct rte_cryptodev_stats stats;
66 /**< Queue pair statistics */
67 uint8_t temp_digest[DIGEST_LENGTH_MAX];
68 /**< Buffer used to store the digest generated
69 * by the driver when verifying a digest provided
70 * by the user (using authentication verify operation)
72 } __rte_cache_aligned;
74 /** OPENSSL crypto private session structure */
75 struct openssl_session {
76 enum openssl_chain_order chain_order;
77 /**< chain order mode */
85 enum rte_crypto_aead_algorithm aead_algo;
86 /**< AEAD algorithm */
88 /** Cipher Parameters */
90 enum rte_crypto_cipher_operation direction;
91 /**< cipher operation direction */
92 enum openssl_cipher_mode mode;
93 /**< cipher operation mode */
94 enum rte_crypto_cipher_algorithm algo;
95 /**< cipher algorithm */
101 /**< key length in bytes */
104 const EVP_CIPHER *evp_algo;
105 /**< pointer to EVP algorithm function */
107 /**< pointer to EVP context structure */
108 EVP_CIPHER_CTX *bpi_ctx;
111 /** Authentication Parameters */
113 enum rte_crypto_auth_operation operation;
114 /**< auth operation generate or verify */
115 enum openssl_auth_mode mode;
116 /**< auth operation mode */
117 enum rte_crypto_auth_algorithm algo;
118 /**< cipher algorithm */
122 const EVP_MD *evp_algo;
123 /**< pointer to EVP algorithm function */
125 /**< pointer to EVP context structure */
130 /**< pointer to EVP key */
131 const EVP_MD *evp_algo;
132 /**< pointer to EVP algorithm function */
134 /**< pointer to EVP context structure */
140 uint16_t digest_length;
141 /**< digest length */
144 } __rte_cache_aligned;
146 /** OPENSSL crypto private asymmetric session structure */
147 struct openssl_asym_session {
148 enum rte_crypto_asym_xform_type xfrm_type;
163 } __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_ */