]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/include/internal/evp_int.h
KMAC implementation using EVP_MAC
[thirdparty/openssl.git] / crypto / include / internal / evp_int.h
CommitLineData
27af42f9 1/*
0d664759 2 * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
27af42f9 3 *
aa6bb135
RS
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
27af42f9
DSH
8 */
9
c0804614 10#include <openssl/evp.h>
2f545ae4
KR
11#include "internal/refcount.h"
12
4803717f
PY
13/*
14 * Don't free up md_ctx->pctx in EVP_MD_CTX_reset, use the reserved flag
15 * values in evp.h
16 */
17#define EVP_MD_CTX_FLAG_KEEP_PKEY_CTX 0x0400
18
27af42f9
DSH
19struct evp_pkey_ctx_st {
20 /* Method associated with this operation */
21 const EVP_PKEY_METHOD *pmeth;
22 /* Engine that implements this method or NULL if builtin */
23 ENGINE *engine;
24 /* Key: may be NULL */
25 EVP_PKEY *pkey;
26 /* Peer key for key agreement, may be NULL */
27 EVP_PKEY *peerkey;
28 /* Actual operation */
29 int operation;
30 /* Algorithm specific data */
31 void *data;
32 /* Application specific data */
33 void *app_data;
34 /* Keygen callback */
35 EVP_PKEY_gen_cb *pkey_gencb;
36 /* implementation specific keygen data */
37 int *keygen_info;
38 int keygen_info_count;
39} /* EVP_PKEY_CTX */ ;
40
41#define EVP_PKEY_FLAG_DYNAMIC 1
42
43struct evp_pkey_method_st {
44 int pkey_id;
45 int flags;
46 int (*init) (EVP_PKEY_CTX *ctx);
47 int (*copy) (EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src);
48 void (*cleanup) (EVP_PKEY_CTX *ctx);
49 int (*paramgen_init) (EVP_PKEY_CTX *ctx);
50 int (*paramgen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
51 int (*keygen_init) (EVP_PKEY_CTX *ctx);
52 int (*keygen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
53 int (*sign_init) (EVP_PKEY_CTX *ctx);
54 int (*sign) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
55 const unsigned char *tbs, size_t tbslen);
56 int (*verify_init) (EVP_PKEY_CTX *ctx);
57 int (*verify) (EVP_PKEY_CTX *ctx,
58 const unsigned char *sig, size_t siglen,
59 const unsigned char *tbs, size_t tbslen);
60 int (*verify_recover_init) (EVP_PKEY_CTX *ctx);
61 int (*verify_recover) (EVP_PKEY_CTX *ctx,
62 unsigned char *rout, size_t *routlen,
63 const unsigned char *sig, size_t siglen);
64 int (*signctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
65 int (*signctx) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
66 EVP_MD_CTX *mctx);
67 int (*verifyctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
68 int (*verifyctx) (EVP_PKEY_CTX *ctx, const unsigned char *sig, int siglen,
69 EVP_MD_CTX *mctx);
70 int (*encrypt_init) (EVP_PKEY_CTX *ctx);
71 int (*encrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
72 const unsigned char *in, size_t inlen);
73 int (*decrypt_init) (EVP_PKEY_CTX *ctx);
74 int (*decrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
75 const unsigned char *in, size_t inlen);
76 int (*derive_init) (EVP_PKEY_CTX *ctx);
77 int (*derive) (EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen);
78 int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1, void *p2);
79 int (*ctrl_str) (EVP_PKEY_CTX *ctx, const char *type, const char *value);
f723c98e
DSH
80 int (*digestsign) (EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen,
81 const unsigned char *tbs, size_t tbslen);
82 int (*digestverify) (EVP_MD_CTX *ctx, const unsigned char *sig,
83 size_t siglen, const unsigned char *tbs,
84 size_t tbslen);
2aee35d3 85 int (*check) (EVP_PKEY *pkey);
b0004708
PY
86 int (*public_check) (EVP_PKEY *pkey);
87 int (*param_check) (EVP_PKEY *pkey);
0a8fdef7
PY
88
89 int (*digest_custom) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
27af42f9
DSH
90} /* EVP_PKEY_METHOD */ ;
91
a8eba56e 92DEFINE_STACK_OF_CONST(EVP_PKEY_METHOD)
4a1f3f27 93
27af42f9 94void evp_pkey_set_cb_translate(BN_GENCB *cb, EVP_PKEY_CTX *ctx);
8f463dbd
DSH
95
96extern const EVP_PKEY_METHOD cmac_pkey_meth;
97extern const EVP_PKEY_METHOD dh_pkey_meth;
98extern const EVP_PKEY_METHOD dhx_pkey_meth;
99extern const EVP_PKEY_METHOD dsa_pkey_meth;
100extern const EVP_PKEY_METHOD ec_pkey_meth;
ddb634fe 101extern const EVP_PKEY_METHOD sm2_pkey_meth;
262bd85f 102extern const EVP_PKEY_METHOD ecx25519_pkey_meth;
13735cfe 103extern const EVP_PKEY_METHOD ecx448_pkey_meth;
42a3008a 104extern const EVP_PKEY_METHOD ed25519_pkey_meth;
13735cfe 105extern const EVP_PKEY_METHOD ed448_pkey_meth;
8f463dbd
DSH
106extern const EVP_PKEY_METHOD hmac_pkey_meth;
107extern const EVP_PKEY_METHOD rsa_pkey_meth;
6577e008 108extern const EVP_PKEY_METHOD rsa_pss_pkey_meth;
cefa762e 109extern const EVP_PKEY_METHOD scrypt_pkey_meth;
1eff3485 110extern const EVP_PKEY_METHOD tls1_prf_pkey_meth;
aacfb134 111extern const EVP_PKEY_METHOD hkdf_pkey_meth;
52ad5b60 112extern const EVP_PKEY_METHOD poly1305_pkey_meth;
3f5616d7 113extern const EVP_PKEY_METHOD siphash_pkey_meth;
2db6bf6f 114
567db2c1
RL
115/* struct evp_mac_impl_st is defined by the implementation */
116typedef struct evp_mac_impl_st EVP_MAC_IMPL;
117struct evp_mac_st {
118 int type;
119 EVP_MAC_IMPL *(*new) (void);
120 int (*copy) (EVP_MAC_IMPL *macdst, EVP_MAC_IMPL *macsrc);
121 void (*free) (EVP_MAC_IMPL *macctx);
122 size_t (*size) (EVP_MAC_IMPL *macctx);
123 int (*init) (EVP_MAC_IMPL *macctx);
124 int (*update) (EVP_MAC_IMPL *macctx, const unsigned char *data,
125 size_t datalen);
126 int (*final) (EVP_MAC_IMPL *macctx, unsigned char *out);
127 int (*ctrl) (EVP_MAC_IMPL *macctx, int cmd, va_list args);
128 int (*ctrl_str) (EVP_MAC_IMPL *macctx, const char *type, const char *value);
129};
130
f71faf27 131extern const EVP_MAC cmac_meth;
afc580b9 132extern const EVP_MAC gmac_meth;
6723f867 133extern const EVP_MAC hmac_meth;
6e624a64
SL
134extern const EVP_MAC kmac128_meth;
135extern const EVP_MAC kmac256_meth;
c89d9cda 136extern const EVP_MAC siphash_meth;
c1da4b2a 137extern const EVP_MAC poly1305_meth;
f71faf27 138
6e624a64
SL
139/* Internal keccak algorithms used for KMAC */
140const EVP_MD *evp_keccak_kmac128(void);
141const EVP_MD *evp_keccak_kmac256(void);
142
567db2c1
RL
143/*
144 * This function is internal for now, but can be made external when needed.
145 * The documentation would read:
146 *
147 * EVP_add_mac() adds the MAC implementation C<mac> to the internal
148 * object database.
149 */
150int EVP_add_mac(const EVP_MAC *mac);
151
2db6bf6f
RL
152struct evp_md_st {
153 int type;
154 int pkey_type;
155 int md_size;
156 unsigned long flags;
157 int (*init) (EVP_MD_CTX *ctx);
158 int (*update) (EVP_MD_CTX *ctx, const void *data, size_t count);
159 int (*final) (EVP_MD_CTX *ctx, unsigned char *md);
160 int (*copy) (EVP_MD_CTX *to, const EVP_MD_CTX *from);
161 int (*cleanup) (EVP_MD_CTX *ctx);
162 int block_size;
163 int ctx_size; /* how big does the ctx->md_data need to be */
164 /* control function */
165 int (*md_ctrl) (EVP_MD_CTX *ctx, int cmd, int p1, void *p2);
166} /* EVP_MD */ ;
167
e79f8773
RL
168struct evp_cipher_st {
169 int nid;
170 int block_size;
171 /* Default value for variable length ciphers */
172 int key_len;
173 int iv_len;
174 /* Various flags */
175 unsigned long flags;
176 /* init key */
177 int (*init) (EVP_CIPHER_CTX *ctx, const unsigned char *key,
178 const unsigned char *iv, int enc);
179 /* encrypt/decrypt data */
180 int (*do_cipher) (EVP_CIPHER_CTX *ctx, unsigned char *out,
181 const unsigned char *in, size_t inl);
182 /* cleanup ctx */
183 int (*cleanup) (EVP_CIPHER_CTX *);
184 /* how big ctx->cipher_data needs to be */
185 int ctx_size;
186 /* Populate a ASN1_TYPE with parameters */
187 int (*set_asn1_parameters) (EVP_CIPHER_CTX *, ASN1_TYPE *);
188 /* Get parameters from a ASN1_TYPE */
189 int (*get_asn1_parameters) (EVP_CIPHER_CTX *, ASN1_TYPE *);
190 /* Miscellaneous operations */
191 int (*ctrl) (EVP_CIPHER_CTX *, int type, int arg, void *ptr);
192 /* Application data */
193 void *app_data;
194} /* EVP_CIPHER */ ;
195
196/* Macros to code block cipher wrappers */
197
198/* Wrapper functions for each cipher mode */
199
44ab2dfd
MC
200#define EVP_C_DATA(kstruct, ctx) \
201 ((kstruct *)EVP_CIPHER_CTX_get_cipher_data(ctx))
e79f8773
RL
202
203#define BLOCK_CIPHER_ecb_loop() \
204 size_t i, bl; \
205 bl = EVP_CIPHER_CTX_cipher(ctx)->block_size; \
e8aa8b6c 206 if (inl < bl) return 1;\
e79f8773 207 inl -= bl; \
e8aa8b6c 208 for (i=0; i <= inl; i+=bl)
e79f8773
RL
209
210#define BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \
211static int cname##_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \
212{\
213 BLOCK_CIPHER_ecb_loop() \
214 cprefix##_ecb_encrypt(in + i, out + i, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_encrypting(ctx)); \
215 return 1;\
216}
217
218#define EVP_MAXCHUNK ((size_t)1<<(sizeof(long)*8-2))
219
220#define BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) \
221 static int cname##_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \
222{\
223 while(inl>=EVP_MAXCHUNK) {\
224 int num = EVP_CIPHER_CTX_num(ctx);\
225 cprefix##_ofb##cbits##_encrypt(in, out, (long)EVP_MAXCHUNK, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), &num); \
226 EVP_CIPHER_CTX_set_num(ctx, num);\
227 inl-=EVP_MAXCHUNK;\
228 in +=EVP_MAXCHUNK;\
229 out+=EVP_MAXCHUNK;\
230 }\
231 if (inl) {\
232 int num = EVP_CIPHER_CTX_num(ctx);\
233 cprefix##_ofb##cbits##_encrypt(in, out, (long)inl, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), &num); \
234 EVP_CIPHER_CTX_set_num(ctx, num);\
235 }\
236 return 1;\
237}
238
239#define BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \
240static int cname##_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \
241{\
242 while(inl>=EVP_MAXCHUNK) \
243 {\
244 cprefix##_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), EVP_CIPHER_CTX_encrypting(ctx));\
245 inl-=EVP_MAXCHUNK;\
246 in +=EVP_MAXCHUNK;\
247 out+=EVP_MAXCHUNK;\
248 }\
249 if (inl)\
250 cprefix##_cbc_encrypt(in, out, (long)inl, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), EVP_CIPHER_CTX_encrypting(ctx));\
251 return 1;\
252}
253
254#define BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \
255static int cname##_cfb##cbits##_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \
256{\
e8aa8b6c
F
257 size_t chunk = EVP_MAXCHUNK;\
258 if (cbits == 1) chunk >>= 3;\
259 if (inl < chunk) chunk = inl;\
260 while (inl && inl >= chunk)\
261 {\
262 int num = EVP_CIPHER_CTX_num(ctx);\
263 cprefix##_cfb##cbits##_encrypt(in, out, (long) \
264 ((cbits == 1) \
265 && !EVP_CIPHER_CTX_test_flags(ctx, EVP_CIPH_FLAG_LENGTH_BITS) \
604e591e 266 ? chunk*8 : chunk), \
e8aa8b6c
F
267 &EVP_C_DATA(kstruct, ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx),\
268 &num, EVP_CIPHER_CTX_encrypting(ctx));\
269 EVP_CIPHER_CTX_set_num(ctx, num);\
270 inl -= chunk;\
271 in += chunk;\
272 out += chunk;\
273 if (inl < chunk) chunk = inl;\
274 }\
275 return 1;\
e79f8773
RL
276}
277
278#define BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \
279 BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \
280 BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \
281 BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \
282 BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched)
283
284#define BLOCK_CIPHER_def1(cname, nmode, mode, MODE, kstruct, nid, block_size, \
285 key_len, iv_len, flags, init_key, cleanup, \
286 set_asn1, get_asn1, ctrl) \
287static const EVP_CIPHER cname##_##mode = { \
288 nid##_##nmode, block_size, key_len, iv_len, \
289 flags | EVP_CIPH_##MODE##_MODE, \
290 init_key, \
291 cname##_##mode##_cipher, \
292 cleanup, \
293 sizeof(kstruct), \
294 set_asn1, get_asn1,\
295 ctrl, \
296 NULL \
297}; \
298const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
299
300#define BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, \
301 iv_len, flags, init_key, cleanup, set_asn1, \
302 get_asn1, ctrl) \
303BLOCK_CIPHER_def1(cname, cbc, cbc, CBC, kstruct, nid, block_size, key_len, \
304 iv_len, flags, init_key, cleanup, set_asn1, get_asn1, ctrl)
305
306#define BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, \
307 iv_len, cbits, flags, init_key, cleanup, \
308 set_asn1, get_asn1, ctrl) \
309BLOCK_CIPHER_def1(cname, cfb##cbits, cfb##cbits, CFB, kstruct, nid, 1, \
310 key_len, iv_len, flags, init_key, cleanup, set_asn1, \
311 get_asn1, ctrl)
312
313#define BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, \
314 iv_len, cbits, flags, init_key, cleanup, \
315 set_asn1, get_asn1, ctrl) \
316BLOCK_CIPHER_def1(cname, ofb##cbits, ofb, OFB, kstruct, nid, 1, \
317 key_len, iv_len, flags, init_key, cleanup, set_asn1, \
318 get_asn1, ctrl)
319
320#define BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, \
321 flags, init_key, cleanup, set_asn1, \
322 get_asn1, ctrl) \
323BLOCK_CIPHER_def1(cname, ecb, ecb, ECB, kstruct, nid, block_size, key_len, \
324 0, flags, init_key, cleanup, set_asn1, get_asn1, ctrl)
325
326#define BLOCK_CIPHER_defs(cname, kstruct, \
327 nid, block_size, key_len, iv_len, cbits, flags, \
328 init_key, cleanup, set_asn1, get_asn1, ctrl) \
329BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, iv_len, flags, \
330 init_key, cleanup, set_asn1, get_asn1, ctrl) \
331BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, iv_len, cbits, \
332 flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \
333BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, iv_len, cbits, \
334 flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \
335BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, flags, \
336 init_key, cleanup, set_asn1, get_asn1, ctrl)
337
338/*-
339#define BLOCK_CIPHER_defs(cname, kstruct, \
340 nid, block_size, key_len, iv_len, flags,\
341 init_key, cleanup, set_asn1, get_asn1, ctrl)\
342static const EVP_CIPHER cname##_cbc = {\
343 nid##_cbc, block_size, key_len, iv_len, \
344 flags | EVP_CIPH_CBC_MODE,\
345 init_key,\
346 cname##_cbc_cipher,\
347 cleanup,\
348 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\
349 sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\
350 set_asn1, get_asn1,\
351 ctrl, \
352 NULL \
353};\
354const EVP_CIPHER *EVP_##cname##_cbc(void) { return &cname##_cbc; }\
355static const EVP_CIPHER cname##_cfb = {\
356 nid##_cfb64, 1, key_len, iv_len, \
357 flags | EVP_CIPH_CFB_MODE,\
358 init_key,\
359 cname##_cfb_cipher,\
360 cleanup,\
361 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\
362 sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\
363 set_asn1, get_asn1,\
364 ctrl,\
365 NULL \
366};\
367const EVP_CIPHER *EVP_##cname##_cfb(void) { return &cname##_cfb; }\
368static const EVP_CIPHER cname##_ofb = {\
369 nid##_ofb64, 1, key_len, iv_len, \
370 flags | EVP_CIPH_OFB_MODE,\
371 init_key,\
372 cname##_ofb_cipher,\
373 cleanup,\
374 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\
375 sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\
376 set_asn1, get_asn1,\
377 ctrl,\
378 NULL \
379};\
380const EVP_CIPHER *EVP_##cname##_ofb(void) { return &cname##_ofb; }\
381static const EVP_CIPHER cname##_ecb = {\
382 nid##_ecb, block_size, key_len, iv_len, \
383 flags | EVP_CIPH_ECB_MODE,\
384 init_key,\
385 cname##_ecb_cipher,\
386 cleanup,\
387 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\
388 sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\
389 set_asn1, get_asn1,\
390 ctrl,\
391 NULL \
392};\
393const EVP_CIPHER *EVP_##cname##_ecb(void) { return &cname##_ecb; }
394*/
395
396#define IMPLEMENT_BLOCK_CIPHER(cname, ksched, cprefix, kstruct, nid, \
397 block_size, key_len, iv_len, cbits, \
398 flags, init_key, \
399 cleanup, set_asn1, get_asn1, ctrl) \
400 BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \
401 BLOCK_CIPHER_defs(cname, kstruct, nid, block_size, key_len, iv_len, \
402 cbits, flags, init_key, cleanup, set_asn1, \
403 get_asn1, ctrl)
404
405#define IMPLEMENT_CFBR(cipher,cprefix,kstruct,ksched,keysize,cbits,iv_len,fl) \
406 BLOCK_CIPHER_func_cfb(cipher##_##keysize,cprefix,cbits,kstruct,ksched) \
407 BLOCK_CIPHER_def_cfb(cipher##_##keysize,kstruct, \
408 NID_##cipher##_##keysize, keysize/8, iv_len, cbits, \
409 (fl)|EVP_CIPH_FLAG_DEFAULT_ASN1, \
410 cipher##_init_key, NULL, NULL, NULL, NULL)
411
3aeb9348 412
13735cfe
MC
413# ifndef OPENSSL_NO_EC
414
415#define X25519_KEYLEN 32
416#define X448_KEYLEN 56
417#define ED448_KEYLEN 57
418
419#define MAX_KEYLEN ED448_KEYLEN
420
421typedef struct {
422 unsigned char pubkey[MAX_KEYLEN];
423 unsigned char *privkey;
424} ECX_KEY;
425
426#endif
427
3aeb9348
DSH
428/*
429 * Type needs to be a bit field Sub-type needs to be for variations on the
430 * method, as in, can it do arbitrary encryption....
431 */
432struct evp_pkey_st {
433 int type;
434 int save_type;
2f545ae4 435 CRYPTO_REF_COUNT references;
3aeb9348
DSH
436 const EVP_PKEY_ASN1_METHOD *ameth;
437 ENGINE *engine;
d19b01ad 438 ENGINE *pmeth_engine; /* If not NULL public key ENGINE to use */
3aeb9348 439 union {
a4cb54d2 440 void *ptr;
3aeb9348
DSH
441# ifndef OPENSSL_NO_RSA
442 struct rsa_st *rsa; /* RSA */
443# endif
444# ifndef OPENSSL_NO_DSA
445 struct dsa_st *dsa; /* DSA */
446# endif
447# ifndef OPENSSL_NO_DH
448 struct dh_st *dh; /* DH */
449# endif
450# ifndef OPENSSL_NO_EC
451 struct ec_key_st *ec; /* ECC */
13735cfe 452 ECX_KEY *ecx; /* X25519, X448, Ed25519, Ed448 */
3aeb9348
DSH
453# endif
454 } pkey;
455 int save_parameters;
456 STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */
03273d61 457 CRYPTO_RWLOCK *lock;
3aeb9348 458} /* EVP_PKEY */ ;
7b9f8f7f
MC
459
460
b3599dbb
MC
461void openssl_add_all_ciphers_int(void);
462void openssl_add_all_digests_int(void);
0145dd32 463void openssl_add_all_macs_int(void);
b3599dbb 464void evp_cleanup_int(void);
0822e89a 465void evp_app_cleanup_int(void);
9d6fcd42 466
46f4e1be 467/* Pulling defines out of C source files */
9d6fcd42
TS
468
469#define EVP_RC4_KEY_SIZE 16
470#ifndef TLS1_1_VERSION
471# define TLS1_1_VERSION 0x0302
472#endif
c0804614
MC
473
474void evp_encode_ctx_set_flags(EVP_ENCODE_CTX *ctx, unsigned int flags);
475
476/* EVP_ENCODE_CTX flags */
3fd59700
MC
477/* Don't generate new lines when encoding */
478#define EVP_ENCODE_CTX_NO_NEWLINES 1
479/* Use the SRP base64 alphabet instead of the standard one */
480#define EVP_ENCODE_CTX_USE_SRP_ALPHABET 2