]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/include/internal/evp_int.h
blake2b: add EVP_MAC API
[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 *
48f4ad77 4 * Licensed under the Apache License 2.0 (the "License"). You may not use
aa6bb135
RS
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
c3a261f8 131extern const EVP_MAC blake2b_mac_meth;
f71faf27 132extern const EVP_MAC cmac_meth;
afc580b9 133extern const EVP_MAC gmac_meth;
6723f867 134extern const EVP_MAC hmac_meth;
6e624a64
SL
135extern const EVP_MAC kmac128_meth;
136extern const EVP_MAC kmac256_meth;
c89d9cda 137extern const EVP_MAC siphash_meth;
c1da4b2a 138extern const EVP_MAC poly1305_meth;
f71faf27 139
6e624a64
SL
140/* Internal keccak algorithms used for KMAC */
141const EVP_MD *evp_keccak_kmac128(void);
142const EVP_MD *evp_keccak_kmac256(void);
143
567db2c1
RL
144/*
145 * This function is internal for now, but can be made external when needed.
146 * The documentation would read:
147 *
148 * EVP_add_mac() adds the MAC implementation C<mac> to the internal
149 * object database.
150 */
151int EVP_add_mac(const EVP_MAC *mac);
152
2db6bf6f
RL
153struct evp_md_st {
154 int type;
155 int pkey_type;
156 int md_size;
157 unsigned long flags;
158 int (*init) (EVP_MD_CTX *ctx);
159 int (*update) (EVP_MD_CTX *ctx, const void *data, size_t count);
160 int (*final) (EVP_MD_CTX *ctx, unsigned char *md);
161 int (*copy) (EVP_MD_CTX *to, const EVP_MD_CTX *from);
162 int (*cleanup) (EVP_MD_CTX *ctx);
163 int block_size;
164 int ctx_size; /* how big does the ctx->md_data need to be */
165 /* control function */
166 int (*md_ctrl) (EVP_MD_CTX *ctx, int cmd, int p1, void *p2);
167} /* EVP_MD */ ;
168
e79f8773
RL
169struct evp_cipher_st {
170 int nid;
171 int block_size;
172 /* Default value for variable length ciphers */
173 int key_len;
174 int iv_len;
175 /* Various flags */
176 unsigned long flags;
177 /* init key */
178 int (*init) (EVP_CIPHER_CTX *ctx, const unsigned char *key,
179 const unsigned char *iv, int enc);
180 /* encrypt/decrypt data */
181 int (*do_cipher) (EVP_CIPHER_CTX *ctx, unsigned char *out,
182 const unsigned char *in, size_t inl);
183 /* cleanup ctx */
184 int (*cleanup) (EVP_CIPHER_CTX *);
185 /* how big ctx->cipher_data needs to be */
186 int ctx_size;
187 /* Populate a ASN1_TYPE with parameters */
188 int (*set_asn1_parameters) (EVP_CIPHER_CTX *, ASN1_TYPE *);
189 /* Get parameters from a ASN1_TYPE */
190 int (*get_asn1_parameters) (EVP_CIPHER_CTX *, ASN1_TYPE *);
191 /* Miscellaneous operations */
192 int (*ctrl) (EVP_CIPHER_CTX *, int type, int arg, void *ptr);
193 /* Application data */
194 void *app_data;
195} /* EVP_CIPHER */ ;
196
197/* Macros to code block cipher wrappers */
198
199/* Wrapper functions for each cipher mode */
200
44ab2dfd
MC
201#define EVP_C_DATA(kstruct, ctx) \
202 ((kstruct *)EVP_CIPHER_CTX_get_cipher_data(ctx))
e79f8773
RL
203
204#define BLOCK_CIPHER_ecb_loop() \
205 size_t i, bl; \
206 bl = EVP_CIPHER_CTX_cipher(ctx)->block_size; \
e8aa8b6c 207 if (inl < bl) return 1;\
e79f8773 208 inl -= bl; \
e8aa8b6c 209 for (i=0; i <= inl; i+=bl)
e79f8773
RL
210
211#define BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \
212static int cname##_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \
213{\
214 BLOCK_CIPHER_ecb_loop() \
215 cprefix##_ecb_encrypt(in + i, out + i, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_encrypting(ctx)); \
216 return 1;\
217}
218
219#define EVP_MAXCHUNK ((size_t)1<<(sizeof(long)*8-2))
220
221#define BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) \
222 static int cname##_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \
223{\
224 while(inl>=EVP_MAXCHUNK) {\
225 int num = EVP_CIPHER_CTX_num(ctx);\
226 cprefix##_ofb##cbits##_encrypt(in, out, (long)EVP_MAXCHUNK, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), &num); \
227 EVP_CIPHER_CTX_set_num(ctx, num);\
228 inl-=EVP_MAXCHUNK;\
229 in +=EVP_MAXCHUNK;\
230 out+=EVP_MAXCHUNK;\
231 }\
232 if (inl) {\
233 int num = EVP_CIPHER_CTX_num(ctx);\
234 cprefix##_ofb##cbits##_encrypt(in, out, (long)inl, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), &num); \
235 EVP_CIPHER_CTX_set_num(ctx, num);\
236 }\
237 return 1;\
238}
239
240#define BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \
241static int cname##_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \
242{\
243 while(inl>=EVP_MAXCHUNK) \
244 {\
245 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));\
246 inl-=EVP_MAXCHUNK;\
247 in +=EVP_MAXCHUNK;\
248 out+=EVP_MAXCHUNK;\
249 }\
250 if (inl)\
251 cprefix##_cbc_encrypt(in, out, (long)inl, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), EVP_CIPHER_CTX_encrypting(ctx));\
252 return 1;\
253}
254
255#define BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \
256static int cname##_cfb##cbits##_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \
257{\
e8aa8b6c
F
258 size_t chunk = EVP_MAXCHUNK;\
259 if (cbits == 1) chunk >>= 3;\
260 if (inl < chunk) chunk = inl;\
261 while (inl && inl >= chunk)\
262 {\
263 int num = EVP_CIPHER_CTX_num(ctx);\
264 cprefix##_cfb##cbits##_encrypt(in, out, (long) \
265 ((cbits == 1) \
266 && !EVP_CIPHER_CTX_test_flags(ctx, EVP_CIPH_FLAG_LENGTH_BITS) \
604e591e 267 ? chunk*8 : chunk), \
e8aa8b6c
F
268 &EVP_C_DATA(kstruct, ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx),\
269 &num, EVP_CIPHER_CTX_encrypting(ctx));\
270 EVP_CIPHER_CTX_set_num(ctx, num);\
271 inl -= chunk;\
272 in += chunk;\
273 out += chunk;\
274 if (inl < chunk) chunk = inl;\
275 }\
276 return 1;\
e79f8773
RL
277}
278
279#define BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \
280 BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \
281 BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \
282 BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \
283 BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched)
284
285#define BLOCK_CIPHER_def1(cname, nmode, mode, MODE, kstruct, nid, block_size, \
286 key_len, iv_len, flags, init_key, cleanup, \
287 set_asn1, get_asn1, ctrl) \
288static const EVP_CIPHER cname##_##mode = { \
289 nid##_##nmode, block_size, key_len, iv_len, \
290 flags | EVP_CIPH_##MODE##_MODE, \
291 init_key, \
292 cname##_##mode##_cipher, \
293 cleanup, \
294 sizeof(kstruct), \
295 set_asn1, get_asn1,\
296 ctrl, \
297 NULL \
298}; \
299const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
300
301#define BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, \
302 iv_len, flags, init_key, cleanup, set_asn1, \
303 get_asn1, ctrl) \
304BLOCK_CIPHER_def1(cname, cbc, cbc, CBC, kstruct, nid, block_size, key_len, \
305 iv_len, flags, init_key, cleanup, set_asn1, get_asn1, ctrl)
306
307#define BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, \
308 iv_len, cbits, flags, init_key, cleanup, \
309 set_asn1, get_asn1, ctrl) \
310BLOCK_CIPHER_def1(cname, cfb##cbits, cfb##cbits, CFB, kstruct, nid, 1, \
311 key_len, iv_len, flags, init_key, cleanup, set_asn1, \
312 get_asn1, ctrl)
313
314#define BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, \
315 iv_len, cbits, flags, init_key, cleanup, \
316 set_asn1, get_asn1, ctrl) \
317BLOCK_CIPHER_def1(cname, ofb##cbits, ofb, OFB, kstruct, nid, 1, \
318 key_len, iv_len, flags, init_key, cleanup, set_asn1, \
319 get_asn1, ctrl)
320
321#define BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, \
322 flags, init_key, cleanup, set_asn1, \
323 get_asn1, ctrl) \
324BLOCK_CIPHER_def1(cname, ecb, ecb, ECB, kstruct, nid, block_size, key_len, \
325 0, flags, init_key, cleanup, set_asn1, get_asn1, ctrl)
326
327#define BLOCK_CIPHER_defs(cname, kstruct, \
328 nid, block_size, key_len, iv_len, cbits, flags, \
329 init_key, cleanup, set_asn1, get_asn1, ctrl) \
330BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, iv_len, flags, \
331 init_key, cleanup, set_asn1, get_asn1, ctrl) \
332BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, iv_len, cbits, \
333 flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \
334BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, iv_len, cbits, \
335 flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \
336BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, flags, \
337 init_key, cleanup, set_asn1, get_asn1, ctrl)
338
339/*-
340#define BLOCK_CIPHER_defs(cname, kstruct, \
341 nid, block_size, key_len, iv_len, flags,\
342 init_key, cleanup, set_asn1, get_asn1, ctrl)\
343static const EVP_CIPHER cname##_cbc = {\
344 nid##_cbc, block_size, key_len, iv_len, \
345 flags | EVP_CIPH_CBC_MODE,\
346 init_key,\
347 cname##_cbc_cipher,\
348 cleanup,\
349 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\
350 sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\
351 set_asn1, get_asn1,\
352 ctrl, \
353 NULL \
354};\
355const EVP_CIPHER *EVP_##cname##_cbc(void) { return &cname##_cbc; }\
356static const EVP_CIPHER cname##_cfb = {\
357 nid##_cfb64, 1, key_len, iv_len, \
358 flags | EVP_CIPH_CFB_MODE,\
359 init_key,\
360 cname##_cfb_cipher,\
361 cleanup,\
362 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\
363 sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\
364 set_asn1, get_asn1,\
365 ctrl,\
366 NULL \
367};\
368const EVP_CIPHER *EVP_##cname##_cfb(void) { return &cname##_cfb; }\
369static const EVP_CIPHER cname##_ofb = {\
370 nid##_ofb64, 1, key_len, iv_len, \
371 flags | EVP_CIPH_OFB_MODE,\
372 init_key,\
373 cname##_ofb_cipher,\
374 cleanup,\
375 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\
376 sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\
377 set_asn1, get_asn1,\
378 ctrl,\
379 NULL \
380};\
381const EVP_CIPHER *EVP_##cname##_ofb(void) { return &cname##_ofb; }\
382static const EVP_CIPHER cname##_ecb = {\
383 nid##_ecb, block_size, key_len, iv_len, \
384 flags | EVP_CIPH_ECB_MODE,\
385 init_key,\
386 cname##_ecb_cipher,\
387 cleanup,\
388 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\
389 sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\
390 set_asn1, get_asn1,\
391 ctrl,\
392 NULL \
393};\
394const EVP_CIPHER *EVP_##cname##_ecb(void) { return &cname##_ecb; }
395*/
396
397#define IMPLEMENT_BLOCK_CIPHER(cname, ksched, cprefix, kstruct, nid, \
398 block_size, key_len, iv_len, cbits, \
399 flags, init_key, \
400 cleanup, set_asn1, get_asn1, ctrl) \
401 BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \
402 BLOCK_CIPHER_defs(cname, kstruct, nid, block_size, key_len, iv_len, \
403 cbits, flags, init_key, cleanup, set_asn1, \
404 get_asn1, ctrl)
405
406#define IMPLEMENT_CFBR(cipher,cprefix,kstruct,ksched,keysize,cbits,iv_len,fl) \
407 BLOCK_CIPHER_func_cfb(cipher##_##keysize,cprefix,cbits,kstruct,ksched) \
408 BLOCK_CIPHER_def_cfb(cipher##_##keysize,kstruct, \
409 NID_##cipher##_##keysize, keysize/8, iv_len, cbits, \
410 (fl)|EVP_CIPH_FLAG_DEFAULT_ASN1, \
411 cipher##_init_key, NULL, NULL, NULL, NULL)
412
3aeb9348 413
13735cfe
MC
414# ifndef OPENSSL_NO_EC
415
416#define X25519_KEYLEN 32
417#define X448_KEYLEN 56
418#define ED448_KEYLEN 57
419
420#define MAX_KEYLEN ED448_KEYLEN
421
422typedef struct {
423 unsigned char pubkey[MAX_KEYLEN];
424 unsigned char *privkey;
425} ECX_KEY;
426
427#endif
428
3aeb9348
DSH
429/*
430 * Type needs to be a bit field Sub-type needs to be for variations on the
431 * method, as in, can it do arbitrary encryption....
432 */
433struct evp_pkey_st {
434 int type;
435 int save_type;
2f545ae4 436 CRYPTO_REF_COUNT references;
3aeb9348
DSH
437 const EVP_PKEY_ASN1_METHOD *ameth;
438 ENGINE *engine;
d19b01ad 439 ENGINE *pmeth_engine; /* If not NULL public key ENGINE to use */
3aeb9348 440 union {
a4cb54d2 441 void *ptr;
3aeb9348
DSH
442# ifndef OPENSSL_NO_RSA
443 struct rsa_st *rsa; /* RSA */
444# endif
445# ifndef OPENSSL_NO_DSA
446 struct dsa_st *dsa; /* DSA */
447# endif
448# ifndef OPENSSL_NO_DH
449 struct dh_st *dh; /* DH */
450# endif
451# ifndef OPENSSL_NO_EC
452 struct ec_key_st *ec; /* ECC */
13735cfe 453 ECX_KEY *ecx; /* X25519, X448, Ed25519, Ed448 */
3aeb9348
DSH
454# endif
455 } pkey;
456 int save_parameters;
457 STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */
03273d61 458 CRYPTO_RWLOCK *lock;
3aeb9348 459} /* EVP_PKEY */ ;
7b9f8f7f
MC
460
461
b3599dbb
MC
462void openssl_add_all_ciphers_int(void);
463void openssl_add_all_digests_int(void);
0145dd32 464void openssl_add_all_macs_int(void);
b3599dbb 465void evp_cleanup_int(void);
0822e89a 466void evp_app_cleanup_int(void);
9d6fcd42 467
46f4e1be 468/* Pulling defines out of C source files */
9d6fcd42
TS
469
470#define EVP_RC4_KEY_SIZE 16
471#ifndef TLS1_1_VERSION
472# define TLS1_1_VERSION 0x0302
473#endif
c0804614
MC
474
475void evp_encode_ctx_set_flags(EVP_ENCODE_CTX *ctx, unsigned int flags);
476
477/* EVP_ENCODE_CTX flags */
3fd59700
MC
478/* Don't generate new lines when encoding */
479#define EVP_ENCODE_CTX_NO_NEWLINES 1
480/* Use the SRP base64 alphabet instead of the standard one */
481#define EVP_ENCODE_CTX_USE_SRP_ALPHABET 2