1
2
3
4
5#ifndef _OPENSSL_PMD_PRIVATE_H_
6#define _OPENSSL_PMD_PRIVATE_H_
7
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>
14
15#define CRYPTODEV_NAME_OPENSSL_PMD crypto_openssl
16
17
18
19extern 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__, \
23 ## __VA_ARGS__)
24
25
26#define DIGEST_LENGTH_MAX 64
27
28
29enum 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
37};
38
39
40enum openssl_cipher_mode {
41 OPENSSL_CIPHER_LIB,
42 OPENSSL_CIPHER_DES3CTR,
43};
44
45
46enum openssl_auth_mode {
47 OPENSSL_AUTH_AS_AUTH,
48 OPENSSL_AUTH_AS_HMAC,
49};
50
51
52struct openssl_private {
53 unsigned int max_nb_qpairs;
54
55};
56
57
58struct openssl_qp {
59 uint16_t id;
60
61 char name[RTE_CRYPTODEV_NAME_MAX_LEN];
62
63 struct rte_ring *processed_ops;
64
65 struct rte_mempool *sess_mp;
66
67 struct rte_mempool *sess_mp_priv;
68
69 struct rte_cryptodev_stats stats;
70
71 uint8_t temp_digest[DIGEST_LENGTH_MAX];
72
73
74
75
76} __rte_cache_aligned;
77
78
79struct openssl_session {
80 enum openssl_chain_order chain_order;
81
82
83 struct {
84 uint16_t length;
85 uint16_t offset;
86 } iv;
87
88
89 enum rte_crypto_aead_algorithm aead_algo;
90
91
92
93 struct {
94 enum rte_crypto_cipher_operation direction;
95
96 enum openssl_cipher_mode mode;
97
98 enum rte_crypto_cipher_algorithm algo;
99
100
101 struct {
102 uint8_t data[32];
103
104 size_t length;
105
106 } key;
107
108 const EVP_CIPHER *evp_algo;
109
110 EVP_CIPHER_CTX *ctx;
111
112 EVP_CIPHER_CTX *bpi_ctx;
113 } cipher;
114
115
116 struct {
117 enum rte_crypto_auth_operation operation;
118
119 enum openssl_auth_mode mode;
120
121 enum rte_crypto_auth_algorithm algo;
122
123
124 union {
125 struct {
126 const EVP_MD *evp_algo;
127
128 EVP_MD_CTX *ctx;
129
130 } auth;
131
132 struct {
133 EVP_PKEY *pkey;
134
135 const EVP_MD *evp_algo;
136
137 HMAC_CTX *ctx;
138
139 } hmac;
140 };
141
142 uint16_t aad_length;
143
144 uint16_t digest_length;
145
146 } auth;
147
148} __rte_cache_aligned;
149
150
151struct openssl_asym_session {
152 enum rte_crypto_asym_xform_type xfrm_type;
153 union {
154 struct rsa {
155 RSA *rsa;
156 } r;
157 struct exp {
158 BIGNUM *exp;
159 BIGNUM *mod;
160 BN_CTX *ctx;
161 } e;
162 struct mod {
163 BIGNUM *modulus;
164 BN_CTX *ctx;
165 } m;
166 struct dh {
167 DH *dh_key;
168 uint32_t key_op;
169 } dh;
170 struct {
171 DSA *dsa;
172 } s;
173 } u;
174} __rte_cache_aligned;
175
176extern int
177openssl_set_session_parameters(struct openssl_session *sess,
178 const struct rte_crypto_sym_xform *xform);
179
180
181extern void
182openssl_reset_session(struct openssl_session *sess);
183
184
185extern struct rte_cryptodev_ops *rte_openssl_pmd_ops;
186
187#endif
188