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_cryptodev_stats stats;
68 /**< Queue pair statistics */
69 uint8_t temp_digest[DIGEST_LENGTH_MAX];
70 /**< Buffer used to store the digest generated
71 * by the driver when verifying a digest provided
72 * by the user (using authentication verify operation)
74 } __rte_cache_aligned;
76 /** OPENSSL crypto private session structure */
77 struct openssl_session {
78 enum openssl_chain_order chain_order;
79 /**< chain order mode */
87 enum rte_crypto_aead_algorithm aead_algo;
88 /**< AEAD algorithm */
90 /** Cipher Parameters */
92 enum rte_crypto_cipher_operation direction;
93 /**< cipher operation direction */
94 enum openssl_cipher_mode mode;
95 /**< cipher operation mode */
96 enum rte_crypto_cipher_algorithm algo;
97 /**< cipher algorithm */
103 /**< key length in bytes */
106 const EVP_CIPHER *evp_algo;
107 /**< pointer to EVP algorithm function */
109 /**< pointer to EVP context structure */
110 EVP_CIPHER_CTX *bpi_ctx;
113 /** Authentication Parameters */
115 enum rte_crypto_auth_operation operation;
116 /**< auth operation generate or verify */
117 enum openssl_auth_mode mode;
118 /**< auth operation mode */
119 enum rte_crypto_auth_algorithm algo;
120 /**< cipher algorithm */
124 const EVP_MD *evp_algo;
125 /**< pointer to EVP algorithm function */
127 /**< pointer to EVP context structure */
132 /**< pointer to EVP key */
133 const EVP_MD *evp_algo;
134 /**< pointer to EVP algorithm function */
136 /**< pointer to EVP context structure */
142 uint16_t digest_length;
143 /**< digest length */
146 } __rte_cache_aligned;
148 /** OPENSSL crypto private asymmetric session structure */
149 struct openssl_asym_session {
150 enum rte_crypto_asym_xform_type xfrm_type;
172 } __rte_cache_aligned;
173 /** Set and validate OPENSSL crypto session parameters */
175 openssl_set_session_parameters(struct openssl_session *sess,
176 const struct rte_crypto_sym_xform *xform);
178 /** Reset OPENSSL crypto session parameters */
180 openssl_reset_session(struct openssl_session *sess);
182 /** device specific operations function pointer structure */
183 extern struct rte_cryptodev_ops *rte_openssl_pmd_ops;
185 #endif /* _OPENSSL_PMD_PRIVATE_H_ */