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>
12 #define CRYPTODEV_NAME_OPENSSL_PMD crypto_openssl
13 /**< Open SSL Crypto PMD device name */
15 #define OPENSSL_LOG_ERR(fmt, args...) \
16 RTE_LOG(ERR, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
17 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD), \
18 __func__, __LINE__, ## args)
20 #ifdef RTE_LIBRTE_OPENSSL_DEBUG
21 #define OPENSSL_LOG_INFO(fmt, args...) \
22 RTE_LOG(INFO, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
23 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD), \
24 __func__, __LINE__, ## args)
26 #define OPENSSL_LOG_DBG(fmt, args...) \
27 RTE_LOG(DEBUG, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
28 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD), \
29 __func__, __LINE__, ## args)
31 #define OPENSSL_LOG_INFO(fmt, args...)
32 #define OPENSSL_LOG_DBG(fmt, args...)
35 /* Maximum length for digest (SHA-512 needs 64 bytes) */
36 #define DIGEST_LENGTH_MAX 64
38 /** OPENSSL operation order mode enumerator */
39 enum openssl_chain_order {
40 OPENSSL_CHAIN_ONLY_CIPHER,
41 OPENSSL_CHAIN_ONLY_AUTH,
42 OPENSSL_CHAIN_CIPHER_BPI,
43 OPENSSL_CHAIN_CIPHER_AUTH,
44 OPENSSL_CHAIN_AUTH_CIPHER,
45 OPENSSL_CHAIN_COMBINED,
46 OPENSSL_CHAIN_NOT_SUPPORTED
49 /** OPENSSL cipher mode enumerator */
50 enum openssl_cipher_mode {
52 OPENSSL_CIPHER_DES3CTR,
55 /** OPENSSL auth mode enumerator */
56 enum openssl_auth_mode {
61 /** private data structure for each OPENSSL crypto device */
62 struct openssl_private {
63 unsigned int max_nb_qpairs;
64 /**< Max number of queue pairs */
65 unsigned int max_nb_sessions;
66 /**< Max number of sessions */
69 /** OPENSSL crypto queue pair */
72 /**< Queue Pair Identifier */
73 char name[RTE_CRYPTODEV_NAME_MAX_LEN];
74 /**< Unique Queue Pair Name */
75 struct rte_ring *processed_ops;
76 /**< Ring for placing process packets */
77 struct rte_mempool *sess_mp;
78 /**< Session Mempool */
79 struct rte_cryptodev_stats stats;
80 /**< Queue pair statistics */
81 uint8_t temp_digest[DIGEST_LENGTH_MAX];
82 /**< Buffer used to store the digest generated
83 * by the driver when verifying a digest provided
84 * by the user (using authentication verify operation)
86 } __rte_cache_aligned;
88 /** OPENSSL crypto private session structure */
89 struct openssl_session {
90 enum openssl_chain_order chain_order;
91 /**< chain order mode */
99 enum rte_crypto_aead_algorithm aead_algo;
100 /**< AEAD algorithm */
102 /** Cipher Parameters */
104 enum rte_crypto_cipher_operation direction;
105 /**< cipher operation direction */
106 enum openssl_cipher_mode mode;
107 /**< cipher operation mode */
108 enum rte_crypto_cipher_algorithm algo;
109 /**< cipher algorithm */
115 /**< key length in bytes */
118 const EVP_CIPHER *evp_algo;
119 /**< pointer to EVP algorithm function */
121 /**< pointer to EVP context structure */
122 EVP_CIPHER_CTX *bpi_ctx;
125 /** Authentication Parameters */
127 enum rte_crypto_auth_operation operation;
128 /**< auth operation generate or verify */
129 enum openssl_auth_mode mode;
130 /**< auth operation mode */
131 enum rte_crypto_auth_algorithm algo;
132 /**< cipher algorithm */
136 const EVP_MD *evp_algo;
137 /**< pointer to EVP algorithm function */
139 /**< pointer to EVP context structure */
144 /**< pointer to EVP key */
145 const EVP_MD *evp_algo;
146 /**< pointer to EVP algorithm function */
148 /**< pointer to EVP context structure */
154 uint16_t digest_length;
155 /**< digest length */
158 } __rte_cache_aligned;
160 /** Set and validate OPENSSL crypto session parameters */
162 openssl_set_session_parameters(struct openssl_session *sess,
163 const struct rte_crypto_sym_xform *xform);
165 /** Reset OPENSSL crypto session parameters */
167 openssl_reset_session(struct openssl_session *sess);
169 /** device specific operations function pointer structure */
170 extern struct rte_cryptodev_ops *rte_openssl_pmd_ops;
172 #endif /* _OPENSSL_PMD_PRIVATE_H_ */