1 /* crypto/evp/evp.h */
2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3  * All rights reserved.
4  *
5  * This package is an SSL implementation written
6  * by Eric Young (eay@cryptsoft.com).
7  * The implementation was written so as to conform with Netscapes SSL.
8  *
9  * This library is free for commercial and non-commercial use as long as
10  * the following conditions are aheared to.  The following conditions
11  * apply to all code found in this distribution, be it the RC4, RSA,
12  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
13  * included with this distribution is covered by the same copyright terms
14  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15  *
16  * Copyright remains Eric Young's, and as such any Copyright notices in
17  * the code are not to be removed.
18  * If this package is used in a product, Eric Young should be given attribution
19  * as the author of the parts of the library used.
20  * This can be in the form of a textual message at program startup or
21  * in documentation (online or textual) provided with the package.
22  *
23  * Redistribution and use in source and binary forms, with or without
24  * modification, are permitted provided that the following conditions
25  * are met:
26  * 1. Redistributions of source code must retain the copyright
27  *   notice, this list of conditions and the following disclaimer.
28  * 2. Redistributions in binary form must reproduce the above copyright
29  *   notice, this list of conditions and the following disclaimer in the
30  *   documentation and/or other materials provided with the distribution.
31  * 3. All advertising materials mentioning features or use of this software
32  *   must display the following acknowledgement:
33  *   "This product includes cryptographic software written by
34  *    Eric Young (eay@cryptsoft.com)"
35  *   The word 'cryptographic' can be left out if the rouines from the library
36  *   being used are not cryptographic related :-).
37  * 4. If you include any Windows specific code (or a derivative thereof) from
38  *   the apps directory (application code) you must include an acknowledgement:
39  *   "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40  *
41  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51  * SUCH DAMAGE.
52  *
53  * The licence and distribution terms for any publically available version or
54  * derivative of this code cannot be changed.  i.e. this code cannot simply be
55  * copied and put under another distribution licence
56  * [including the GNU Public Licence.]
57  */
58 
59 module deimos.openssl.evp;
60 
61 import deimos.openssl._d_util;
62 
63 import deimos.openssl.x509; // Needed for X509_ATTRIBUTE.
64 
65 //#ifdef OPENSSL_ALGORITHM_DEFINES
66 public import deimos.openssl.opensslconf;
67 //#else
68 //# define OPENSSL_ALGORITHM_DEFINES
69 //public import deimos.openssl.opensslconf;
70 //# undef OPENSSL_ALGORITHM_DEFINES
71 //#endif
72 
73 public import deimos.openssl.ossl_typ;
74 
75 public import deimos.openssl.symhacks;
76 
77 version(OPENSSL_NO_BIO) {} else {
78 public import deimos.openssl.bio;
79 }
80 
81 /*
82 enum EVP_RC2_KEY_SIZE = 16;
83 enum EVP_RC4_KEY_SIZE = 16;
84 enum EVP_BLOWFISH_KEY_SIZE = 16;
85 enum EVP_CAST5_KEY_SIZE = 16;
86 enum EVP_RC5_32_12_16_KEY_SIZE = 16;
87 */
88 enum EVP_MAX_MD_SIZE = 64;	/* longest known is SHA512 */
89 enum EVP_MAX_KEY_LENGTH = 64;
90 enum EVP_MAX_IV_LENGTH = 16;
91 enum EVP_MAX_BLOCK_LENGTH = 32;
92 
93 enum PKCS5_SALT_LEN = 8;
94 /* Default PKCS#5 iteration count */
95 enum PKCS5_DEFAULT_ITER = 2048;
96 
97 public import deimos.openssl.objects;
98 
99 enum EVP_PK_RSA = 0x0001;
100 enum EVP_PK_DSA = 0x0002;
101 enum EVP_PK_DH = 0x0004;
102 enum EVP_PK_EC = 0x0008;
103 enum EVP_PKT_SIGN = 0x0010;
104 enum EVP_PKT_ENC = 0x0020;
105 enum EVP_PKT_EXCH = 0x0040;
106 enum EVP_PKS_RSA = 0x0100;
107 enum EVP_PKS_DSA = 0x0200;
108 enum EVP_PKS_EC = 0x0400;
109 enum EVP_PKT_EXP = 0x1000; /* <= 512 bit key */
110 
111 alias NID_undef EVP_PKEY_NONE;
112 alias NID_rsaEncryption EVP_PKEY_RSA;
113 alias NID_rsa EVP_PKEY_RSA2;
114 alias NID_dsa EVP_PKEY_DSA;
115 alias NID_dsa_2 EVP_PKEY_DSA1;
116 alias NID_dsaWithSHA EVP_PKEY_DSA2;
117 alias NID_dsaWithSHA1 EVP_PKEY_DSA3;
118 alias NID_dsaWithSHA1_2 EVP_PKEY_DSA4;
119 alias NID_dhKeyAgreement EVP_PKEY_DH;
120 alias NID_X9_62_id_ecPublicKey EVP_PKEY_EC;
121 alias NID_hmac EVP_PKEY_HMAC;
122 alias NID_cmac EVP_PKEY_CMAC;
123 
124 extern (C):
125 nothrow:
126 
127 /* Type needs to be a bit field
128  * Sub-type needs to be for variations on the method, as in_, can it do
129  * arbitrary encryption.... */
130 struct evp_pkey_st
131 	{
132 	int type;
133 	int save_type;
134 	int references;
135 	const(EVP_PKEY_ASN1_METHOD)* ameth;
136 	ENGINE* engine;
137 	union pkey_ {
138 		char* ptr;
139 version(OPENSSL_NO_RSA) {} else {
140 		rsa_st* rsa;	/* RSA */
141 }
142 version(OPENSSL_NO_DSA) {} else {
143 		dsa_st* dsa;	/* DSA */
144 }
145 version(OPENSSL_NO_DH) {} else {
146 		dh_st* dh;	/* DH */
147 }
148 version(OPENSSL_NO_EC) {} else {
149 		ec_key_st* ec;	/* ECC */
150 }
151 		}
152 	pkey_ pkey;
153 	int save_parameters;
154 	STACK_OF!(X509_ATTRIBUTE) *attributes; /* [ 0 ] */
155 	} /* EVP_PKEY */;
156 
157 enum EVP_PKEY_MO_SIGN = 0x0001;
158 enum EVP_PKEY_MO_VERIFY = 0x0002;
159 enum EVP_PKEY_MO_ENCRYPT = 0x0004;
160 enum EVP_PKEY_MO_DECRYPT = 0x0008;
161 
162 // #ifndef EVP_MD
163 struct env_md_st
164 	{
165 	int type;
166 	int pkey_type;
167 	int md_size;
168 	c_ulong flags;
169 	ExternC!(int function(EVP_MD_CTX* ctx)) init_;
170 	ExternC!(int function(EVP_MD_CTX* ctx,const(void)* data,size_t count)) update;
171 	ExternC!(int function(EVP_MD_CTX* ctx,ubyte* md)) final_;
172 	ExternC!(int function(EVP_MD_CTX* to,const(EVP_MD_CTX)* from)) copy;
173 	ExternC!(int function(EVP_MD_CTX* ctx)) cleanup;
174 
175 	/* FIXME: prototype these some day */
176 	ExternC!(int function(int type, const(ubyte)* m, uint m_length,
177 		    ubyte* sigret, uint* siglen, void* key)) sign;
178 	ExternC!(int function(int type, const(ubyte)* m, uint m_length,
179 		      const(ubyte)* sigbuf, uint siglen,
180 		      void* key)) verify;
181 	int[5] required_pkey_type; /*EVP_PKEY_xxx */
182 	int block_size;
183 	int ctx_size; /* how big does the ctx->md_data need to be */
184 	/* control function */
185 	ExternC!(int function(EVP_MD_CTX* ctx, int cmd, int p1, void* p2)) md_ctrl;
186 	} /* EVP_MD */;
187 
188 alias typeof(*(ExternC!(int function(int type,const(ubyte)* m,
189 			    uint m_length,ubyte* sigret,
190 			    uint* siglen, void* key))).init) evp_sign_method;
191 alias typeof(*(ExternC!(int function(int type,const(ubyte)* m,
192 			    uint m_length,const(ubyte)* sigbuf,
193 			    uint siglen, void* key))).init) evp_verify_method;
194 
195 enum EVP_MD_FLAG_ONESHOT = 0x0001; /* digest can only handle a single
196 					* block */
197 
198 enum EVP_MD_FLAG_PKEY_DIGEST = 0x0002; /* digest is a "clone" digest used
199 					* which is a copy of an existing
200 					* one for a specific public key type.
201 					* EVP_dss1() etc */
202 
203 /* Digest uses EVP_PKEY_METHOD for signing instead of MD specific signing */
204 
205 enum EVP_MD_FLAG_PKEY_METHOD_SIGNATURE = 0x0004;
206 
207 /* DigestAlgorithmIdentifier flags... */
208 
209 enum EVP_MD_FLAG_DIGALGID_MASK = 0x0018;
210 
211 /* NULL or absent parameter accepted. Use NULL */
212 
213 enum EVP_MD_FLAG_DIGALGID_NULL = 0x0000;
214 
215 /* NULL or absent parameter accepted. Use NULL for PKCS#1 otherwise absent */
216 
217 enum EVP_MD_FLAG_DIGALGID_ABSENT = 0x0008;
218 
219 /* Custom handling via ctrl */
220 
221 enum EVP_MD_FLAG_DIGALGID_CUSTOM = 0x0018;
222 
223 enum EVP_MD_FLAG_FIPS = 0x0400; /* Note if suitable for use in FIPS mode */
224 
225 /* Digest ctrls */
226 
227 enum EVP_MD_CTRL_DIGALGID = 0x1;
228 enum EVP_MD_CTRL_MICALG = 0x2;
229 
230 /* Minimum Algorithm specific ctrl value */
231 
232 enum EVP_MD_CTRL_ALG_CTRL = 0x1000;
233 
234 enum EVP_PKEY_NULL_method = "null,null,{0,0,0,0}";
235 
236 version (OPENSSL_NO_DSA) {
237 	alias EVP_PKEY_NULL_method EVP_PKEY_DSA_method;
238 } else {
239 	enum EVP_PKEY_DSA_method = "cast(evp_sign_method*)&DSA_sign," ~
240 		"cast(evp_verify_method*)&DSA_verify,{EVP_PKEY_DSA,EVP_PKEY_DSA2," ~
241 		"EVP_PKEY_DSA3, EVP_PKEY_DSA4,0}";
242 }
243 
244 version(OPENSSL_NO_ECDSA) {
245 	alias EVP_PKEY_NULL_method EVP_PKEY_ECDSA_method;
246 } else {
247 	enum EVP_PKEY_ECDSA_method = "cast(evp_sign_method*)&ECDSA_sign," ~
248 		"cast(evp_verify_method*)&ECDSA_verify,{EVP_PKEY_EC,0,0,0}";
249 }
250 
251 version (OPENSSL_NO_RSA) {
252 	alias EVP_PKEY_NULL_method EVP_PKEY_RSA_method;
253 	alias EVP_PKEY_NULL_method EVP_PKEY_RSA_ASN1_OCTET_STRING_method;
254 } else {
255 	enum EVP_PKEY_RSA_method = "cast(evp_sign_method*)&RSA_sign," ~
256 		"cast(evp_verify_method*)RSA_verify,{EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0}";
257  	enum EVP_PKEY_RSA_ASN1_OCTET_STRING_method =
258 		"cast(evp_sign_method*)&RSA_sign_ASN1_OCTET_STRING," ~
259 		"cast(evp_verify_method*)RSA_verify_ASN1_OCTET_STRING," ~
260 		"{EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0}";
261 }
262 
263 // #endif /* !EVP_MD */
264 
265 struct env_md_ctx_st
266 	{
267 	const(EVP_MD)* digest;
268 	ENGINE* engine; /* functional reference if 'digest' is ENGINE-provided */
269 	c_ulong flags;
270 	void* md_data;
271 	/* Public key context for sign/verify */
272 	EVP_PKEY_CTX* pctx;
273 	/* Update function: usually copied from EVP_MD */
274 	ExternC!(int function(EVP_MD_CTX* ctx,const(void)* data,size_t count)) update;
275 	} /* EVP_MD_CTX */;
276 
277 /* values for EVP_MD_CTX flags */
278 
279 enum EVP_MD_CTX_FLAG_ONESHOT = 0x0001; /* digest update will be called
280 						* once only */
281 enum EVP_MD_CTX_FLAG_CLEANED = 0x0002; /* context has already been
282 						* cleaned */
283 enum EVP_MD_CTX_FLAG_REUSE = 0x0004; /* Don't free up ctx->md_data
284 						* in EVP_MD_CTX_cleanup */
285 /* FIPS and pad options are ignored in 1.0.0, definitions are here
286  * so we don't accidentally reuse the values for other purposes.
287  */
288 
289 enum EVP_MD_CTX_FLAG_NON_FIPS_ALLOW = 0x0008;	/* Allow use of non FIPS digest
290 						 * in FIPS mode */
291 
292 /* The following PAD options are also currently ignored in 1.0.0, digest
293  * parameters are handled through EVP_DigestSign*() and EVP_DigestVerify*()
294  * instead.
295  */
296 enum EVP_MD_CTX_FLAG_PAD_MASK = 0xF0;	/* RSA mode to use */
297 enum EVP_MD_CTX_FLAG_PAD_PKCS1 = 0x00;	/* PKCS#1 v1.5 mode */
298 enum EVP_MD_CTX_FLAG_PAD_X931 = 0x10;	/* X9.31 mode */
299 enum EVP_MD_CTX_FLAG_PAD_PSS = 0x20;	/* PSS mode */
300 
301 enum EVP_MD_CTX_FLAG_NO_INIT = 0x0100; /* Don't initialize md_data */
302 
303 struct evp_cipher_st
304 	{
305 	int nid;
306 	int block_size;
307 	int key_len;		/* Default value for variable length ciphers */
308 	int iv_len;
309 	c_ulong flags;	/* Various flags */
310 	ExternC!(int function(EVP_CIPHER_CTX* ctx, const(ubyte)* key,
311 		    const(ubyte)* iv, int enc)) init_;	/* init key */
312 	ExternC!(int function(EVP_CIPHER_CTX* ctx, ubyte* out_,
313 			 const(ubyte)* in_, size_t inl)) do_cipher;/* encrypt/decrypt data */
314 	ExternC!(int function(EVP_CIPHER_CTX*)) cleanup; /* cleanup ctx */
315 	int ctx_size;		/* how big ctx->cipher_data needs to be */
316 	ExternC!(int function(EVP_CIPHER_CTX*, ASN1_TYPE*)) set_asn1_parameters; /* Populate a ASN1_TYPE with parameters */
317 	ExternC!(int function(EVP_CIPHER_CTX*, ASN1_TYPE*)) get_asn1_parameters; /* Get parameters from a ASN1_TYPE */
318 	ExternC!(int function(EVP_CIPHER_CTX*, int type, int arg, void* ptr)) ctrl; /* Miscellaneous operations */
319 	void* app_data;		/* Application data */
320 	} /* EVP_CIPHER */;
321 
322 /* Values for cipher flags */
323 
324 /* Modes for ciphers */
325 
326 enum EVP_CIPH_STREAM_CIPHER = 0x0;
327 enum EVP_CIPH_ECB_MODE = 0x1;
328 enum EVP_CIPH_CBC_MODE = 0x2;
329 enum EVP_CIPH_CFB_MODE = 0x3;
330 enum EVP_CIPH_OFB_MODE = 0x4;
331 enum EVP_CIPH_CTR_MODE = 0x5;
332 enum EVP_CIPH_GCM_MODE = 0x6;
333 enum EVP_CIPH_CCM_MODE = 0x7;
334 enum EVP_CIPH_XTS_MODE = 0x10001;
335 enum EVP_CIPH_MODE = 0xF0007;
336 /* Set if variable length cipher */
337 enum EVP_CIPH_VARIABLE_LENGTH = 0x8;
338 /* Set if the iv handling should be done by the cipher itself */
339 enum EVP_CIPH_CUSTOM_IV = 0x10;
340 /* Set if the cipher's init() function should be called if key is NULL */
341 enum EVP_CIPH_ALWAYS_CALL_INIT = 0x20;
342 /* Call ctrl() to init cipher parameters */
343 enum EVP_CIPH_CTRL_INIT = 0x40;
344 /* Don't use standard key length function */
345 enum EVP_CIPH_CUSTOM_KEY_LENGTH = 0x80;
346 /* Don't use standard block padding */
347 enum EVP_CIPH_NO_PADDING = 0x100;
348 /* cipher handles random key generation */
349 enum EVP_CIPH_RAND_KEY = 0x200;
350 /* cipher has its own additional copying logic */
351 enum EVP_CIPH_CUSTOM_COPY = 0x400;
352 /* Allow use default ASN1 get/set iv */
353 enum EVP_CIPH_FLAG_DEFAULT_ASN1 = 0x1000;
354 /* Buffer length in bits not bytes: CFB1 mode only */
355 enum EVP_CIPH_FLAG_LENGTH_BITS = 0x2000;
356 /* Note if suitable for use in FIPS mode */
357 enum EVP_CIPH_FLAG_FIPS = 0x4000;
358 /* Allow non FIPS cipher in FIPS mode */
359 enum EVP_CIPH_FLAG_NON_FIPS_ALLOW = 0x8000;
360 /* Cipher handles any and all padding logic as well
361  * as finalisation.
362  */
363 enum EVP_CIPH_FLAG_CUSTOM_CIPHER = 0x100000;
364 enum EVP_CIPH_FLAG_AEAD_CIPHER = 0x200000;
365 
366 /* ctrl() values */
367 
368 enum EVP_CTRL_INIT = 0x0;
369 enum EVP_CTRL_SET_KEY_LENGTH = 0x1;
370 enum EVP_CTRL_GET_RC2_KEY_BITS = 0x2;
371 enum EVP_CTRL_SET_RC2_KEY_BITS = 0x3;
372 enum EVP_CTRL_GET_RC5_ROUNDS = 0x4;
373 enum EVP_CTRL_SET_RC5_ROUNDS = 0x5;
374 enum EVP_CTRL_RAND_KEY = 0x6;
375 enum EVP_CTRL_PBE_PRF_NID = 0x7;
376 enum EVP_CTRL_COPY = 0x8;
377 enum EVP_CTRL_GCM_SET_IVLEN = 0x9;
378 enum EVP_CTRL_GCM_GET_TAG = 0x10;
379 enum EVP_CTRL_GCM_SET_TAG = 0x11;
380 enum EVP_CTRL_GCM_SET_IV_FIXED = 0x12;
381 enum EVP_CTRL_GCM_IV_GEN = 0x13;
382 alias EVP_CTRL_CCM_SET_IVLEN = EVP_CTRL_GCM_SET_IVLEN;
383 alias EVP_CTRL_CCM_GET_TAG = EVP_CTRL_GCM_GET_TAG;
384 alias EVP_CTRL_CCM_SET_TAG = EVP_CTRL_GCM_SET_TAG;
385 enum EVP_CTRL_CCM_SET_L = 0x14;
386 enum EVP_CTRL_CCM_SET_MSGLEN = 0x15;
387 /* AEAD cipher deduces payload length and returns number of bytes
388  * required to store MAC and eventual padding. Subsequent call to
389  * EVP_Cipher even appends/verifies MAC.
390  */
391 enum EVP_CTRL_AEAD_TLS1_AAD = 0x16;
392 /* Used by composite AEAD ciphers, no-op in GCM, CCM... */
393 enum EVP_CTRL_AEAD_SET_MAC_KEY = 0x17;
394 /* Set the GCM invocation field, decrypt only */
395 enum EVP_CTRL_GCM_SET_IV_INV = 0x18;
396 
397 /* GCM TLS constants */
398 /* Length of fixed part of IV derived from PRF */
399 enum EVP_GCM_TLS_FIXED_IV_LEN = 4;
400 /* Length of explicit part of IV part of TLS records */
401 enum EVP_GCM_TLS_EXPLICIT_IV_LEN = 8;
402 /* Length of tag for TLS */
403 enum EVP_GCM_TLS_TAG_LEN = 16;
404 
405 struct evp_cipher_info_st {
406 	const(EVP_CIPHER)* cipher;
407 	ubyte[EVP_MAX_IV_LENGTH] iv;
408 	}
409 alias evp_cipher_info_st EVP_CIPHER_INFO;
410 
411 struct evp_cipher_ctx_st
412 	{
413 	const(EVP_CIPHER)* cipher;
414 	ENGINE* engine;	/* functional reference if 'cipher' is ENGINE-provided */
415 	int encrypt;		/* encrypt or decrypt */
416 	int buf_len;		/* number we have left */
417 
418 	ubyte[EVP_MAX_IV_LENGTH]  oiv;	/* original iv */
419 	ubyte[EVP_MAX_IV_LENGTH]  iv;	/* working iv */
420 	ubyte[EVP_MAX_BLOCK_LENGTH] buf;/* saved partial block */
421 	int num;				/* used by cfb/ofb mode */
422 
423 	void* app_data;		/* application stuff */
424 	int key_len;		/* May change for variable length cipher */
425 	c_ulong flags;	/* Various flags */
426 	void* cipher_data; /* per EVP data */
427 	int final_used;
428 	int block_mask;
429 	ubyte[EVP_MAX_BLOCK_LENGTH] final_;/* possible final block */
430 	} /* EVP_CIPHER_CTX */;
431 
432 struct evp_Encode_Ctx_st {
433 	int num;	/* number saved in a partial encode/decode */
434 	int length;	/* The length is either the output line length
435 			 * (in input bytes) or the shortest input line
436 			 * length that is ok.  Once decoding begins,
437 			 * the length is adjusted up each time a longer
438 			 * line is decoded */
439 	ubyte[80] enc_data;	/* data to encode */
440 	int line_num;	/* number read on current line */
441 	int expect_nl;
442 	}
443 alias evp_Encode_Ctx_st EVP_ENCODE_CTX;
444 
445 /* Password based encryption function */
446 alias typeof(*(ExternC!(int function(EVP_CIPHER_CTX* ctx, const(char)* pass, int passlen,
447 		ASN1_TYPE* param, const(EVP_CIPHER)* cipher,
448                 const(EVP_MD)* md, int en_de))).init) EVP_PBE_KEYGEN;
449 
450 version(OPENSSL_NO_RSA) {} else {
451 	auto EVP_PKEY_assign_RSA()(EVP_PKEY* pkey, RSA* key) {
452 		return EVP_PKEY_assign(pkey,EVP_PKEY_RSA,cast(void*)key);
453 	}
454 }
455 
456 version(OPENSSL_NO_DSA) {} else {
457 	auto EVP_PKEY_assign_RSA()(EVP_PKEY* pkey, DSA* key) {
458 		return EVP_PKEY_assign(pkey,EVP_PKEY_DSA,cast(void*)key);
459 	}
460 }
461 
462 version(OPENSSL_NO_DH) {} else {
463 	auto EVP_PKEY_assign_DH()(EVP_PKEY* pkey, DH* key) {
464 		return EVP_PKEY_assign(pkey,EVP_PKEY_DH,cast(void*)key);
465 	}
466 }
467 
468 version(OPENSSL_NO_EC) {} else {
469 	auto EVP_PKEY_assign_EC_KEY()(EVP_PKEY* pkey, EC_KEY* key) {
470 		return EVP_PKEY_assign(pkey,EVP_PKEY_EC,cast(void*)key);
471 	}
472 }
473 
474 /* Add some extra combinations */
475 auto EVP_get_digestbynid()(int a) { return EVP_get_digestbyname(OBJ_nid2sn(a)); }
476 auto EVP_get_digestbyobj()(const(ASN1_OBJECT)* a) { return EVP_get_digestbynid(OBJ_obj2nid(a)); }
477 auto EVP_get_cipherbynid()(int a) { return EVP_get_cipherbyname(OBJ_nid2sn(a)); }
478 auto EVP_get_cipherbyobj()(const(ASN1_OBJECT)* a) { return EVP_get_cipherbynid(OBJ_obj2nid(a)); }
479 
480 int EVP_MD_type(const(EVP_MD)* md);
481 alias EVP_MD_type EVP_MD_nid;
482 auto EVP_MD_name()(const(EVP_MD)* e) { return OBJ_nid2sn(EVP_MD_nid(e)); }
483 int EVP_MD_pkey_type(const(EVP_MD)* md);
484 int EVP_MD_size(const(EVP_MD)* md);
485 int EVP_MD_block_size(const(EVP_MD)* md);
486 c_ulong EVP_MD_flags(const(EVP_MD)* md);
487 
488 const(EVP_MD)* EVP_MD_CTX_md(const(EVP_MD_CTX)* ctx);
489 auto EVP_MD_CTX_size()(const(EVP_MD_CTX)* e) { return EVP_MD_size(EVP_MD_CTX_md(e)); }
490 auto EVP_MD_CTX_block_size()(const(EVP_MD_CTX)* e) { return EVP_MD_block_size(EVP_MD_CTX_md(e)); }
491 auto EVP_MD_CTX_type()(const(EVP_MD_CTX)* e) { return EVP_MD_type(EVP_MD_CTX_md(e)); }
492 
493 int EVP_CIPHER_nid(const(EVP_CIPHER)* cipher);
494 auto EVP_CIPHER_name()(const(EVP_CIPHER)* e){ return OBJ_nid2sn(EVP_CIPHER_nid(e)); }
495 int EVP_CIPHER_block_size(const(EVP_CIPHER)* cipher);
496 int EVP_CIPHER_key_length(const(EVP_CIPHER)* cipher);
497 int EVP_CIPHER_iv_length(const(EVP_CIPHER)* cipher);
498 c_ulong EVP_CIPHER_flags(const(EVP_CIPHER)* cipher);
499 auto EVP_CIPHER_mode()(const(EVP_CIPHER)* e) { return (EVP_CIPHER_flags(e) & EVP_CIPH_MODE); }
500 
501 const(EVP_CIPHER)* EVP_CIPHER_CTX_cipher(const(EVP_CIPHER_CTX)* ctx);
502 int EVP_CIPHER_CTX_nid(const(EVP_CIPHER_CTX)* ctx);
503 int EVP_CIPHER_CTX_block_size(const(EVP_CIPHER_CTX)* ctx);
504 int EVP_CIPHER_CTX_key_length(const(EVP_CIPHER_CTX)* ctx);
505 int EVP_CIPHER_CTX_iv_length(const(EVP_CIPHER_CTX)* ctx);
506 int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX* out_, const(EVP_CIPHER_CTX)* in_);
507 void* EVP_CIPHER_CTX_get_app_data(const(EVP_CIPHER_CTX)* ctx);
508 void EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX* ctx, void* data);
509 auto EVP_CIPHER_CTX_type()(const(EVP_CIPHER_CTX)* c) { return EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c)); }
510 c_ulong EVP_CIPHER_CTX_flags(const(EVP_CIPHER_CTX)* ctx);
511 auto EVP_CIPHER_CTX_mode()(const(EVP_CIPHER_CTX)* e) { return (EVP_CIPHER_CTX_flags(e) & EVP_CIPH_MODE); }
512 
513 auto EVP_ENCODE_LENGTH(T)(T l) { return (((l+2)/3*4)+(l/48+1)*2+80); }
514 auto EVP_DECODE_LENGTH(T)(T l) { return ((l+3)/4*3+80); }
515 
516 alias EVP_DigestInit_ex EVP_SignInit_ex;
517 alias EVP_DigestInit EVP_SignInit;
518 alias EVP_DigestUpdate EVP_SignUpdate;
519 alias EVP_DigestInit_ex EVP_VerifyInit_ex;
520 alias EVP_DigestInit EVP_VerifyInit;
521 alias EVP_DigestUpdate EVP_VerifyUpdate;
522 alias EVP_DecryptUpdate EVP_OpenUpdate;
523 alias EVP_EncryptUpdate EVP_SealUpdate;
524 alias EVP_DigestUpdate EVP_DigestSignUpdate;
525 alias EVP_DigestUpdate EVP_DigestVerifyUpdate;
526 
527 void BIO_set_md()(BIO* b,const(EVP_MD)* md) { return BIO_ctrl(b,BIO_C_SET_MD,0,md); }
528 auto BIO_get_md()(BIO* b,EVP_MD** mdp) { return BIO_ctrl(b,BIO_C_GET_MD,0,mdp); }
529 auto BIO_get_md_ctx()(BIO* b,EVP_MD_CTX** mdcp) { return BIO_ctrl(b,BIO_C_GET_MD_CTX,0,mdcp); }
530 auto BIO_set_md_ctx()(BIO* b,EVP_MD_CTX** mdcp) { return BIO_ctrl(b,BIO_C_SET_MD_CTX,0,mdcp); }
531 auto BIO_get_cipher_status()(BIO* b) { return BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,null); }
532 auto BIO_get_cipher_ctx()(BIO* b,EVP_CIPHER_CTX** c_pp) { return BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0,c_pp); }
533 
534 int EVP_Cipher(EVP_CIPHER_CTX* c,
535 		ubyte* out_,
536 		const(ubyte)* in_,
537 		uint inl);
538 
539 auto EVP_add_cipher_alias()(const(char)* n,const(char)* alias_) {
540 	return OBJ_NAME_add(alias_,OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS,(n));
541 }
542 auto EVP_add_digest_alias()(const(char)* n,const(char)* alias_) {
543 	return OBJ_NAME_add(alias_,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,(n));
544 }
545 auto EVP_delete_cipher_alias()(const(char)* alias_) {
546 	return OBJ_NAME_remove(alias_,OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS);
547 }
548 auto EVP_delete_digest_alias()(const(char)* alias_) {
549 	return OBJ_NAME_remove(alias_,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS);
550 }
551 
552 void	EVP_MD_CTX_init(EVP_MD_CTX* ctx);
553 int	EVP_MD_CTX_cleanup(EVP_MD_CTX* ctx);
554 
555 alias EVP_MD_CTX_create = EVP_MD_CTX_new;
556 alias EVP_MD_CTX_destroy = EVP_MD_CTX_free;
557 
558 EVP_MD_CTX* EVP_MD_CTX_new();
559 void	EVP_MD_CTX_free(EVP_MD_CTX* ctx);
560 int     EVP_MD_CTX_copy_ex(EVP_MD_CTX* out_,const(EVP_MD_CTX)* in_);
561 void	EVP_MD_CTX_set_flags(EVP_MD_CTX* ctx, int flags);
562 void	EVP_MD_CTX_clear_flags(EVP_MD_CTX* ctx, int flags);
563 int 	EVP_MD_CTX_test_flags(const(EVP_MD_CTX)* ctx,int flags);
564 int	EVP_DigestInit_ex(EVP_MD_CTX* ctx, const(EVP_MD)* type, ENGINE* impl);
565 int	EVP_DigestUpdate(EVP_MD_CTX* ctx,const(void)* d,
566 			 size_t cnt);
567 int	EVP_DigestFinal_ex(EVP_MD_CTX* ctx,ubyte* md,uint* s);
568 int	EVP_Digest(const(void)* data, size_t count,
569 		ubyte* md, uint* size, const(EVP_MD)* type, ENGINE* impl);
570 
571 int     EVP_MD_CTX_copy(EVP_MD_CTX* out_,const(EVP_MD_CTX)* in_);
572 int	EVP_DigestInit(EVP_MD_CTX* ctx, const(EVP_MD)* type);
573 int	EVP_DigestFinal(EVP_MD_CTX* ctx,ubyte* md,uint* s);
574 
575 int	EVP_read_pw_string(char* buf,int length,const(char)* prompt,int verify);
576 int	EVP_read_pw_string_min(char* buf,int minlen,int maxlen,const(char)* prompt,int verify);
577 void	EVP_set_pw_prompt(const(char)* prompt);
578 char* 	EVP_get_pw_prompt();
579 
580 int	EVP_BytesToKey(const(EVP_CIPHER)* type,const(EVP_MD)* md,
581 		const(ubyte)* salt, const(ubyte)* data,
582 		int datal, int count, ubyte* key,ubyte* iv);
583 
584 void	EVP_CIPHER_CTX_set_flags(EVP_CIPHER_CTX* ctx, int flags);
585 void	EVP_CIPHER_CTX_clear_flags(EVP_CIPHER_CTX* ctx, int flags);
586 int 	EVP_CIPHER_CTX_test_flags(const(EVP_CIPHER_CTX)* ctx,int flags);
587 
588 int	EVP_EncryptInit(EVP_CIPHER_CTX* ctx,const(EVP_CIPHER)* cipher,
589 		const(ubyte)* key, const(ubyte)* iv);
590 int	EVP_EncryptInit_ex(EVP_CIPHER_CTX* ctx,const(EVP_CIPHER)* cipher, ENGINE* impl,
591 		const(ubyte)* key, const(ubyte)* iv);
592 int	EVP_EncryptUpdate(EVP_CIPHER_CTX* ctx, ubyte* out_,
593 		int* outl, const(ubyte)* in_, int inl);
594 int	EVP_EncryptFinal_ex(EVP_CIPHER_CTX* ctx, ubyte* out_, int* outl);
595 int	EVP_EncryptFinal(EVP_CIPHER_CTX* ctx, ubyte* out_, int* outl);
596 
597 int	EVP_DecryptInit(EVP_CIPHER_CTX* ctx,const(EVP_CIPHER)* cipher,
598 		const(ubyte)* key, const(ubyte)* iv);
599 int	EVP_DecryptInit_ex(EVP_CIPHER_CTX* ctx,const(EVP_CIPHER)* cipher, ENGINE* impl,
600 		const(ubyte)* key, const(ubyte)* iv);
601 int	EVP_DecryptUpdate(EVP_CIPHER_CTX* ctx, ubyte* out_,
602 		int* outl, const(ubyte)* in_, int inl);
603 int	EVP_DecryptFinal(EVP_CIPHER_CTX* ctx, ubyte* outm, int* outl);
604 int	EVP_DecryptFinal_ex(EVP_CIPHER_CTX* ctx, ubyte* outm, int* outl);
605 
606 int	EVP_CipherInit(EVP_CIPHER_CTX* ctx,const(EVP_CIPHER)* cipher,
607 		       const(ubyte)* key,const(ubyte)* iv,
608 		       int enc);
609 int	EVP_CipherInit_ex(EVP_CIPHER_CTX* ctx,const(EVP_CIPHER)* cipher, ENGINE* impl,
610 		       const(ubyte)* key,const(ubyte)* iv,
611 		       int enc);
612 int	EVP_CipherUpdate(EVP_CIPHER_CTX* ctx, ubyte* out_,
613 		int* outl, const(ubyte)* in_, int inl);
614 int	EVP_CipherFinal(EVP_CIPHER_CTX* ctx, ubyte* outm, int* outl);
615 int	EVP_CipherFinal_ex(EVP_CIPHER_CTX* ctx, ubyte* outm, int* outl);
616 
617 int	EVP_SignFinal(EVP_MD_CTX* ctx,ubyte* md,uint* s,
618 		EVP_PKEY* pkey);
619 
620 int	EVP_VerifyFinal(EVP_MD_CTX* ctx,const(ubyte)* sigbuf,
621 		uint siglen,EVP_PKEY* pkey);
622 
623 int	EVP_DigestSignInit(EVP_MD_CTX* ctx, EVP_PKEY_CTX** pctx,
624 			const(EVP_MD)* type, ENGINE* e, EVP_PKEY* pkey);
625 int	EVP_DigestSignFinal(EVP_MD_CTX* ctx,
626 			ubyte* sigret, size_t* siglen);
627 
628 int	EVP_DigestVerifyInit(EVP_MD_CTX* ctx, EVP_PKEY_CTX** pctx,
629 			const(EVP_MD)* type, ENGINE* e, EVP_PKEY* pkey);
630 int	EVP_DigestVerifyFinal(EVP_MD_CTX* ctx,
631 			ubyte* sig, size_t siglen);
632 
633 int	EVP_OpenInit(EVP_CIPHER_CTX* ctx,const(EVP_CIPHER)* type,
634 		const(ubyte)* ek, int ekl, const(ubyte)* iv,
635 		EVP_PKEY* priv);
636 int	EVP_OpenFinal(EVP_CIPHER_CTX* ctx, ubyte* out_, int* outl);
637 
638 int	EVP_SealInit(EVP_CIPHER_CTX* ctx, const(EVP_CIPHER)* type,
639 		 ubyte** ek, int* ekl, ubyte* iv,
640 		EVP_PKEY** pubk, int npubk);
641 int	EVP_SealFinal(EVP_CIPHER_CTX* ctx,ubyte* out_,int* outl);
642 
643 void	EVP_EncodeInit(EVP_ENCODE_CTX* ctx);
644 void	EVP_EncodeUpdate(EVP_ENCODE_CTX* ctx,ubyte* out_,int* outl,
645 		const(ubyte)* in_,int inl);
646 void	EVP_EncodeFinal(EVP_ENCODE_CTX* ctx,ubyte* out_,int* outl);
647 int	EVP_EncodeBlock(ubyte* t, const(ubyte)* f, int n);
648 
649 void	EVP_DecodeInit(EVP_ENCODE_CTX* ctx);
650 int	EVP_DecodeUpdate(EVP_ENCODE_CTX* ctx,ubyte* out_,int* outl,
651 		const(ubyte)* in_, int inl);
652 int	EVP_DecodeFinal(EVP_ENCODE_CTX* ctx, ubyte* out_, int* outl);
653 int	EVP_DecodeBlock(ubyte* t, const(ubyte)* f, int n);
654 
655 void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX* a);
656 int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX* a);
657 EVP_CIPHER_CTX* EVP_CIPHER_CTX_new();
658 void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX* a);
659 int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX* x, int keylen);
660 int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX* c, int pad);
661 int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX* ctx, int type, int arg, void* ptr);
662 int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX* ctx, ubyte* key);
663 
664 version(OPENSSL_NO_BIO) {} else {
665 BIO_METHOD* BIO_f_md();
666 BIO_METHOD* BIO_f_base64();
667 BIO_METHOD* BIO_f_cipher();
668 BIO_METHOD* BIO_f_reliable();
669 void BIO_set_cipher(BIO* b,const(EVP_CIPHER)* c,const(ubyte)* k,
670 		const(ubyte)* i, int enc);
671 }
672 
673 const(EVP_MD)* EVP_md_null();
674 version(OPENSSL_NO_MD2) {} else {
675 const(EVP_MD)* EVP_md2();
676 }
677 version(OPENSSL_NO_MD4) {} else {
678 const(EVP_MD)* EVP_md4();
679 }
680 version(OPENSSL_NO_MD5) {} else {
681 const(EVP_MD)* EVP_md5();
682 }
683 version(OPENSSL_NO_SHA) {} else {
684 const(EVP_MD)* EVP_sha();
685 const(EVP_MD)* EVP_sha1();
686 const(EVP_MD)* EVP_dss();
687 const(EVP_MD)* EVP_dss1();
688 const(EVP_MD)* EVP_ecdsa();
689 }
690 version(OPENSSL_NO_SHA256) {} else {
691 const(EVP_MD)* EVP_sha224();
692 const(EVP_MD)* EVP_sha256();
693 }
694 version(OPENSSL_NO_SHA512) {} else {
695 const(EVP_MD)* EVP_sha384();
696 const(EVP_MD)* EVP_sha512();
697 }
698 version(OPENSSL_NO_MDC2) {} else {
699 const(EVP_MD)* EVP_mdc2();
700 }
701 version(OPENSSL_NO_RIPEMD) {} else {
702 const(EVP_MD)* EVP_ripemd160();
703 }
704 version(OPENSSL_NO_WHIRLPOOL) {} else {
705 const(EVP_MD)* EVP_whirlpool();
706 }
707 const(EVP_CIPHER)* EVP_enc_null();		/* does nothing :-) */
708 version (OPENSSL_NO_DES) {} else {
709 const(EVP_CIPHER)* EVP_des_ecb();
710 const(EVP_CIPHER)* EVP_des_ede();
711 const(EVP_CIPHER)* EVP_des_ede3();
712 const(EVP_CIPHER)* EVP_des_ede_ecb();
713 const(EVP_CIPHER)* EVP_des_ede3_ecb();
714 const(EVP_CIPHER)* EVP_des_cfb64();
715 alias EVP_des_cfb64 EVP_des_cfb;
716 const(EVP_CIPHER)* EVP_des_cfb1();
717 const(EVP_CIPHER)* EVP_des_cfb8();
718 const(EVP_CIPHER)* EVP_des_ede_cfb64();
719 alias EVP_des_ede_cfb64 EVP_des_ede_cfb;
720 version (none) {
721 const(EVP_CIPHER)* EVP_des_ede_cfb1();
722 const(EVP_CIPHER)* EVP_des_ede_cfb8();
723 }
724 const(EVP_CIPHER)* EVP_des_ede3_cfb64();
725 alias EVP_des_ede3_cfb64 EVP_des_ede3_cfb;
726 const(EVP_CIPHER)* EVP_des_ede3_cfb1();
727 const(EVP_CIPHER)* EVP_des_ede3_cfb8();
728 const(EVP_CIPHER)* EVP_des_ofb();
729 const(EVP_CIPHER)* EVP_des_ede_ofb();
730 const(EVP_CIPHER)* EVP_des_ede3_ofb();
731 const(EVP_CIPHER)* EVP_des_cbc();
732 const(EVP_CIPHER)* EVP_des_ede_cbc();
733 const(EVP_CIPHER)* EVP_des_ede3_cbc();
734 const(EVP_CIPHER)* EVP_desx_cbc();
735 /* This should now be supported through the dev_crypto ENGINE. But also, why are
736  * rc4 and md5 declarations made here inside a "NO_DES" precompiler branch? */
737 //#if 0
738 //# ifdef OPENSSL_OPENBSD_DEV_CRYPTO
739 //const(EVP_CIPHER)* EVP_dev_crypto_des_ede3_cbc();
740 //const(EVP_CIPHER)* EVP_dev_crypto_rc4();
741 //const(EVP_MD)* EVP_dev_crypto_md5();
742 //# endif
743 //#endif
744 }
745 version(OPENSSL_NO_RC4) {} else {
746 const(EVP_CIPHER)* EVP_rc4();
747 const(EVP_CIPHER)* EVP_rc4_40();
748 version(OPENSSL_NO_MD5) {} else {
749 const(EVP_CIPHER)* EVP_rc4_hmac_md5();
750 }
751 }
752 version(OPENSSL_NO_IDEA) {} else {
753 const(EVP_CIPHER)* EVP_idea_ecb();
754 const(EVP_CIPHER)* EVP_idea_cfb64();
755 alias EVP_idea_cfb64 EVP_idea_cfb;
756 const(EVP_CIPHER)* EVP_idea_ofb();
757 const(EVP_CIPHER)* EVP_idea_cbc();
758 }
759 version(OPENSSL_NO_RC2) {} else {
760 const(EVP_CIPHER)* EVP_rc2_ecb();
761 const(EVP_CIPHER)* EVP_rc2_cbc();
762 const(EVP_CIPHER)* EVP_rc2_40_cbc();
763 const(EVP_CIPHER)* EVP_rc2_64_cbc();
764 const(EVP_CIPHER)* EVP_rc2_cfb64();
765 alias EVP_rc2_cfb64 EVP_rc2_cfb;
766 const(EVP_CIPHER)* EVP_rc2_ofb();
767 }
768 version(OPENSSL_NO_BF) {} else {
769 const(EVP_CIPHER)* EVP_bf_ecb();
770 const(EVP_CIPHER)* EVP_bf_cbc();
771 const(EVP_CIPHER)* EVP_bf_cfb64();
772 alias EVP_bf_cfb64 EVP_bf_cfb;
773 const(EVP_CIPHER)* EVP_bf_ofb();
774 }
775 version(OPENSSL_NO_CAST) {} else {
776 const(EVP_CIPHER)* EVP_cast5_ecb();
777 const(EVP_CIPHER)* EVP_cast5_cbc();
778 const(EVP_CIPHER)* EVP_cast5_cfb64();
779 alias EVP_cast5_cfb64 EVP_cast5_cfb;
780 const(EVP_CIPHER)* EVP_cast5_ofb();
781 }
782 version(OPENSSL_NO_RC5) {} else {
783 const(EVP_CIPHER)* EVP_rc5_32_12_16_cbc();
784 const(EVP_CIPHER)* EVP_rc5_32_12_16_ecb();
785 const(EVP_CIPHER)* EVP_rc5_32_12_16_cfb64();
786 alias EVP_rc5_32_12_16_cfb64 EVP_rc5_32_12_16_cfb;
787 const(EVP_CIPHER)* EVP_rc5_32_12_16_ofb();
788 }
789 version(OPENSSL_NO_AES) {} else {
790 const(EVP_CIPHER)* EVP_aes_128_ecb();
791 const(EVP_CIPHER)* EVP_aes_128_cbc();
792 const(EVP_CIPHER)* EVP_aes_128_cfb1();
793 const(EVP_CIPHER)* EVP_aes_128_cfb8();
794 const(EVP_CIPHER)* EVP_aes_128_cfb128();
795 alias EVP_aes_128_cfb128 EVP_aes_128_cfb;
796 const(EVP_CIPHER)* EVP_aes_128_ofb();
797 const(EVP_CIPHER)* EVP_aes_128_ctr();
798 const(EVP_CIPHER)* EVP_aes_128_ccm();
799 const(EVP_CIPHER)* EVP_aes_128_gcm();
800 const(EVP_CIPHER)* EVP_aes_128_xts();
801 const(EVP_CIPHER)* EVP_aes_192_ecb();
802 const(EVP_CIPHER)* EVP_aes_192_cbc();
803 const(EVP_CIPHER)* EVP_aes_192_cfb1();
804 const(EVP_CIPHER)* EVP_aes_192_cfb8();
805 const(EVP_CIPHER)* EVP_aes_192_cfb128();
806 alias EVP_aes_192_cfb128 EVP_aes_192_cfb;
807 const(EVP_CIPHER)* EVP_aes_192_ofb();
808 const(EVP_CIPHER)* EVP_aes_192_ctr();
809 const(EVP_CIPHER)* EVP_aes_192_ccm();
810 const(EVP_CIPHER)* EVP_aes_192_gcm();
811 const(EVP_CIPHER)* EVP_aes_256_ecb();
812 const(EVP_CIPHER)* EVP_aes_256_cbc();
813 const(EVP_CIPHER)* EVP_aes_256_cfb1();
814 const(EVP_CIPHER)* EVP_aes_256_cfb8();
815 const(EVP_CIPHER)* EVP_aes_256_cfb128();
816 alias EVP_aes_256_cfb128 EVP_aes_256_cfb;
817 const(EVP_CIPHER)* EVP_aes_256_ofb();
818 const(EVP_CIPHER)* EVP_aes_256_ctr();
819 const(EVP_CIPHER)* EVP_aes_256_ccm();
820 const(EVP_CIPHER)* EVP_aes_256_gcm();
821 const(EVP_CIPHER)* EVP_aes_256_xts();
822 version(OPENSSL_NO_SHA) {} else version(OPENSSL_NO_SHA1) {} else {
823 const(EVP_CIPHER)* EVP_aes_128_cbc_hmac_sha1();
824 const(EVP_CIPHER)* EVP_aes_256_cbc_hmac_sha1();
825 }
826 }
827 version(OPENSSL_NO_CAMELLIA) {} else {
828 const(EVP_CIPHER)* EVP_camellia_128_ecb();
829 const(EVP_CIPHER)* EVP_camellia_128_cbc();
830 const(EVP_CIPHER)* EVP_camellia_128_cfb1();
831 const(EVP_CIPHER)* EVP_camellia_128_cfb8();
832 const(EVP_CIPHER)* EVP_camellia_128_cfb128();
833 alias EVP_camellia_128_cfb128 EVP_camellia_128_cfb;
834 const(EVP_CIPHER)* EVP_camellia_128_ofb();
835 const(EVP_CIPHER)* EVP_camellia_192_ecb();
836 const(EVP_CIPHER)* EVP_camellia_192_cbc();
837 const(EVP_CIPHER)* EVP_camellia_192_cfb1();
838 const(EVP_CIPHER)* EVP_camellia_192_cfb8();
839 const(EVP_CIPHER)* EVP_camellia_192_cfb128();
840 alias EVP_camellia_192_cfb128 EVP_camellia_192_cfb;
841 const(EVP_CIPHER)* EVP_camellia_192_ofb();
842 const(EVP_CIPHER)* EVP_camellia_256_ecb();
843 const(EVP_CIPHER)* EVP_camellia_256_cbc();
844 const(EVP_CIPHER)* EVP_camellia_256_cfb1();
845 const(EVP_CIPHER)* EVP_camellia_256_cfb8();
846 const(EVP_CIPHER)* EVP_camellia_256_cfb128();
847 alias EVP_camellia_256_cfb128 EVP_camellia_256_cfb;
848 const(EVP_CIPHER)* EVP_camellia_256_ofb();
849 }
850 
851 version(OPENSSL_NO_SEED) {} else {
852 const(EVP_CIPHER)* EVP_seed_ecb();
853 const(EVP_CIPHER)* EVP_seed_cbc();
854 const(EVP_CIPHER)* EVP_seed_cfb128();
855 alias EVP_seed_cfb128 EVP_seed_cfb;
856 const(EVP_CIPHER)* EVP_seed_ofb();
857 }
858 
859 void OPENSSL_add_all_algorithms_noconf();
860 void OPENSSL_add_all_algorithms_conf();
861 
862 version (OPENSSL_LOAD_CONF) {
863 alias OPENSSL_add_all_algorithms_conf OpenSSL_add_all_algorithms;
864 } else {
865 alias OPENSSL_add_all_algorithms_noconf OpenSSL_add_all_algorithms;
866 }
867 
868 void OpenSSL_add_all_ciphers();
869 void OpenSSL_add_all_digests();
870 alias OpenSSL_add_all_algorithms SSLeay_add_all_algorithms;
871 alias OpenSSL_add_all_ciphers SSLeay_add_all_ciphers;
872 alias OpenSSL_add_all_digests SSLeay_add_all_digests;
873 
874 int EVP_add_cipher(const(EVP_CIPHER)* cipher);
875 int EVP_add_digest(const(EVP_MD)* digest);
876 
877 const(EVP_CIPHER)* EVP_get_cipherbyname(const(char)* name);
878 const(EVP_MD)* EVP_get_digestbyname(const(char)* name);
879 void EVP_cleanup();
880 
881 void EVP_CIPHER_do_all(ExternC!(void function(const(EVP_CIPHER)* ciph,
882 		const(char)* from, const(char)* to, void* x)) fn, void* arg);
883 void EVP_CIPHER_do_all_sorted(ExternC!(void function(const(EVP_CIPHER)* ciph,
884 		const(char)* from, const(char)* to, void* x)) fn, void* arg);
885 
886 void EVP_MD_do_all(ExternC!(void function(const(EVP_MD)* ciph,
887 		const(char)* from, const(char)* to, void* x)) fn, void* arg);
888 void EVP_MD_do_all_sorted(ExternC!(void function(const(EVP_MD)* ciph,
889 		const(char)* from, const(char)* to, void* x)) fn, void* arg);
890 
891 int		EVP_PKEY_decrypt_old(ubyte* dec_key,
892 			const(ubyte)* enc_key,int enc_key_len,
893 			EVP_PKEY* private_key);
894 int		EVP_PKEY_encrypt_old(ubyte* enc_key,
895 			const(ubyte)* key,int key_len,
896 			EVP_PKEY* pub_key);
897 int		EVP_PKEY_type(int type);
898 int		EVP_PKEY_id(const(EVP_PKEY)* pkey);
899 int		EVP_PKEY_base_id(const(EVP_PKEY)* pkey);
900 int		EVP_PKEY_bits(EVP_PKEY* pkey);
901 int		EVP_PKEY_size(EVP_PKEY* pkey);
902 int 		EVP_PKEY_set_type(EVP_PKEY* pkey,int type);
903 int		EVP_PKEY_set_type_str(EVP_PKEY* pkey, const(char)* str, int len);
904 int 		EVP_PKEY_assign(EVP_PKEY* pkey,int type,void* key);
905 void* 		EVP_PKEY_get0(EVP_PKEY* pkey);
906 
907 version(OPENSSL_NO_RSA) {} else {
908 import deimos.openssl.rsa; /*struct rsa_st;*/
909 int EVP_PKEY_set1_RSA(EVP_PKEY* pkey,rsa_st* key);
910 rsa_st* EVP_PKEY_get1_RSA(EVP_PKEY* pkey);
911 }
912 version(OPENSSL_NO_DSA) {} else {
913 import deimos.openssl.dsa; /*struct dsa_st;*/
914 int EVP_PKEY_set1_DSA(EVP_PKEY* pkey,dsa_st* key);
915 dsa_st* EVP_PKEY_get1_DSA(EVP_PKEY* pkey);
916 }
917 version(OPENSSL_NO_DH) {} else {
918 import deimos.openssl.dh; /*struct dh_st;*/
919 int EVP_PKEY_set1_DH(EVP_PKEY* pkey,dh_st* key);
920 dh_st* EVP_PKEY_get1_DH(EVP_PKEY* pkey);
921 }
922 version(OPENSSL_NO_EC) {} else {
923 struct ec_key_st;
924 int EVP_PKEY_set1_EC_KEY(EVP_PKEY* pkey,ec_key_st* key);
925 ec_key_st* EVP_PKEY_get1_EC_KEY(EVP_PKEY* pkey);
926 }
927 
928 EVP_PKEY* 	EVP_PKEY_new();
929 void		EVP_PKEY_free(EVP_PKEY* pkey);
930 
931 EVP_PKEY* 	d2i_PublicKey(int type,EVP_PKEY** a, const(ubyte)** pp,
932 			c_long length);
933 int		i2d_PublicKey(EVP_PKEY* a, ubyte** pp);
934 
935 EVP_PKEY* 	d2i_PrivateKey(int type,EVP_PKEY** a, const(ubyte)** pp,
936 			c_long length);
937 EVP_PKEY* 	d2i_AutoPrivateKey(EVP_PKEY** a, const(ubyte)** pp,
938 			c_long length);
939 int		i2d_PrivateKey(EVP_PKEY* a, ubyte** pp);
940 
941 int EVP_PKEY_copy_parameters(EVP_PKEY* to, const(EVP_PKEY)* from);
942 int EVP_PKEY_missing_parameters(const(EVP_PKEY)* pkey);
943 int EVP_PKEY_save_parameters(EVP_PKEY* pkey,int mode);
944 int EVP_PKEY_cmp_parameters(const(EVP_PKEY)* a, const(EVP_PKEY)* b);
945 
946 int EVP_PKEY_cmp(const(EVP_PKEY)* a, const(EVP_PKEY)* b);
947 
948 int EVP_PKEY_print_public(BIO* out_, const(EVP_PKEY)* pkey,
949 				int indent, ASN1_PCTX* pctx);
950 int EVP_PKEY_print_private(BIO* out_, const(EVP_PKEY)* pkey,
951 				int indent, ASN1_PCTX* pctx);
952 int EVP_PKEY_print_params(BIO* out_, const(EVP_PKEY)* pkey,
953 				int indent, ASN1_PCTX* pctx);
954 
955 int EVP_PKEY_get_default_digest_nid(EVP_PKEY* pkey, int* pnid);
956 
957 int EVP_CIPHER_type(const(EVP_CIPHER)* ctx);
958 
959 /* calls methods */
960 int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX* c, ASN1_TYPE* type);
961 int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX* c, ASN1_TYPE* type);
962 
963 /* These are used by EVP_CIPHER methods */
964 int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX* c,ASN1_TYPE* type);
965 int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX* c,ASN1_TYPE* type);
966 
967 /* PKCS5 password based encryption */
968 int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX* ctx, const(char)* pass, int passlen,
969 			 ASN1_TYPE* param, const(EVP_CIPHER)* cipher, const(EVP_MD)* md,
970 			 int en_de);
971 int PKCS5_PBKDF2_HMAC_SHA1(const(char)* pass, int passlen,
972 			   const(ubyte)* salt, int saltlen, int iter,
973 			   int keylen, ubyte* out_);
974 int PKCS5_PBKDF2_HMAC(const(char)* pass, int passlen,
975 			   const(ubyte)* salt, int saltlen, int iter,
976 			   const(EVP_MD)* digest,
977 		      int keylen, ubyte* out_);
978 int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX* ctx, const(char)* pass, int passlen,
979 			 ASN1_TYPE* param, const(EVP_CIPHER)* cipher, const(EVP_MD)* md,
980 			 int en_de);
981 
982 void PKCS5_PBE_add();
983 
984 int EVP_PBE_CipherInit (ASN1_OBJECT* pbe_obj, const(char)* pass, int passlen,
985 	     ASN1_TYPE* param, EVP_CIPHER_CTX* ctx, int en_de);
986 
987 /* PBE type */
988 
989 /* Can appear as the outermost AlgorithmIdentifier */
990 enum EVP_PBE_TYPE_OUTER = 0x0;
991 /* Is an PRF type OID */
992 enum EVP_PBE_TYPE_PRF = 0x1;
993 
994 int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid, int md_nid,
995 	     EVP_PBE_KEYGEN* keygen);
996 int EVP_PBE_alg_add(int nid, const(EVP_CIPHER)* cipher, const(EVP_MD)* md,
997 		    EVP_PBE_KEYGEN* keygen);
998 int EVP_PBE_find(int type, int pbe_nid,
999 			int* pcnid, int* pmnid, EVP_PBE_KEYGEN** pkeygen);
1000 void EVP_PBE_cleanup();
1001 
1002 enum ASN1_PKEY_ALIAS = 0x1;
1003 enum ASN1_PKEY_DYNAMIC = 0x2;
1004 enum ASN1_PKEY_SIGPARAM_NULL = 0x4;
1005 
1006 enum ASN1_PKEY_CTRL_PKCS7_SIGN = 0x1;
1007 enum ASN1_PKEY_CTRL_PKCS7_ENCRYPT = 0x2;
1008 enum ASN1_PKEY_CTRL_DEFAULT_MD_NID = 0x3;
1009 enum ASN1_PKEY_CTRL_CMS_SIGN = 0x5;
1010 enum ASN1_PKEY_CTRL_CMS_ENVELOPE = 0x7;
1011 
1012 int EVP_PKEY_asn1_get_count();
1013 const(EVP_PKEY_ASN1_METHOD)* EVP_PKEY_asn1_get0(int idx);
1014 const(EVP_PKEY_ASN1_METHOD)* EVP_PKEY_asn1_find(ENGINE** pe, int type);
1015 const(EVP_PKEY_ASN1_METHOD)* EVP_PKEY_asn1_find_str(ENGINE** pe,
1016 					const(char)* str, int len);
1017 int EVP_PKEY_asn1_add0(const(EVP_PKEY_ASN1_METHOD)* ameth);
1018 int EVP_PKEY_asn1_add_alias(int to, int from);
1019 int EVP_PKEY_asn1_get0_info(int* ppkey_id, int* pkey_base_id, int* ppkey_flags,
1020 				const(char)** pinfo, const(char)** ppem_str,
1021 					const(EVP_PKEY_ASN1_METHOD)* ameth);
1022 
1023 const(EVP_PKEY_ASN1_METHOD)* EVP_PKEY_get0_asn1(EVP_PKEY* pkey);
1024 EVP_PKEY_ASN1_METHOD* EVP_PKEY_asn1_new(int id, int flags,
1025 					const(char)* pem_str, const(char)* info);
1026 void EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD* dst,
1027 			const(EVP_PKEY_ASN1_METHOD)* src);
1028 void EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD* ameth);
1029 void EVP_PKEY_asn1_set_public(EVP_PKEY_ASN1_METHOD* ameth,
1030 		ExternC!(int function(EVP_PKEY* pk, X509_PUBKEY* pub)) pub_decode,
1031 		ExternC!(int function(X509_PUBKEY* pub, const(EVP_PKEY)* pk)) pub_encode,
1032 		ExternC!(int function(const(EVP_PKEY)* a, const(EVP_PKEY)* b)) pub_cmp,
1033 		ExternC!(int function(BIO* out_, const(EVP_PKEY)* pkey, int indent,
1034 							ASN1_PCTX* pctx)) pub_print,
1035 		ExternC!(int function(const(EVP_PKEY)* pk)) pkey_size,
1036 		ExternC!(int function(const(EVP_PKEY)* pk)) pkey_bits);
1037 void EVP_PKEY_asn1_set_private(EVP_PKEY_ASN1_METHOD* ameth,
1038 		ExternC!(int function(EVP_PKEY* pk, PKCS8_PRIV_KEY_INFO* p8inf)) priv_decode,
1039 		ExternC!(int function(PKCS8_PRIV_KEY_INFO* p8, const(EVP_PKEY)* pk)) priv_encode,
1040 		ExternC!(int function(BIO* out_, const(EVP_PKEY)* pkey, int indent,
1041 							ASN1_PCTX* pctx)) priv_print);
1042 void EVP_PKEY_asn1_set_param(EVP_PKEY_ASN1_METHOD* ameth,
1043 		ExternC!(int function(EVP_PKEY* pkey,
1044 				const(ubyte)** pder, int derlen)) param_decode,
1045 		ExternC!(int function(const(EVP_PKEY)* pkey, ubyte** pder)) param_encode,
1046 		ExternC!(int function(const(EVP_PKEY)* pk)) param_missing,
1047 		ExternC!(int function(EVP_PKEY* to, const(EVP_PKEY)* from)) param_copy,
1048 		ExternC!(int function(const(EVP_PKEY)* a, const(EVP_PKEY)* b)) param_cmp,
1049 		ExternC!(int function(BIO* out_, const(EVP_PKEY)* pkey, int indent,
1050 							ASN1_PCTX* pctx)) param_print);
1051 
1052 void EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD* ameth,
1053 		ExternC!(void function(EVP_PKEY* pkey)) pkey_free);
1054 void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD* ameth,
1055 		ExternC!(int function(EVP_PKEY* pkey, int op,
1056 							c_long arg1, void* arg2)) pkey_ctrl);
1057 
1058 
1059 enum EVP_PKEY_OP_UNDEFINED = 0;
1060 enum EVP_PKEY_OP_PARAMGEN = (1<<1);
1061 enum EVP_PKEY_OP_KEYGEN = (1<<2);
1062 enum EVP_PKEY_OP_SIGN = (1<<3);
1063 enum EVP_PKEY_OP_VERIFY = (1<<4);
1064 enum EVP_PKEY_OP_VERIFYRECOVER = (1<<5);
1065 enum EVP_PKEY_OP_SIGNCTX = (1<<6);
1066 enum EVP_PKEY_OP_VERIFYCTX = (1<<7);
1067 enum EVP_PKEY_OP_ENCRYPT = (1<<8);
1068 enum EVP_PKEY_OP_DECRYPT = (1<<9);
1069 enum EVP_PKEY_OP_DERIVE = (1<<10);
1070 
1071 enum EVP_PKEY_OP_TYPE_SIG =
1072 	(EVP_PKEY_OP_SIGN | EVP_PKEY_OP_VERIFY | EVP_PKEY_OP_VERIFYRECOVER
1073 		| EVP_PKEY_OP_SIGNCTX | EVP_PKEY_OP_VERIFYCTX);
1074 
1075 enum EVP_PKEY_OP_TYPE_CRYPT =
1076 	(EVP_PKEY_OP_ENCRYPT | EVP_PKEY_OP_DECRYPT);
1077 
1078 /+ BUG in original headers: EVP_PKEY_OP_SIG, EVP_PKEY_OP_CRYPT are not defined.
1079 enum EVP_PKEY_OP_TYPE_NOGEN =
1080 	(EVP_PKEY_OP_SIG | EVP_PKEY_OP_CRYPT | EVP_PKEY_OP_DERIVE);
1081 +/
1082 
1083 enum EVP_PKEY_OP_TYPE_GEN =
1084 		(EVP_PKEY_OP_PARAMGEN | EVP_PKEY_OP_KEYGEN);
1085 
1086 auto EVP_PKEY_CTX_set_signature_md()(EVP_PKEY_CTX* ctx, void* md) {
1087 	return EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG,
1088 				EVP_PKEY_CTRL_MD, 0, md);
1089 }
1090 
1091 enum EVP_PKEY_CTRL_MD = 1;
1092 enum EVP_PKEY_CTRL_PEER_KEY = 2;
1093 
1094 enum EVP_PKEY_CTRL_PKCS7_ENCRYPT = 3;
1095 enum EVP_PKEY_CTRL_PKCS7_DECRYPT = 4;
1096 
1097 enum EVP_PKEY_CTRL_PKCS7_SIGN = 5;
1098 
1099 enum EVP_PKEY_CTRL_SET_MAC_KEY = 6;
1100 
1101 enum EVP_PKEY_CTRL_DIGESTINIT = 7;
1102 
1103 /* Used by GOST key encryption in TLS */
1104 enum EVP_PKEY_CTRL_SET_IV = 8;
1105 
1106 enum EVP_PKEY_CTRL_CMS_ENCRYPT = 9;
1107 enum EVP_PKEY_CTRL_CMS_DECRYPT = 10;
1108 enum EVP_PKEY_CTRL_CMS_SIGN = 11;
1109 
1110 enum EVP_PKEY_CTRL_CIPHER = 12;
1111 
1112 enum EVP_PKEY_ALG_CTRL = 0x1000;
1113 
1114 
1115 enum EVP_PKEY_FLAG_AUTOARGLEN = 2;
1116 /* Method handles all operations: don't assume any digest related
1117  * defaults.
1118  */
1119 enum EVP_PKEY_FLAG_SIGCTX_CUSTOM = 4;
1120 
1121 const(EVP_PKEY_METHOD)* EVP_PKEY_meth_find(int type);
1122 EVP_PKEY_METHOD* EVP_PKEY_meth_new(int id, int flags);
1123 void EVP_PKEY_meth_get0_info(int* ppkey_id, int* pflags,
1124 				const(EVP_PKEY_METHOD)* meth);
1125 void EVP_PKEY_meth_copy(EVP_PKEY_METHOD* dst, const(EVP_PKEY_METHOD)* src);
1126 void EVP_PKEY_meth_free(EVP_PKEY_METHOD* pmeth);
1127 int EVP_PKEY_meth_add0(const(EVP_PKEY_METHOD)* pmeth);
1128 
1129 EVP_PKEY_CTX* EVP_PKEY_CTX_new(EVP_PKEY* pkey, ENGINE* e);
1130 EVP_PKEY_CTX* EVP_PKEY_CTX_new_id(int id, ENGINE* e);
1131 EVP_PKEY_CTX* EVP_PKEY_CTX_dup(EVP_PKEY_CTX* ctx);
1132 void EVP_PKEY_CTX_free(EVP_PKEY_CTX* ctx);
1133 
1134 int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX* ctx, int keytype, int optype,
1135 				int cmd, int p1, void* p2);
1136 int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX* ctx, const(char)* type,
1137 						const(char)* value);
1138 
1139 int EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX* ctx);
1140 void EVP_PKEY_CTX_set0_keygen_info(EVP_PKEY_CTX* ctx, int* dat, int datlen);
1141 
1142 EVP_PKEY* EVP_PKEY_new_mac_key(int type, ENGINE* e,
1143 				const(ubyte)* key, int keylen);
1144 
1145 void EVP_PKEY_CTX_set_data(EVP_PKEY_CTX* ctx, void* data);
1146 void* EVP_PKEY_CTX_get_data(EVP_PKEY_CTX* ctx);
1147 EVP_PKEY* EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX* ctx);
1148 
1149 EVP_PKEY* EVP_PKEY_CTX_get0_peerkey(EVP_PKEY_CTX* ctx);
1150 
1151 void EVP_PKEY_CTX_set_app_data(EVP_PKEY_CTX* ctx, void* data);
1152 void* EVP_PKEY_CTX_get_app_data(EVP_PKEY_CTX* ctx);
1153 
1154 int EVP_PKEY_sign_init(EVP_PKEY_CTX* ctx);
1155 int EVP_PKEY_sign(EVP_PKEY_CTX* ctx,
1156 			ubyte* sig, size_t* siglen,
1157 			const(ubyte)* tbs, size_t tbslen);
1158 int EVP_PKEY_verify_init(EVP_PKEY_CTX* ctx);
1159 int EVP_PKEY_verify(EVP_PKEY_CTX* ctx,
1160 			const(ubyte)* sig, size_t siglen,
1161 			const(ubyte)* tbs, size_t tbslen);
1162 int EVP_PKEY_verify_recover_init(EVP_PKEY_CTX* ctx);
1163 int EVP_PKEY_verify_recover(EVP_PKEY_CTX* ctx,
1164 			ubyte* rout, size_t* routlen,
1165 			const(ubyte)* sig, size_t siglen);
1166 int EVP_PKEY_encrypt_init(EVP_PKEY_CTX* ctx);
1167 int EVP_PKEY_encrypt(EVP_PKEY_CTX* ctx,
1168 			ubyte* out_, size_t* outlen,
1169 			const(ubyte)* in_, size_t inlen);
1170 int EVP_PKEY_decrypt_init(EVP_PKEY_CTX* ctx);
1171 int EVP_PKEY_decrypt(EVP_PKEY_CTX* ctx,
1172 			ubyte* out_, size_t* outlen,
1173 			const(ubyte)* in_, size_t inlen);
1174 
1175 int EVP_PKEY_derive_init(EVP_PKEY_CTX* ctx);
1176 int EVP_PKEY_derive_set_peer(EVP_PKEY_CTX* ctx, EVP_PKEY* peer);
1177 int EVP_PKEY_derive(EVP_PKEY_CTX* ctx, ubyte* key, size_t* keylen);
1178 
1179 alias typeof(*(ExternC!(int function(EVP_PKEY_CTX* ctx))).init) EVP_PKEY_gen_cb;
1180 
1181 int EVP_PKEY_paramgen_init(EVP_PKEY_CTX* ctx);
1182 int EVP_PKEY_paramgen(EVP_PKEY_CTX* ctx, EVP_PKEY** ppkey);
1183 int EVP_PKEY_keygen_init(EVP_PKEY_CTX* ctx);
1184 int EVP_PKEY_keygen(EVP_PKEY_CTX* ctx, EVP_PKEY** ppkey);
1185 
1186 void EVP_PKEY_CTX_set_cb(EVP_PKEY_CTX* ctx, EVP_PKEY_gen_cb* cb);
1187 EVP_PKEY_gen_cb* EVP_PKEY_CTX_get_cb(EVP_PKEY_CTX* ctx);
1188 
1189 int EVP_PKEY_CTX_get_keygen_info(EVP_PKEY_CTX* ctx, int idx);
1190 
1191 void EVP_PKEY_meth_set_init(EVP_PKEY_METHOD* pmeth,
1192 	ExternC!(int function(EVP_PKEY_CTX* ctx)) init);
1193 
1194 void EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD* pmeth,
1195 	ExternC!(int function(EVP_PKEY_CTX* dst, EVP_PKEY_CTX* src)) copy);
1196 
1197 void EVP_PKEY_meth_set_cleanup(EVP_PKEY_METHOD* pmeth,
1198 	ExternC!(void function(EVP_PKEY_CTX* ctx)) cleanup);
1199 
1200 void EVP_PKEY_meth_set_paramgen(EVP_PKEY_METHOD* pmeth,
1201 	ExternC!(int function(EVP_PKEY_CTX* ctx)) paramgen_init,
1202 	ExternC!(int function(EVP_PKEY_CTX* ctx, EVP_PKEY* pkey)) paramgen);
1203 
1204 void EVP_PKEY_meth_set_keygen(EVP_PKEY_METHOD* pmeth,
1205 	ExternC!(int function(EVP_PKEY_CTX* ctx)) keygen_init,
1206 	ExternC!(int function(EVP_PKEY_CTX* ctx, EVP_PKEY* pkey)) keygen);
1207 
1208 void EVP_PKEY_meth_set_sign(EVP_PKEY_METHOD* pmeth,
1209 	ExternC!(int function(EVP_PKEY_CTX* ctx)) sign_init,
1210 	ExternC!(int function(EVP_PKEY_CTX* ctx, ubyte* sig, size_t* siglen,
1211 					const(ubyte)* tbs, size_t tbslen)) sign);
1212 
1213 void EVP_PKEY_meth_set_verify(EVP_PKEY_METHOD* pmeth,
1214 	ExternC!(int function(EVP_PKEY_CTX* ctx)) verify_init,
1215 	ExternC!(int function(EVP_PKEY_CTX* ctx, const(ubyte)* sig, size_t siglen,
1216 					const(ubyte)* tbs, size_t tbslen)) verify);
1217 
1218 void EVP_PKEY_meth_set_verify_recover(EVP_PKEY_METHOD* pmeth,
1219 	ExternC!(int function(EVP_PKEY_CTX* ctx)) verify_recover_init,
1220 	ExternC!(int function(EVP_PKEY_CTX* ctx,
1221 					ubyte* sig, size_t* siglen,
1222 					const(ubyte)* tbs, size_t tbslen)) verify_recover);
1223 
1224 void EVP_PKEY_meth_set_signctx(EVP_PKEY_METHOD* pmeth,
1225 	ExternC!(int function(EVP_PKEY_CTX* ctx, EVP_MD_CTX* mctx)) signctx_init,
1226 	ExternC!(int function(EVP_PKEY_CTX* ctx, ubyte* sig, size_t* siglen,
1227 					EVP_MD_CTX* mctx)) signctx);
1228 
1229 void EVP_PKEY_meth_set_verifyctx(EVP_PKEY_METHOD* pmeth,
1230 	ExternC!(int function(EVP_PKEY_CTX* ctx, EVP_MD_CTX* mctx)) verifyctx_init,
1231 	ExternC!(int function(EVP_PKEY_CTX* ctx, const(ubyte)* sig,int siglen,
1232 					EVP_MD_CTX* mctx)) verifyctx);
1233 
1234 void EVP_PKEY_meth_set_encrypt(EVP_PKEY_METHOD* pmeth,
1235 	ExternC!(int function(EVP_PKEY_CTX* ctx)) encrypt_init,
1236 	ExternC!(int function(EVP_PKEY_CTX* ctx, ubyte* out_, size_t* outlen,
1237 					const(ubyte)* in_, size_t inlen)) encryptfn);
1238 
1239 void EVP_PKEY_meth_set_decrypt(EVP_PKEY_METHOD* pmeth,
1240 	ExternC!(int function(EVP_PKEY_CTX* ctx)) decrypt_init,
1241 	ExternC!(int function(EVP_PKEY_CTX* ctx, ubyte* out_, size_t* outlen,
1242 					const(ubyte)* in_, size_t inlen)) decrypt);
1243 
1244 void EVP_PKEY_meth_set_derive(EVP_PKEY_METHOD* pmeth,
1245 	ExternC!(int function(EVP_PKEY_CTX* ctx)) derive_init,
1246 	ExternC!(int function(EVP_PKEY_CTX* ctx, ubyte* key, size_t* keylen)) derive);
1247 
1248 void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD* pmeth,
1249 	ExternC!(int function(EVP_PKEY_CTX* ctx, int type, int p1, void* p2)) ctrl,
1250 	ExternC!(int function(EVP_PKEY_CTX* ctx,
1251 					const(char)* type, const(char)* value)) ctrl_str);
1252 
1253 void EVP_add_alg_module();
1254 
1255 /* BEGIN ERROR CODES */
1256 /* The following lines are auto generated by the script mkerr.pl. Any changes
1257  * made after this point may be overwritten when the script is next run.
1258  */
1259 void ERR_load_EVP_strings();
1260 
1261 /* Error codes for the EVP functions. */
1262 
1263 /* Function codes. */
1264 enum EVP_F_AESNI_INIT_KEY = 165;
1265 enum EVP_F_AESNI_XTS_CIPHER = 176;
1266 enum EVP_F_AES_INIT_KEY = 133;
1267 enum EVP_F_AES_XTS = 172;
1268 enum EVP_F_AES_XTS_CIPHER = 175;
1269 enum EVP_F_ALG_MODULE_INIT = 177;
1270 enum EVP_F_CAMELLIA_INIT_KEY = 159;
1271 enum EVP_F_CMAC_INIT = 173;
1272 enum EVP_F_D2I_PKEY = 100;
1273 enum EVP_F_DO_SIGVER_INIT = 161;
1274 enum EVP_F_DSAPKEY2PKCS8 = 134;
1275 enum EVP_F_DSA_PKEY2PKCS8 = 135;
1276 enum EVP_F_ECDSA_PKEY2PKCS8 = 129;
1277 enum EVP_F_ECKEY_PKEY2PKCS8 = 132;
1278 enum EVP_F_EVP_CIPHERINIT_EX = 123;
1279 enum EVP_F_EVP_CIPHER_CTX_COPY = 163;
1280 enum EVP_F_EVP_CIPHER_CTX_CTRL = 124;
1281 enum EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH = 122;
1282 enum EVP_F_EVP_DECRYPTFINAL_EX = 101;
1283 enum EVP_F_EVP_DIGESTINIT_EX = 128;
1284 enum EVP_F_EVP_ENCRYPTFINAL_EX = 127;
1285 enum EVP_F_EVP_MD_CTX_COPY_EX = 110;
1286 enum EVP_F_EVP_MD_SIZE = 162;
1287 enum EVP_F_EVP_OPENINIT = 102;
1288 enum EVP_F_EVP_PBE_ALG_ADD = 115;
1289 enum EVP_F_EVP_PBE_ALG_ADD_TYPE = 160;
1290 enum EVP_F_EVP_PBE_CIPHERINIT = 116;
1291 enum EVP_F_EVP_PKCS82PKEY = 111;
1292 enum EVP_F_EVP_PKCS82PKEY_BROKEN = 136;
1293 enum EVP_F_EVP_PKEY2PKCS8_BROKEN = 113;
1294 enum EVP_F_EVP_PKEY_COPY_PARAMETERS = 103;
1295 enum EVP_F_EVP_PKEY_CTX_CTRL = 137;
1296 enum EVP_F_EVP_PKEY_CTX_CTRL_STR = 150;
1297 enum EVP_F_EVP_PKEY_CTX_DUP = 156;
1298 enum EVP_F_EVP_PKEY_DECRYPT = 104;
1299 enum EVP_F_EVP_PKEY_DECRYPT_INIT = 138;
1300 enum EVP_F_EVP_PKEY_DECRYPT_OLD = 151;
1301 enum EVP_F_EVP_PKEY_DERIVE = 153;
1302 enum EVP_F_EVP_PKEY_DERIVE_INIT = 154;
1303 enum EVP_F_EVP_PKEY_DERIVE_SET_PEER = 155;
1304 enum EVP_F_EVP_PKEY_ENCRYPT = 105;
1305 enum EVP_F_EVP_PKEY_ENCRYPT_INIT = 139;
1306 enum EVP_F_EVP_PKEY_ENCRYPT_OLD = 152;
1307 enum EVP_F_EVP_PKEY_GET1_DH = 119;
1308 enum EVP_F_EVP_PKEY_GET1_DSA = 120;
1309 enum EVP_F_EVP_PKEY_GET1_ECDSA = 130;
1310 enum EVP_F_EVP_PKEY_GET1_EC_KEY = 131;
1311 enum EVP_F_EVP_PKEY_GET1_RSA = 121;
1312 enum EVP_F_EVP_PKEY_KEYGEN = 146;
1313 enum EVP_F_EVP_PKEY_KEYGEN_INIT = 147;
1314 enum EVP_F_EVP_PKEY_NEW = 106;
1315 enum EVP_F_EVP_PKEY_PARAMGEN = 148;
1316 enum EVP_F_EVP_PKEY_PARAMGEN_INIT = 149;
1317 enum EVP_F_EVP_PKEY_SIGN = 140;
1318 enum EVP_F_EVP_PKEY_SIGN_INIT = 141;
1319 enum EVP_F_EVP_PKEY_VERIFY = 142;
1320 enum EVP_F_EVP_PKEY_VERIFY_INIT = 143;
1321 enum EVP_F_EVP_PKEY_VERIFY_RECOVER = 144;
1322 enum EVP_F_EVP_PKEY_VERIFY_RECOVER_INIT = 145;
1323 enum EVP_F_EVP_RIJNDAEL = 126;
1324 enum EVP_F_EVP_SIGNFINAL = 107;
1325 enum EVP_F_EVP_VERIFYFINAL = 108;
1326 enum EVP_F_FIPS_CIPHERINIT = 166;
1327 enum EVP_F_FIPS_CIPHER_CTX_COPY = 170;
1328 enum EVP_F_FIPS_CIPHER_CTX_CTRL = 167;
1329 enum EVP_F_FIPS_CIPHER_CTX_SET_KEY_LENGTH = 171;
1330 enum EVP_F_FIPS_DIGESTINIT = 168;
1331 enum EVP_F_FIPS_MD_CTX_COPY = 169;
1332 enum EVP_F_HMAC_INIT_EX = 174;
1333 enum EVP_F_INT_CTX_NEW = 157;
1334 enum EVP_F_PKCS5_PBE_KEYIVGEN = 117;
1335 enum EVP_F_PKCS5_V2_PBE_KEYIVGEN = 118;
1336 enum EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN = 164;
1337 enum EVP_F_PKCS8_SET_BROKEN = 112;
1338 enum EVP_F_PKEY_SET_TYPE = 158;
1339 enum EVP_F_RC2_MAGIC_TO_METH = 109;
1340 enum EVP_F_RC5_CTRL = 125;
1341 
1342 /* Reason codes. */
1343 enum EVP_R_AES_IV_SETUP_FAILED = 162;
1344 enum EVP_R_AES_KEY_SETUP_FAILED = 143;
1345 enum EVP_R_ASN1_LIB = 140;
1346 enum EVP_R_BAD_BLOCK_LENGTH = 136;
1347 enum EVP_R_BAD_DECRYPT = 100;
1348 enum EVP_R_BAD_KEY_LENGTH = 137;
1349 enum EVP_R_BN_DECODE_ERROR = 112;
1350 enum EVP_R_BN_PUBKEY_ERROR = 113;
1351 enum EVP_R_BUFFER_TOO_SMALL = 155;
1352 enum EVP_R_CAMELLIA_KEY_SETUP_FAILED = 157;
1353 enum EVP_R_CIPHER_PARAMETER_ERROR = 122;
1354 enum EVP_R_COMMAND_NOT_SUPPORTED = 147;
1355 enum EVP_R_CTRL_NOT_IMPLEMENTED = 132;
1356 enum EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED = 133;
1357 enum EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH = 138;
1358 enum EVP_R_DECODE_ERROR = 114;
1359 enum EVP_R_DIFFERENT_KEY_TYPES = 101;
1360 enum EVP_R_DIFFERENT_PARAMETERS = 153;
1361 enum EVP_R_DISABLED_FOR_FIPS = 163;
1362 enum EVP_R_ENCODE_ERROR = 115;
1363 enum EVP_R_ERROR_LOADING_SECTION = 165;
1364 enum EVP_R_ERROR_SETTING_FIPS_MODE = 166;
1365 enum EVP_R_EVP_PBE_CIPHERINIT_ERROR = 119;
1366 enum EVP_R_EXPECTING_AN_RSA_KEY = 127;
1367 enum EVP_R_EXPECTING_A_DH_KEY = 128;
1368 enum EVP_R_EXPECTING_A_DSA_KEY = 129;
1369 enum EVP_R_EXPECTING_A_ECDSA_KEY = 141;
1370 enum EVP_R_EXPECTING_A_EC_KEY = 142;
1371 enum EVP_R_FIPS_MODE_NOT_SUPPORTED = 167;
1372 enum EVP_R_INITIALIZATION_ERROR = 134;
1373 enum EVP_R_INPUT_NOT_INITIALIZED = 111;
1374 enum EVP_R_INVALID_DIGEST = 152;
1375 enum EVP_R_INVALID_FIPS_MODE = 168;
1376 enum EVP_R_INVALID_KEY_LENGTH = 130;
1377 enum EVP_R_INVALID_OPERATION = 148;
1378 enum EVP_R_IV_TOO_LARGE = 102;
1379 enum EVP_R_KEYGEN_FAILURE = 120;
1380 enum EVP_R_MESSAGE_DIGEST_IS_NULL = 159;
1381 enum EVP_R_METHOD_NOT_SUPPORTED = 144;
1382 enum EVP_R_MISSING_PARAMETERS = 103;
1383 enum EVP_R_NO_CIPHER_SET = 131;
1384 enum EVP_R_NO_DEFAULT_DIGEST = 158;
1385 enum EVP_R_NO_DIGEST_SET = 139;
1386 enum EVP_R_NO_DSA_PARAMETERS = 116;
1387 enum EVP_R_NO_KEY_SET = 154;
1388 enum EVP_R_NO_OPERATION_SET = 149;
1389 enum EVP_R_NO_SIGN_FUNCTION_CONFIGURED = 104;
1390 enum EVP_R_NO_VERIFY_FUNCTION_CONFIGURED = 105;
1391 enum EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE = 150;
1392 enum EVP_R_OPERATON_NOT_INITIALIZED = 151;
1393 enum EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE = 117;
1394 enum EVP_R_PRIVATE_KEY_DECODE_ERROR = 145;
1395 enum EVP_R_PRIVATE_KEY_ENCODE_ERROR = 146;
1396 enum EVP_R_PUBLIC_KEY_NOT_RSA = 106;
1397 enum EVP_R_TOO_LARGE = 164;
1398 enum EVP_R_UNKNOWN_CIPHER = 160;
1399 enum EVP_R_UNKNOWN_DIGEST = 161;
1400 enum EVP_R_UNKNOWN_OPTION = 169;
1401 enum EVP_R_UNKNOWN_PBE_ALGORITHM = 121;
1402 enum EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS = 135;
1403 enum EVP_R_UNSUPPORTED_ALGORITHM = 156;
1404 enum EVP_R_UNSUPPORTED_CIPHER = 107;
1405 enum EVP_R_UNSUPPORTED_KEYLENGTH = 123;
1406 enum EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION = 124;
1407 enum EVP_R_UNSUPPORTED_KEY_SIZE = 108;
1408 enum EVP_R_UNSUPPORTED_PRF = 125;
1409 enum EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM = 118;
1410 enum EVP_R_UNSUPPORTED_SALT_TYPE = 126;
1411 enum EVP_R_WRONG_FINAL_BLOCK_LENGTH = 109;
1412 enum EVP_R_WRONG_PUBLIC_KEY_TYPE = 110;