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 /** OPENSSL PMD LOGTYPE DRIVER */
16 int openssl_logtype_driver;
17 #define OPENSSL_LOG(level, fmt, ...) \
18 rte_log(RTE_LOG_ ## level, openssl_logtype_driver, \
19 "%s() line %u: " fmt "\n", __func__, __LINE__, \
22 /* Maximum length for digest (SHA-512 needs 64 bytes) */
23 #define DIGEST_LENGTH_MAX 64
25 /** OPENSSL operation order mode enumerator */
26 enum openssl_chain_order {
27 OPENSSL_CHAIN_ONLY_CIPHER,
28 OPENSSL_CHAIN_ONLY_AUTH,
29 OPENSSL_CHAIN_CIPHER_BPI,
30 OPENSSL_CHAIN_CIPHER_AUTH,
31 OPENSSL_CHAIN_AUTH_CIPHER,
32 OPENSSL_CHAIN_COMBINED,
33 OPENSSL_CHAIN_NOT_SUPPORTED
36 /** OPENSSL cipher mode enumerator */
37 enum openssl_cipher_mode {
39 OPENSSL_CIPHER_DES3CTR,
42 /** OPENSSL auth mode enumerator */
43 enum openssl_auth_mode {
48 /** private data structure for each OPENSSL crypto device */
49 struct openssl_private {
50 unsigned int max_nb_qpairs;
51 /**< Max number of queue pairs */
52 unsigned int max_nb_sessions;
53 /**< Max number of sessions */
56 /** OPENSSL crypto queue pair */
59 /**< Queue Pair Identifier */
60 char name[RTE_CRYPTODEV_NAME_MAX_LEN];
61 /**< Unique Queue Pair Name */
62 struct rte_ring *processed_ops;
63 /**< Ring for placing process packets */
64 struct rte_mempool *sess_mp;
65 /**< Session Mempool */
66 struct rte_cryptodev_stats stats;
67 /**< Queue pair statistics */
68 uint8_t temp_digest[DIGEST_LENGTH_MAX];
69 /**< Buffer used to store the digest generated
70 * by the driver when verifying a digest provided
71 * by the user (using authentication verify operation)
73 } __rte_cache_aligned;
75 /** OPENSSL crypto private session structure */
76 struct openssl_session {
77 enum openssl_chain_order chain_order;
78 /**< chain order mode */
86 enum rte_crypto_aead_algorithm aead_algo;
87 /**< AEAD algorithm */
89 /** Cipher Parameters */
91 enum rte_crypto_cipher_operation direction;
92 /**< cipher operation direction */
93 enum openssl_cipher_mode mode;
94 /**< cipher operation mode */
95 enum rte_crypto_cipher_algorithm algo;
96 /**< cipher algorithm */
102 /**< key length in bytes */
105 const EVP_CIPHER *evp_algo;
106 /**< pointer to EVP algorithm function */
108 /**< pointer to EVP context structure */
109 EVP_CIPHER_CTX *bpi_ctx;
112 /** Authentication Parameters */
114 enum rte_crypto_auth_operation operation;
115 /**< auth operation generate or verify */
116 enum openssl_auth_mode mode;
117 /**< auth operation mode */
118 enum rte_crypto_auth_algorithm algo;
119 /**< cipher algorithm */
123 const EVP_MD *evp_algo;
124 /**< pointer to EVP algorithm function */
126 /**< pointer to EVP context structure */
131 /**< pointer to EVP key */
132 const EVP_MD *evp_algo;
133 /**< pointer to EVP algorithm function */
135 /**< pointer to EVP context structure */
141 uint16_t digest_length;
142 /**< digest length */
145 } __rte_cache_aligned;
147 /** Set and validate OPENSSL crypto session parameters */
149 openssl_set_session_parameters(struct openssl_session *sess,
150 const struct rte_crypto_sym_xform *xform);
152 /** Reset OPENSSL crypto session parameters */
154 openssl_reset_session(struct openssl_session *sess);
156 /** device specific operations function pointer structure */
157 extern struct rte_cryptodev_ops *rte_openssl_pmd_ops;
159 #endif /* _OPENSSL_PMD_PRIVATE_H_ */