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