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 EVP_MD_CTX* EVP_MD_CTX_create(); 555 void EVP_MD_CTX_destroy(EVP_MD_CTX* ctx); 556 int EVP_MD_CTX_copy_ex(EVP_MD_CTX* out_,const(EVP_MD_CTX)* in_); 557 void EVP_MD_CTX_set_flags(EVP_MD_CTX* ctx, int flags); 558 void EVP_MD_CTX_clear_flags(EVP_MD_CTX* ctx, int flags); 559 int EVP_MD_CTX_test_flags(const(EVP_MD_CTX)* ctx,int flags); 560 int EVP_DigestInit_ex(EVP_MD_CTX* ctx, const(EVP_MD)* type, ENGINE* impl); 561 int EVP_DigestUpdate(EVP_MD_CTX* ctx,const(void)* d, 562 size_t cnt); 563 int EVP_DigestFinal_ex(EVP_MD_CTX* ctx,ubyte* md,uint* s); 564 int EVP_Digest(const(void)* data, size_t count, 565 ubyte* md, uint* size, const(EVP_MD)* type, ENGINE* impl); 566 567 int EVP_MD_CTX_copy(EVP_MD_CTX* out_,const(EVP_MD_CTX)* in_); 568 int EVP_DigestInit(EVP_MD_CTX* ctx, const(EVP_MD)* type); 569 int EVP_DigestFinal(EVP_MD_CTX* ctx,ubyte* md,uint* s); 570 571 int EVP_read_pw_string(char* buf,int length,const(char)* prompt,int verify); 572 int EVP_read_pw_string_min(char* buf,int minlen,int maxlen,const(char)* prompt,int verify); 573 void EVP_set_pw_prompt(const(char)* prompt); 574 char* EVP_get_pw_prompt(); 575 576 int EVP_BytesToKey(const(EVP_CIPHER)* type,const(EVP_MD)* md, 577 const(ubyte)* salt, const(ubyte)* data, 578 int datal, int count, ubyte* key,ubyte* iv); 579 580 void EVP_CIPHER_CTX_set_flags(EVP_CIPHER_CTX* ctx, int flags); 581 void EVP_CIPHER_CTX_clear_flags(EVP_CIPHER_CTX* ctx, int flags); 582 int EVP_CIPHER_CTX_test_flags(const(EVP_CIPHER_CTX)* ctx,int flags); 583 584 int EVP_EncryptInit(EVP_CIPHER_CTX* ctx,const(EVP_CIPHER)* cipher, 585 const(ubyte)* key, const(ubyte)* iv); 586 int EVP_EncryptInit_ex(EVP_CIPHER_CTX* ctx,const(EVP_CIPHER)* cipher, ENGINE* impl, 587 const(ubyte)* key, const(ubyte)* iv); 588 int EVP_EncryptUpdate(EVP_CIPHER_CTX* ctx, ubyte* out_, 589 int* outl, const(ubyte)* in_, int inl); 590 int EVP_EncryptFinal_ex(EVP_CIPHER_CTX* ctx, ubyte* out_, int* outl); 591 int EVP_EncryptFinal(EVP_CIPHER_CTX* ctx, ubyte* out_, int* outl); 592 593 int EVP_DecryptInit(EVP_CIPHER_CTX* ctx,const(EVP_CIPHER)* cipher, 594 const(ubyte)* key, const(ubyte)* iv); 595 int EVP_DecryptInit_ex(EVP_CIPHER_CTX* ctx,const(EVP_CIPHER)* cipher, ENGINE* impl, 596 const(ubyte)* key, const(ubyte)* iv); 597 int EVP_DecryptUpdate(EVP_CIPHER_CTX* ctx, ubyte* out_, 598 int* outl, const(ubyte)* in_, int inl); 599 int EVP_DecryptFinal(EVP_CIPHER_CTX* ctx, ubyte* outm, int* outl); 600 int EVP_DecryptFinal_ex(EVP_CIPHER_CTX* ctx, ubyte* outm, int* outl); 601 602 int EVP_CipherInit(EVP_CIPHER_CTX* ctx,const(EVP_CIPHER)* cipher, 603 const(ubyte)* key,const(ubyte)* iv, 604 int enc); 605 int EVP_CipherInit_ex(EVP_CIPHER_CTX* ctx,const(EVP_CIPHER)* cipher, ENGINE* impl, 606 const(ubyte)* key,const(ubyte)* iv, 607 int enc); 608 int EVP_CipherUpdate(EVP_CIPHER_CTX* ctx, ubyte* out_, 609 int* outl, const(ubyte)* in_, int inl); 610 int EVP_CipherFinal(EVP_CIPHER_CTX* ctx, ubyte* outm, int* outl); 611 int EVP_CipherFinal_ex(EVP_CIPHER_CTX* ctx, ubyte* outm, int* outl); 612 613 int EVP_SignFinal(EVP_MD_CTX* ctx,ubyte* md,uint* s, 614 EVP_PKEY* pkey); 615 616 int EVP_VerifyFinal(EVP_MD_CTX* ctx,const(ubyte)* sigbuf, 617 uint siglen,EVP_PKEY* pkey); 618 619 int EVP_DigestSignInit(EVP_MD_CTX* ctx, EVP_PKEY_CTX** pctx, 620 const(EVP_MD)* type, ENGINE* e, EVP_PKEY* pkey); 621 int EVP_DigestSignFinal(EVP_MD_CTX* ctx, 622 ubyte* sigret, size_t* siglen); 623 624 int EVP_DigestVerifyInit(EVP_MD_CTX* ctx, EVP_PKEY_CTX** pctx, 625 const(EVP_MD)* type, ENGINE* e, EVP_PKEY* pkey); 626 int EVP_DigestVerifyFinal(EVP_MD_CTX* ctx, 627 ubyte* sig, size_t siglen); 628 629 int EVP_OpenInit(EVP_CIPHER_CTX* ctx,const(EVP_CIPHER)* type, 630 const(ubyte)* ek, int ekl, const(ubyte)* iv, 631 EVP_PKEY* priv); 632 int EVP_OpenFinal(EVP_CIPHER_CTX* ctx, ubyte* out_, int* outl); 633 634 int EVP_SealInit(EVP_CIPHER_CTX* ctx, const(EVP_CIPHER)* type, 635 ubyte** ek, int* ekl, ubyte* iv, 636 EVP_PKEY** pubk, int npubk); 637 int EVP_SealFinal(EVP_CIPHER_CTX* ctx,ubyte* out_,int* outl); 638 639 void EVP_EncodeInit(EVP_ENCODE_CTX* ctx); 640 void EVP_EncodeUpdate(EVP_ENCODE_CTX* ctx,ubyte* out_,int* outl, 641 const(ubyte)* in_,int inl); 642 void EVP_EncodeFinal(EVP_ENCODE_CTX* ctx,ubyte* out_,int* outl); 643 int EVP_EncodeBlock(ubyte* t, const(ubyte)* f, int n); 644 645 void EVP_DecodeInit(EVP_ENCODE_CTX* ctx); 646 int EVP_DecodeUpdate(EVP_ENCODE_CTX* ctx,ubyte* out_,int* outl, 647 const(ubyte)* in_, int inl); 648 int EVP_DecodeFinal(EVP_ENCODE_CTX* ctx, ubyte* out_, int* outl); 649 int EVP_DecodeBlock(ubyte* t, const(ubyte)* f, int n); 650 651 void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX* a); 652 int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX* a); 653 EVP_CIPHER_CTX* EVP_CIPHER_CTX_new(); 654 void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX* a); 655 int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX* x, int keylen); 656 int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX* c, int pad); 657 int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX* ctx, int type, int arg, void* ptr); 658 int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX* ctx, ubyte* key); 659 660 version(OPENSSL_NO_BIO) {} else { 661 BIO_METHOD* BIO_f_md(); 662 BIO_METHOD* BIO_f_base64(); 663 BIO_METHOD* BIO_f_cipher(); 664 BIO_METHOD* BIO_f_reliable(); 665 void BIO_set_cipher(BIO* b,const(EVP_CIPHER)* c,const(ubyte)* k, 666 const(ubyte)* i, int enc); 667 } 668 669 const(EVP_MD)* EVP_md_null(); 670 version(OPENSSL_NO_MD2) {} else { 671 const(EVP_MD)* EVP_md2(); 672 } 673 version(OPENSSL_NO_MD4) {} else { 674 const(EVP_MD)* EVP_md4(); 675 } 676 version(OPENSSL_NO_MD5) {} else { 677 const(EVP_MD)* EVP_md5(); 678 } 679 version(OPENSSL_NO_SHA) {} else { 680 const(EVP_MD)* EVP_sha(); 681 const(EVP_MD)* EVP_sha1(); 682 const(EVP_MD)* EVP_dss(); 683 const(EVP_MD)* EVP_dss1(); 684 const(EVP_MD)* EVP_ecdsa(); 685 } 686 version(OPENSSL_NO_SHA256) {} else { 687 const(EVP_MD)* EVP_sha224(); 688 const(EVP_MD)* EVP_sha256(); 689 } 690 version(OPENSSL_NO_SHA512) {} else { 691 const(EVP_MD)* EVP_sha384(); 692 const(EVP_MD)* EVP_sha512(); 693 } 694 version(OPENSSL_NO_MDC2) {} else { 695 const(EVP_MD)* EVP_mdc2(); 696 } 697 version(OPENSSL_NO_RIPEMD) {} else { 698 const(EVP_MD)* EVP_ripemd160(); 699 } 700 version(OPENSSL_NO_WHIRLPOOL) {} else { 701 const(EVP_MD)* EVP_whirlpool(); 702 } 703 const(EVP_CIPHER)* EVP_enc_null(); /* does nothing :-) */ 704 version (OPENSSL_NO_DES) {} else { 705 const(EVP_CIPHER)* EVP_des_ecb(); 706 const(EVP_CIPHER)* EVP_des_ede(); 707 const(EVP_CIPHER)* EVP_des_ede3(); 708 const(EVP_CIPHER)* EVP_des_ede_ecb(); 709 const(EVP_CIPHER)* EVP_des_ede3_ecb(); 710 const(EVP_CIPHER)* EVP_des_cfb64(); 711 alias EVP_des_cfb64 EVP_des_cfb; 712 const(EVP_CIPHER)* EVP_des_cfb1(); 713 const(EVP_CIPHER)* EVP_des_cfb8(); 714 const(EVP_CIPHER)* EVP_des_ede_cfb64(); 715 alias EVP_des_ede_cfb64 EVP_des_ede_cfb; 716 version (none) { 717 const(EVP_CIPHER)* EVP_des_ede_cfb1(); 718 const(EVP_CIPHER)* EVP_des_ede_cfb8(); 719 } 720 const(EVP_CIPHER)* EVP_des_ede3_cfb64(); 721 alias EVP_des_ede3_cfb64 EVP_des_ede3_cfb; 722 const(EVP_CIPHER)* EVP_des_ede3_cfb1(); 723 const(EVP_CIPHER)* EVP_des_ede3_cfb8(); 724 const(EVP_CIPHER)* EVP_des_ofb(); 725 const(EVP_CIPHER)* EVP_des_ede_ofb(); 726 const(EVP_CIPHER)* EVP_des_ede3_ofb(); 727 const(EVP_CIPHER)* EVP_des_cbc(); 728 const(EVP_CIPHER)* EVP_des_ede_cbc(); 729 const(EVP_CIPHER)* EVP_des_ede3_cbc(); 730 const(EVP_CIPHER)* EVP_desx_cbc(); 731 /* This should now be supported through the dev_crypto ENGINE. But also, why are 732 * rc4 and md5 declarations made here inside a "NO_DES" precompiler branch? */ 733 //#if 0 734 //# ifdef OPENSSL_OPENBSD_DEV_CRYPTO 735 //const(EVP_CIPHER)* EVP_dev_crypto_des_ede3_cbc(); 736 //const(EVP_CIPHER)* EVP_dev_crypto_rc4(); 737 //const(EVP_MD)* EVP_dev_crypto_md5(); 738 //# endif 739 //#endif 740 } 741 version(OPENSSL_NO_RC4) {} else { 742 const(EVP_CIPHER)* EVP_rc4(); 743 const(EVP_CIPHER)* EVP_rc4_40(); 744 version(OPENSSL_NO_MD5) {} else { 745 const(EVP_CIPHER)* EVP_rc4_hmac_md5(); 746 } 747 } 748 version(OPENSSL_NO_IDEA) {} else { 749 const(EVP_CIPHER)* EVP_idea_ecb(); 750 const(EVP_CIPHER)* EVP_idea_cfb64(); 751 alias EVP_idea_cfb64 EVP_idea_cfb; 752 const(EVP_CIPHER)* EVP_idea_ofb(); 753 const(EVP_CIPHER)* EVP_idea_cbc(); 754 } 755 version(OPENSSL_NO_RC2) {} else { 756 const(EVP_CIPHER)* EVP_rc2_ecb(); 757 const(EVP_CIPHER)* EVP_rc2_cbc(); 758 const(EVP_CIPHER)* EVP_rc2_40_cbc(); 759 const(EVP_CIPHER)* EVP_rc2_64_cbc(); 760 const(EVP_CIPHER)* EVP_rc2_cfb64(); 761 alias EVP_rc2_cfb64 EVP_rc2_cfb; 762 const(EVP_CIPHER)* EVP_rc2_ofb(); 763 } 764 version(OPENSSL_NO_BF) {} else { 765 const(EVP_CIPHER)* EVP_bf_ecb(); 766 const(EVP_CIPHER)* EVP_bf_cbc(); 767 const(EVP_CIPHER)* EVP_bf_cfb64(); 768 alias EVP_bf_cfb64 EVP_bf_cfb; 769 const(EVP_CIPHER)* EVP_bf_ofb(); 770 } 771 version(OPENSSL_NO_CAST) {} else { 772 const(EVP_CIPHER)* EVP_cast5_ecb(); 773 const(EVP_CIPHER)* EVP_cast5_cbc(); 774 const(EVP_CIPHER)* EVP_cast5_cfb64(); 775 alias EVP_cast5_cfb64 EVP_cast5_cfb; 776 const(EVP_CIPHER)* EVP_cast5_ofb(); 777 } 778 version(OPENSSL_NO_RC5) {} else { 779 const(EVP_CIPHER)* EVP_rc5_32_12_16_cbc(); 780 const(EVP_CIPHER)* EVP_rc5_32_12_16_ecb(); 781 const(EVP_CIPHER)* EVP_rc5_32_12_16_cfb64(); 782 alias EVP_rc5_32_12_16_cfb64 EVP_rc5_32_12_16_cfb; 783 const(EVP_CIPHER)* EVP_rc5_32_12_16_ofb(); 784 } 785 version(OPENSSL_NO_AES) {} else { 786 const(EVP_CIPHER)* EVP_aes_128_ecb(); 787 const(EVP_CIPHER)* EVP_aes_128_cbc(); 788 const(EVP_CIPHER)* EVP_aes_128_cfb1(); 789 const(EVP_CIPHER)* EVP_aes_128_cfb8(); 790 const(EVP_CIPHER)* EVP_aes_128_cfb128(); 791 alias EVP_aes_128_cfb128 EVP_aes_128_cfb; 792 const(EVP_CIPHER)* EVP_aes_128_ofb(); 793 const(EVP_CIPHER)* EVP_aes_128_ctr(); 794 const(EVP_CIPHER)* EVP_aes_128_ccm(); 795 const(EVP_CIPHER)* EVP_aes_128_gcm(); 796 const(EVP_CIPHER)* EVP_aes_128_xts(); 797 const(EVP_CIPHER)* EVP_aes_192_ecb(); 798 const(EVP_CIPHER)* EVP_aes_192_cbc(); 799 const(EVP_CIPHER)* EVP_aes_192_cfb1(); 800 const(EVP_CIPHER)* EVP_aes_192_cfb8(); 801 const(EVP_CIPHER)* EVP_aes_192_cfb128(); 802 alias EVP_aes_192_cfb128 EVP_aes_192_cfb; 803 const(EVP_CIPHER)* EVP_aes_192_ofb(); 804 const(EVP_CIPHER)* EVP_aes_192_ctr(); 805 const(EVP_CIPHER)* EVP_aes_192_ccm(); 806 const(EVP_CIPHER)* EVP_aes_192_gcm(); 807 const(EVP_CIPHER)* EVP_aes_256_ecb(); 808 const(EVP_CIPHER)* EVP_aes_256_cbc(); 809 const(EVP_CIPHER)* EVP_aes_256_cfb1(); 810 const(EVP_CIPHER)* EVP_aes_256_cfb8(); 811 const(EVP_CIPHER)* EVP_aes_256_cfb128(); 812 alias EVP_aes_256_cfb128 EVP_aes_256_cfb; 813 const(EVP_CIPHER)* EVP_aes_256_ofb(); 814 const(EVP_CIPHER)* EVP_aes_256_ctr(); 815 const(EVP_CIPHER)* EVP_aes_256_ccm(); 816 const(EVP_CIPHER)* EVP_aes_256_gcm(); 817 const(EVP_CIPHER)* EVP_aes_256_xts(); 818 version(OPENSSL_NO_SHA) {} else version(OPENSSL_NO_SHA1) {} else { 819 const(EVP_CIPHER)* EVP_aes_128_cbc_hmac_sha1(); 820 const(EVP_CIPHER)* EVP_aes_256_cbc_hmac_sha1(); 821 } 822 } 823 version(OPENSSL_NO_CAMELLIA) {} else { 824 const(EVP_CIPHER)* EVP_camellia_128_ecb(); 825 const(EVP_CIPHER)* EVP_camellia_128_cbc(); 826 const(EVP_CIPHER)* EVP_camellia_128_cfb1(); 827 const(EVP_CIPHER)* EVP_camellia_128_cfb8(); 828 const(EVP_CIPHER)* EVP_camellia_128_cfb128(); 829 alias EVP_camellia_128_cfb128 EVP_camellia_128_cfb; 830 const(EVP_CIPHER)* EVP_camellia_128_ofb(); 831 const(EVP_CIPHER)* EVP_camellia_192_ecb(); 832 const(EVP_CIPHER)* EVP_camellia_192_cbc(); 833 const(EVP_CIPHER)* EVP_camellia_192_cfb1(); 834 const(EVP_CIPHER)* EVP_camellia_192_cfb8(); 835 const(EVP_CIPHER)* EVP_camellia_192_cfb128(); 836 alias EVP_camellia_192_cfb128 EVP_camellia_192_cfb; 837 const(EVP_CIPHER)* EVP_camellia_192_ofb(); 838 const(EVP_CIPHER)* EVP_camellia_256_ecb(); 839 const(EVP_CIPHER)* EVP_camellia_256_cbc(); 840 const(EVP_CIPHER)* EVP_camellia_256_cfb1(); 841 const(EVP_CIPHER)* EVP_camellia_256_cfb8(); 842 const(EVP_CIPHER)* EVP_camellia_256_cfb128(); 843 alias EVP_camellia_256_cfb128 EVP_camellia_256_cfb; 844 const(EVP_CIPHER)* EVP_camellia_256_ofb(); 845 } 846 847 version(OPENSSL_NO_SEED) {} else { 848 const(EVP_CIPHER)* EVP_seed_ecb(); 849 const(EVP_CIPHER)* EVP_seed_cbc(); 850 const(EVP_CIPHER)* EVP_seed_cfb128(); 851 alias EVP_seed_cfb128 EVP_seed_cfb; 852 const(EVP_CIPHER)* EVP_seed_ofb(); 853 } 854 855 void OPENSSL_add_all_algorithms_noconf(); 856 void OPENSSL_add_all_algorithms_conf(); 857 858 version (OPENSSL_LOAD_CONF) { 859 alias OPENSSL_add_all_algorithms_conf OpenSSL_add_all_algorithms; 860 } else { 861 alias OPENSSL_add_all_algorithms_noconf OpenSSL_add_all_algorithms; 862 } 863 864 void OpenSSL_add_all_ciphers(); 865 void OpenSSL_add_all_digests(); 866 alias OpenSSL_add_all_algorithms SSLeay_add_all_algorithms; 867 alias OpenSSL_add_all_ciphers SSLeay_add_all_ciphers; 868 alias OpenSSL_add_all_digests SSLeay_add_all_digests; 869 870 int EVP_add_cipher(const(EVP_CIPHER)* cipher); 871 int EVP_add_digest(const(EVP_MD)* digest); 872 873 const(EVP_CIPHER)* EVP_get_cipherbyname(const(char)* name); 874 const(EVP_MD)* EVP_get_digestbyname(const(char)* name); 875 void EVP_cleanup(); 876 877 void EVP_CIPHER_do_all(ExternC!(void function(const(EVP_CIPHER)* ciph, 878 const(char)* from, const(char)* to, void* x)) fn, void* arg); 879 void EVP_CIPHER_do_all_sorted(ExternC!(void function(const(EVP_CIPHER)* ciph, 880 const(char)* from, const(char)* to, void* x)) fn, void* arg); 881 882 void EVP_MD_do_all(ExternC!(void function(const(EVP_MD)* ciph, 883 const(char)* from, const(char)* to, void* x)) fn, void* arg); 884 void EVP_MD_do_all_sorted(ExternC!(void function(const(EVP_MD)* ciph, 885 const(char)* from, const(char)* to, void* x)) fn, void* arg); 886 887 int EVP_PKEY_decrypt_old(ubyte* dec_key, 888 const(ubyte)* enc_key,int enc_key_len, 889 EVP_PKEY* private_key); 890 int EVP_PKEY_encrypt_old(ubyte* enc_key, 891 const(ubyte)* key,int key_len, 892 EVP_PKEY* pub_key); 893 int EVP_PKEY_type(int type); 894 int EVP_PKEY_id(const(EVP_PKEY)* pkey); 895 int EVP_PKEY_base_id(const(EVP_PKEY)* pkey); 896 int EVP_PKEY_bits(EVP_PKEY* pkey); 897 int EVP_PKEY_size(EVP_PKEY* pkey); 898 int EVP_PKEY_set_type(EVP_PKEY* pkey,int type); 899 int EVP_PKEY_set_type_str(EVP_PKEY* pkey, const(char)* str, int len); 900 int EVP_PKEY_assign(EVP_PKEY* pkey,int type,void* key); 901 void* EVP_PKEY_get0(EVP_PKEY* pkey); 902 903 version(OPENSSL_NO_RSA) {} else { 904 import deimos.openssl.rsa; /*struct rsa_st;*/ 905 int EVP_PKEY_set1_RSA(EVP_PKEY* pkey,rsa_st* key); 906 rsa_st* EVP_PKEY_get1_RSA(EVP_PKEY* pkey); 907 } 908 version(OPENSSL_NO_DSA) {} else { 909 import deimos.openssl.dsa; /*struct dsa_st;*/ 910 int EVP_PKEY_set1_DSA(EVP_PKEY* pkey,dsa_st* key); 911 dsa_st* EVP_PKEY_get1_DSA(EVP_PKEY* pkey); 912 } 913 version(OPENSSL_NO_DH) {} else { 914 import deimos.openssl.dh; /*struct dh_st;*/ 915 int EVP_PKEY_set1_DH(EVP_PKEY* pkey,dh_st* key); 916 dh_st* EVP_PKEY_get1_DH(EVP_PKEY* pkey); 917 } 918 version(OPENSSL_NO_EC) {} else { 919 struct ec_key_st; 920 int EVP_PKEY_set1_EC_KEY(EVP_PKEY* pkey,ec_key_st* key); 921 ec_key_st* EVP_PKEY_get1_EC_KEY(EVP_PKEY* pkey); 922 } 923 924 EVP_PKEY* EVP_PKEY_new(); 925 void EVP_PKEY_free(EVP_PKEY* pkey); 926 927 EVP_PKEY* d2i_PublicKey(int type,EVP_PKEY** a, const(ubyte)** pp, 928 c_long length); 929 int i2d_PublicKey(EVP_PKEY* a, ubyte** pp); 930 931 EVP_PKEY* d2i_PrivateKey(int type,EVP_PKEY** a, const(ubyte)** pp, 932 c_long length); 933 EVP_PKEY* d2i_AutoPrivateKey(EVP_PKEY** a, const(ubyte)** pp, 934 c_long length); 935 int i2d_PrivateKey(EVP_PKEY* a, ubyte** pp); 936 937 int EVP_PKEY_copy_parameters(EVP_PKEY* to, const(EVP_PKEY)* from); 938 int EVP_PKEY_missing_parameters(const(EVP_PKEY)* pkey); 939 int EVP_PKEY_save_parameters(EVP_PKEY* pkey,int mode); 940 int EVP_PKEY_cmp_parameters(const(EVP_PKEY)* a, const(EVP_PKEY)* b); 941 942 int EVP_PKEY_cmp(const(EVP_PKEY)* a, const(EVP_PKEY)* b); 943 944 int EVP_PKEY_print_public(BIO* out_, const(EVP_PKEY)* pkey, 945 int indent, ASN1_PCTX* pctx); 946 int EVP_PKEY_print_private(BIO* out_, const(EVP_PKEY)* pkey, 947 int indent, ASN1_PCTX* pctx); 948 int EVP_PKEY_print_params(BIO* out_, const(EVP_PKEY)* pkey, 949 int indent, ASN1_PCTX* pctx); 950 951 int EVP_PKEY_get_default_digest_nid(EVP_PKEY* pkey, int* pnid); 952 953 int EVP_CIPHER_type(const(EVP_CIPHER)* ctx); 954 955 /* calls methods */ 956 int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX* c, ASN1_TYPE* type); 957 int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX* c, ASN1_TYPE* type); 958 959 /* These are used by EVP_CIPHER methods */ 960 int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX* c,ASN1_TYPE* type); 961 int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX* c,ASN1_TYPE* type); 962 963 /* PKCS5 password based encryption */ 964 int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX* ctx, const(char)* pass, int passlen, 965 ASN1_TYPE* param, const(EVP_CIPHER)* cipher, const(EVP_MD)* md, 966 int en_de); 967 int PKCS5_PBKDF2_HMAC_SHA1(const(char)* pass, int passlen, 968 const(ubyte)* salt, int saltlen, int iter, 969 int keylen, ubyte* out_); 970 int PKCS5_PBKDF2_HMAC(const(char)* pass, int passlen, 971 const(ubyte)* salt, int saltlen, int iter, 972 const(EVP_MD)* digest, 973 int keylen, ubyte* out_); 974 int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX* ctx, const(char)* pass, int passlen, 975 ASN1_TYPE* param, const(EVP_CIPHER)* cipher, const(EVP_MD)* md, 976 int en_de); 977 978 void PKCS5_PBE_add(); 979 980 int EVP_PBE_CipherInit (ASN1_OBJECT* pbe_obj, const(char)* pass, int passlen, 981 ASN1_TYPE* param, EVP_CIPHER_CTX* ctx, int en_de); 982 983 /* PBE type */ 984 985 /* Can appear as the outermost AlgorithmIdentifier */ 986 enum EVP_PBE_TYPE_OUTER = 0x0; 987 /* Is an PRF type OID */ 988 enum EVP_PBE_TYPE_PRF = 0x1; 989 990 int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid, int md_nid, 991 EVP_PBE_KEYGEN* keygen); 992 int EVP_PBE_alg_add(int nid, const(EVP_CIPHER)* cipher, const(EVP_MD)* md, 993 EVP_PBE_KEYGEN* keygen); 994 int EVP_PBE_find(int type, int pbe_nid, 995 int* pcnid, int* pmnid, EVP_PBE_KEYGEN** pkeygen); 996 void EVP_PBE_cleanup(); 997 998 enum ASN1_PKEY_ALIAS = 0x1; 999 enum ASN1_PKEY_DYNAMIC = 0x2; 1000 enum ASN1_PKEY_SIGPARAM_NULL = 0x4; 1001 1002 enum ASN1_PKEY_CTRL_PKCS7_SIGN = 0x1; 1003 enum ASN1_PKEY_CTRL_PKCS7_ENCRYPT = 0x2; 1004 enum ASN1_PKEY_CTRL_DEFAULT_MD_NID = 0x3; 1005 enum ASN1_PKEY_CTRL_CMS_SIGN = 0x5; 1006 enum ASN1_PKEY_CTRL_CMS_ENVELOPE = 0x7; 1007 1008 int EVP_PKEY_asn1_get_count(); 1009 const(EVP_PKEY_ASN1_METHOD)* EVP_PKEY_asn1_get0(int idx); 1010 const(EVP_PKEY_ASN1_METHOD)* EVP_PKEY_asn1_find(ENGINE** pe, int type); 1011 const(EVP_PKEY_ASN1_METHOD)* EVP_PKEY_asn1_find_str(ENGINE** pe, 1012 const(char)* str, int len); 1013 int EVP_PKEY_asn1_add0(const(EVP_PKEY_ASN1_METHOD)* ameth); 1014 int EVP_PKEY_asn1_add_alias(int to, int from); 1015 int EVP_PKEY_asn1_get0_info(int* ppkey_id, int* pkey_base_id, int* ppkey_flags, 1016 const(char)** pinfo, const(char)** ppem_str, 1017 const(EVP_PKEY_ASN1_METHOD)* ameth); 1018 1019 const(EVP_PKEY_ASN1_METHOD)* EVP_PKEY_get0_asn1(EVP_PKEY* pkey); 1020 EVP_PKEY_ASN1_METHOD* EVP_PKEY_asn1_new(int id, int flags, 1021 const(char)* pem_str, const(char)* info); 1022 void EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD* dst, 1023 const(EVP_PKEY_ASN1_METHOD)* src); 1024 void EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD* ameth); 1025 void EVP_PKEY_asn1_set_public(EVP_PKEY_ASN1_METHOD* ameth, 1026 ExternC!(int function(EVP_PKEY* pk, X509_PUBKEY* pub)) pub_decode, 1027 ExternC!(int function(X509_PUBKEY* pub, const(EVP_PKEY)* pk)) pub_encode, 1028 ExternC!(int function(const(EVP_PKEY)* a, const(EVP_PKEY)* b)) pub_cmp, 1029 ExternC!(int function(BIO* out_, const(EVP_PKEY)* pkey, int indent, 1030 ASN1_PCTX* pctx)) pub_print, 1031 ExternC!(int function(const(EVP_PKEY)* pk)) pkey_size, 1032 ExternC!(int function(const(EVP_PKEY)* pk)) pkey_bits); 1033 void EVP_PKEY_asn1_set_private(EVP_PKEY_ASN1_METHOD* ameth, 1034 ExternC!(int function(EVP_PKEY* pk, PKCS8_PRIV_KEY_INFO* p8inf)) priv_decode, 1035 ExternC!(int function(PKCS8_PRIV_KEY_INFO* p8, const(EVP_PKEY)* pk)) priv_encode, 1036 ExternC!(int function(BIO* out_, const(EVP_PKEY)* pkey, int indent, 1037 ASN1_PCTX* pctx)) priv_print); 1038 void EVP_PKEY_asn1_set_param(EVP_PKEY_ASN1_METHOD* ameth, 1039 ExternC!(int function(EVP_PKEY* pkey, 1040 const(ubyte)** pder, int derlen)) param_decode, 1041 ExternC!(int function(const(EVP_PKEY)* pkey, ubyte** pder)) param_encode, 1042 ExternC!(int function(const(EVP_PKEY)* pk)) param_missing, 1043 ExternC!(int function(EVP_PKEY* to, const(EVP_PKEY)* from)) param_copy, 1044 ExternC!(int function(const(EVP_PKEY)* a, const(EVP_PKEY)* b)) param_cmp, 1045 ExternC!(int function(BIO* out_, const(EVP_PKEY)* pkey, int indent, 1046 ASN1_PCTX* pctx)) param_print); 1047 1048 void EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD* ameth, 1049 ExternC!(void function(EVP_PKEY* pkey)) pkey_free); 1050 void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD* ameth, 1051 ExternC!(int function(EVP_PKEY* pkey, int op, 1052 c_long arg1, void* arg2)) pkey_ctrl); 1053 1054 1055 enum EVP_PKEY_OP_UNDEFINED = 0; 1056 enum EVP_PKEY_OP_PARAMGEN = (1<<1); 1057 enum EVP_PKEY_OP_KEYGEN = (1<<2); 1058 enum EVP_PKEY_OP_SIGN = (1<<3); 1059 enum EVP_PKEY_OP_VERIFY = (1<<4); 1060 enum EVP_PKEY_OP_VERIFYRECOVER = (1<<5); 1061 enum EVP_PKEY_OP_SIGNCTX = (1<<6); 1062 enum EVP_PKEY_OP_VERIFYCTX = (1<<7); 1063 enum EVP_PKEY_OP_ENCRYPT = (1<<8); 1064 enum EVP_PKEY_OP_DECRYPT = (1<<9); 1065 enum EVP_PKEY_OP_DERIVE = (1<<10); 1066 1067 enum EVP_PKEY_OP_TYPE_SIG = 1068 (EVP_PKEY_OP_SIGN | EVP_PKEY_OP_VERIFY | EVP_PKEY_OP_VERIFYRECOVER 1069 | EVP_PKEY_OP_SIGNCTX | EVP_PKEY_OP_VERIFYCTX); 1070 1071 enum EVP_PKEY_OP_TYPE_CRYPT = 1072 (EVP_PKEY_OP_ENCRYPT | EVP_PKEY_OP_DECRYPT); 1073 1074 /+ BUG in original headers: EVP_PKEY_OP_SIG, EVP_PKEY_OP_CRYPT are not defined. 1075 enum EVP_PKEY_OP_TYPE_NOGEN = 1076 (EVP_PKEY_OP_SIG | EVP_PKEY_OP_CRYPT | EVP_PKEY_OP_DERIVE); 1077 +/ 1078 1079 enum EVP_PKEY_OP_TYPE_GEN = 1080 (EVP_PKEY_OP_PARAMGEN | EVP_PKEY_OP_KEYGEN); 1081 1082 auto EVP_PKEY_CTX_set_signature_md()(EVP_PKEY_CTX* ctx, void* md) { 1083 return EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG, 1084 EVP_PKEY_CTRL_MD, 0, md); 1085 } 1086 1087 enum EVP_PKEY_CTRL_MD = 1; 1088 enum EVP_PKEY_CTRL_PEER_KEY = 2; 1089 1090 enum EVP_PKEY_CTRL_PKCS7_ENCRYPT = 3; 1091 enum EVP_PKEY_CTRL_PKCS7_DECRYPT = 4; 1092 1093 enum EVP_PKEY_CTRL_PKCS7_SIGN = 5; 1094 1095 enum EVP_PKEY_CTRL_SET_MAC_KEY = 6; 1096 1097 enum EVP_PKEY_CTRL_DIGESTINIT = 7; 1098 1099 /* Used by GOST key encryption in TLS */ 1100 enum EVP_PKEY_CTRL_SET_IV = 8; 1101 1102 enum EVP_PKEY_CTRL_CMS_ENCRYPT = 9; 1103 enum EVP_PKEY_CTRL_CMS_DECRYPT = 10; 1104 enum EVP_PKEY_CTRL_CMS_SIGN = 11; 1105 1106 enum EVP_PKEY_CTRL_CIPHER = 12; 1107 1108 enum EVP_PKEY_ALG_CTRL = 0x1000; 1109 1110 1111 enum EVP_PKEY_FLAG_AUTOARGLEN = 2; 1112 /* Method handles all operations: don't assume any digest related 1113 * defaults. 1114 */ 1115 enum EVP_PKEY_FLAG_SIGCTX_CUSTOM = 4; 1116 1117 const(EVP_PKEY_METHOD)* EVP_PKEY_meth_find(int type); 1118 EVP_PKEY_METHOD* EVP_PKEY_meth_new(int id, int flags); 1119 void EVP_PKEY_meth_get0_info(int* ppkey_id, int* pflags, 1120 const(EVP_PKEY_METHOD)* meth); 1121 void EVP_PKEY_meth_copy(EVP_PKEY_METHOD* dst, const(EVP_PKEY_METHOD)* src); 1122 void EVP_PKEY_meth_free(EVP_PKEY_METHOD* pmeth); 1123 int EVP_PKEY_meth_add0(const(EVP_PKEY_METHOD)* pmeth); 1124 1125 EVP_PKEY_CTX* EVP_PKEY_CTX_new(EVP_PKEY* pkey, ENGINE* e); 1126 EVP_PKEY_CTX* EVP_PKEY_CTX_new_id(int id, ENGINE* e); 1127 EVP_PKEY_CTX* EVP_PKEY_CTX_dup(EVP_PKEY_CTX* ctx); 1128 void EVP_PKEY_CTX_free(EVP_PKEY_CTX* ctx); 1129 1130 int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX* ctx, int keytype, int optype, 1131 int cmd, int p1, void* p2); 1132 int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX* ctx, const(char)* type, 1133 const(char)* value); 1134 1135 int EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX* ctx); 1136 void EVP_PKEY_CTX_set0_keygen_info(EVP_PKEY_CTX* ctx, int* dat, int datlen); 1137 1138 EVP_PKEY* EVP_PKEY_new_mac_key(int type, ENGINE* e, 1139 const(ubyte)* key, int keylen); 1140 1141 void EVP_PKEY_CTX_set_data(EVP_PKEY_CTX* ctx, void* data); 1142 void* EVP_PKEY_CTX_get_data(EVP_PKEY_CTX* ctx); 1143 EVP_PKEY* EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX* ctx); 1144 1145 EVP_PKEY* EVP_PKEY_CTX_get0_peerkey(EVP_PKEY_CTX* ctx); 1146 1147 void EVP_PKEY_CTX_set_app_data(EVP_PKEY_CTX* ctx, void* data); 1148 void* EVP_PKEY_CTX_get_app_data(EVP_PKEY_CTX* ctx); 1149 1150 int EVP_PKEY_sign_init(EVP_PKEY_CTX* ctx); 1151 int EVP_PKEY_sign(EVP_PKEY_CTX* ctx, 1152 ubyte* sig, size_t* siglen, 1153 const(ubyte)* tbs, size_t tbslen); 1154 int EVP_PKEY_verify_init(EVP_PKEY_CTX* ctx); 1155 int EVP_PKEY_verify(EVP_PKEY_CTX* ctx, 1156 const(ubyte)* sig, size_t siglen, 1157 const(ubyte)* tbs, size_t tbslen); 1158 int EVP_PKEY_verify_recover_init(EVP_PKEY_CTX* ctx); 1159 int EVP_PKEY_verify_recover(EVP_PKEY_CTX* ctx, 1160 ubyte* rout, size_t* routlen, 1161 const(ubyte)* sig, size_t siglen); 1162 int EVP_PKEY_encrypt_init(EVP_PKEY_CTX* ctx); 1163 int EVP_PKEY_encrypt(EVP_PKEY_CTX* ctx, 1164 ubyte* out_, size_t* outlen, 1165 const(ubyte)* in_, size_t inlen); 1166 int EVP_PKEY_decrypt_init(EVP_PKEY_CTX* ctx); 1167 int EVP_PKEY_decrypt(EVP_PKEY_CTX* ctx, 1168 ubyte* out_, size_t* outlen, 1169 const(ubyte)* in_, size_t inlen); 1170 1171 int EVP_PKEY_derive_init(EVP_PKEY_CTX* ctx); 1172 int EVP_PKEY_derive_set_peer(EVP_PKEY_CTX* ctx, EVP_PKEY* peer); 1173 int EVP_PKEY_derive(EVP_PKEY_CTX* ctx, ubyte* key, size_t* keylen); 1174 1175 alias typeof(*(ExternC!(int function(EVP_PKEY_CTX* ctx))).init) EVP_PKEY_gen_cb; 1176 1177 int EVP_PKEY_paramgen_init(EVP_PKEY_CTX* ctx); 1178 int EVP_PKEY_paramgen(EVP_PKEY_CTX* ctx, EVP_PKEY** ppkey); 1179 int EVP_PKEY_keygen_init(EVP_PKEY_CTX* ctx); 1180 int EVP_PKEY_keygen(EVP_PKEY_CTX* ctx, EVP_PKEY** ppkey); 1181 1182 void EVP_PKEY_CTX_set_cb(EVP_PKEY_CTX* ctx, EVP_PKEY_gen_cb* cb); 1183 EVP_PKEY_gen_cb* EVP_PKEY_CTX_get_cb(EVP_PKEY_CTX* ctx); 1184 1185 int EVP_PKEY_CTX_get_keygen_info(EVP_PKEY_CTX* ctx, int idx); 1186 1187 void EVP_PKEY_meth_set_init(EVP_PKEY_METHOD* pmeth, 1188 ExternC!(int function(EVP_PKEY_CTX* ctx)) init); 1189 1190 void EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD* pmeth, 1191 ExternC!(int function(EVP_PKEY_CTX* dst, EVP_PKEY_CTX* src)) copy); 1192 1193 void EVP_PKEY_meth_set_cleanup(EVP_PKEY_METHOD* pmeth, 1194 ExternC!(void function(EVP_PKEY_CTX* ctx)) cleanup); 1195 1196 void EVP_PKEY_meth_set_paramgen(EVP_PKEY_METHOD* pmeth, 1197 ExternC!(int function(EVP_PKEY_CTX* ctx)) paramgen_init, 1198 ExternC!(int function(EVP_PKEY_CTX* ctx, EVP_PKEY* pkey)) paramgen); 1199 1200 void EVP_PKEY_meth_set_keygen(EVP_PKEY_METHOD* pmeth, 1201 ExternC!(int function(EVP_PKEY_CTX* ctx)) keygen_init, 1202 ExternC!(int function(EVP_PKEY_CTX* ctx, EVP_PKEY* pkey)) keygen); 1203 1204 void EVP_PKEY_meth_set_sign(EVP_PKEY_METHOD* pmeth, 1205 ExternC!(int function(EVP_PKEY_CTX* ctx)) sign_init, 1206 ExternC!(int function(EVP_PKEY_CTX* ctx, ubyte* sig, size_t* siglen, 1207 const(ubyte)* tbs, size_t tbslen)) sign); 1208 1209 void EVP_PKEY_meth_set_verify(EVP_PKEY_METHOD* pmeth, 1210 ExternC!(int function(EVP_PKEY_CTX* ctx)) verify_init, 1211 ExternC!(int function(EVP_PKEY_CTX* ctx, const(ubyte)* sig, size_t siglen, 1212 const(ubyte)* tbs, size_t tbslen)) verify); 1213 1214 void EVP_PKEY_meth_set_verify_recover(EVP_PKEY_METHOD* pmeth, 1215 ExternC!(int function(EVP_PKEY_CTX* ctx)) verify_recover_init, 1216 ExternC!(int function(EVP_PKEY_CTX* ctx, 1217 ubyte* sig, size_t* siglen, 1218 const(ubyte)* tbs, size_t tbslen)) verify_recover); 1219 1220 void EVP_PKEY_meth_set_signctx(EVP_PKEY_METHOD* pmeth, 1221 ExternC!(int function(EVP_PKEY_CTX* ctx, EVP_MD_CTX* mctx)) signctx_init, 1222 ExternC!(int function(EVP_PKEY_CTX* ctx, ubyte* sig, size_t* siglen, 1223 EVP_MD_CTX* mctx)) signctx); 1224 1225 void EVP_PKEY_meth_set_verifyctx(EVP_PKEY_METHOD* pmeth, 1226 ExternC!(int function(EVP_PKEY_CTX* ctx, EVP_MD_CTX* mctx)) verifyctx_init, 1227 ExternC!(int function(EVP_PKEY_CTX* ctx, const(ubyte)* sig,int siglen, 1228 EVP_MD_CTX* mctx)) verifyctx); 1229 1230 void EVP_PKEY_meth_set_encrypt(EVP_PKEY_METHOD* pmeth, 1231 ExternC!(int function(EVP_PKEY_CTX* ctx)) encrypt_init, 1232 ExternC!(int function(EVP_PKEY_CTX* ctx, ubyte* out_, size_t* outlen, 1233 const(ubyte)* in_, size_t inlen)) encryptfn); 1234 1235 void EVP_PKEY_meth_set_decrypt(EVP_PKEY_METHOD* pmeth, 1236 ExternC!(int function(EVP_PKEY_CTX* ctx)) decrypt_init, 1237 ExternC!(int function(EVP_PKEY_CTX* ctx, ubyte* out_, size_t* outlen, 1238 const(ubyte)* in_, size_t inlen)) decrypt); 1239 1240 void EVP_PKEY_meth_set_derive(EVP_PKEY_METHOD* pmeth, 1241 ExternC!(int function(EVP_PKEY_CTX* ctx)) derive_init, 1242 ExternC!(int function(EVP_PKEY_CTX* ctx, ubyte* key, size_t* keylen)) derive); 1243 1244 void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD* pmeth, 1245 ExternC!(int function(EVP_PKEY_CTX* ctx, int type, int p1, void* p2)) ctrl, 1246 ExternC!(int function(EVP_PKEY_CTX* ctx, 1247 const(char)* type, const(char)* value)) ctrl_str); 1248 1249 void EVP_add_alg_module(); 1250 1251 /* BEGIN ERROR CODES */ 1252 /* The following lines are auto generated by the script mkerr.pl. Any changes 1253 * made after this point may be overwritten when the script is next run. 1254 */ 1255 void ERR_load_EVP_strings(); 1256 1257 /* Error codes for the EVP functions. */ 1258 1259 /* Function codes. */ 1260 enum EVP_F_AESNI_INIT_KEY = 165; 1261 enum EVP_F_AESNI_XTS_CIPHER = 176; 1262 enum EVP_F_AES_INIT_KEY = 133; 1263 enum EVP_F_AES_XTS = 172; 1264 enum EVP_F_AES_XTS_CIPHER = 175; 1265 enum EVP_F_ALG_MODULE_INIT = 177; 1266 enum EVP_F_CAMELLIA_INIT_KEY = 159; 1267 enum EVP_F_CMAC_INIT = 173; 1268 enum EVP_F_D2I_PKEY = 100; 1269 enum EVP_F_DO_SIGVER_INIT = 161; 1270 enum EVP_F_DSAPKEY2PKCS8 = 134; 1271 enum EVP_F_DSA_PKEY2PKCS8 = 135; 1272 enum EVP_F_ECDSA_PKEY2PKCS8 = 129; 1273 enum EVP_F_ECKEY_PKEY2PKCS8 = 132; 1274 enum EVP_F_EVP_CIPHERINIT_EX = 123; 1275 enum EVP_F_EVP_CIPHER_CTX_COPY = 163; 1276 enum EVP_F_EVP_CIPHER_CTX_CTRL = 124; 1277 enum EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH = 122; 1278 enum EVP_F_EVP_DECRYPTFINAL_EX = 101; 1279 enum EVP_F_EVP_DIGESTINIT_EX = 128; 1280 enum EVP_F_EVP_ENCRYPTFINAL_EX = 127; 1281 enum EVP_F_EVP_MD_CTX_COPY_EX = 110; 1282 enum EVP_F_EVP_MD_SIZE = 162; 1283 enum EVP_F_EVP_OPENINIT = 102; 1284 enum EVP_F_EVP_PBE_ALG_ADD = 115; 1285 enum EVP_F_EVP_PBE_ALG_ADD_TYPE = 160; 1286 enum EVP_F_EVP_PBE_CIPHERINIT = 116; 1287 enum EVP_F_EVP_PKCS82PKEY = 111; 1288 enum EVP_F_EVP_PKCS82PKEY_BROKEN = 136; 1289 enum EVP_F_EVP_PKEY2PKCS8_BROKEN = 113; 1290 enum EVP_F_EVP_PKEY_COPY_PARAMETERS = 103; 1291 enum EVP_F_EVP_PKEY_CTX_CTRL = 137; 1292 enum EVP_F_EVP_PKEY_CTX_CTRL_STR = 150; 1293 enum EVP_F_EVP_PKEY_CTX_DUP = 156; 1294 enum EVP_F_EVP_PKEY_DECRYPT = 104; 1295 enum EVP_F_EVP_PKEY_DECRYPT_INIT = 138; 1296 enum EVP_F_EVP_PKEY_DECRYPT_OLD = 151; 1297 enum EVP_F_EVP_PKEY_DERIVE = 153; 1298 enum EVP_F_EVP_PKEY_DERIVE_INIT = 154; 1299 enum EVP_F_EVP_PKEY_DERIVE_SET_PEER = 155; 1300 enum EVP_F_EVP_PKEY_ENCRYPT = 105; 1301 enum EVP_F_EVP_PKEY_ENCRYPT_INIT = 139; 1302 enum EVP_F_EVP_PKEY_ENCRYPT_OLD = 152; 1303 enum EVP_F_EVP_PKEY_GET1_DH = 119; 1304 enum EVP_F_EVP_PKEY_GET1_DSA = 120; 1305 enum EVP_F_EVP_PKEY_GET1_ECDSA = 130; 1306 enum EVP_F_EVP_PKEY_GET1_EC_KEY = 131; 1307 enum EVP_F_EVP_PKEY_GET1_RSA = 121; 1308 enum EVP_F_EVP_PKEY_KEYGEN = 146; 1309 enum EVP_F_EVP_PKEY_KEYGEN_INIT = 147; 1310 enum EVP_F_EVP_PKEY_NEW = 106; 1311 enum EVP_F_EVP_PKEY_PARAMGEN = 148; 1312 enum EVP_F_EVP_PKEY_PARAMGEN_INIT = 149; 1313 enum EVP_F_EVP_PKEY_SIGN = 140; 1314 enum EVP_F_EVP_PKEY_SIGN_INIT = 141; 1315 enum EVP_F_EVP_PKEY_VERIFY = 142; 1316 enum EVP_F_EVP_PKEY_VERIFY_INIT = 143; 1317 enum EVP_F_EVP_PKEY_VERIFY_RECOVER = 144; 1318 enum EVP_F_EVP_PKEY_VERIFY_RECOVER_INIT = 145; 1319 enum EVP_F_EVP_RIJNDAEL = 126; 1320 enum EVP_F_EVP_SIGNFINAL = 107; 1321 enum EVP_F_EVP_VERIFYFINAL = 108; 1322 enum EVP_F_FIPS_CIPHERINIT = 166; 1323 enum EVP_F_FIPS_CIPHER_CTX_COPY = 170; 1324 enum EVP_F_FIPS_CIPHER_CTX_CTRL = 167; 1325 enum EVP_F_FIPS_CIPHER_CTX_SET_KEY_LENGTH = 171; 1326 enum EVP_F_FIPS_DIGESTINIT = 168; 1327 enum EVP_F_FIPS_MD_CTX_COPY = 169; 1328 enum EVP_F_HMAC_INIT_EX = 174; 1329 enum EVP_F_INT_CTX_NEW = 157; 1330 enum EVP_F_PKCS5_PBE_KEYIVGEN = 117; 1331 enum EVP_F_PKCS5_V2_PBE_KEYIVGEN = 118; 1332 enum EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN = 164; 1333 enum EVP_F_PKCS8_SET_BROKEN = 112; 1334 enum EVP_F_PKEY_SET_TYPE = 158; 1335 enum EVP_F_RC2_MAGIC_TO_METH = 109; 1336 enum EVP_F_RC5_CTRL = 125; 1337 1338 /* Reason codes. */ 1339 enum EVP_R_AES_IV_SETUP_FAILED = 162; 1340 enum EVP_R_AES_KEY_SETUP_FAILED = 143; 1341 enum EVP_R_ASN1_LIB = 140; 1342 enum EVP_R_BAD_BLOCK_LENGTH = 136; 1343 enum EVP_R_BAD_DECRYPT = 100; 1344 enum EVP_R_BAD_KEY_LENGTH = 137; 1345 enum EVP_R_BN_DECODE_ERROR = 112; 1346 enum EVP_R_BN_PUBKEY_ERROR = 113; 1347 enum EVP_R_BUFFER_TOO_SMALL = 155; 1348 enum EVP_R_CAMELLIA_KEY_SETUP_FAILED = 157; 1349 enum EVP_R_CIPHER_PARAMETER_ERROR = 122; 1350 enum EVP_R_COMMAND_NOT_SUPPORTED = 147; 1351 enum EVP_R_CTRL_NOT_IMPLEMENTED = 132; 1352 enum EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED = 133; 1353 enum EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH = 138; 1354 enum EVP_R_DECODE_ERROR = 114; 1355 enum EVP_R_DIFFERENT_KEY_TYPES = 101; 1356 enum EVP_R_DIFFERENT_PARAMETERS = 153; 1357 enum EVP_R_DISABLED_FOR_FIPS = 163; 1358 enum EVP_R_ENCODE_ERROR = 115; 1359 enum EVP_R_ERROR_LOADING_SECTION = 165; 1360 enum EVP_R_ERROR_SETTING_FIPS_MODE = 166; 1361 enum EVP_R_EVP_PBE_CIPHERINIT_ERROR = 119; 1362 enum EVP_R_EXPECTING_AN_RSA_KEY = 127; 1363 enum EVP_R_EXPECTING_A_DH_KEY = 128; 1364 enum EVP_R_EXPECTING_A_DSA_KEY = 129; 1365 enum EVP_R_EXPECTING_A_ECDSA_KEY = 141; 1366 enum EVP_R_EXPECTING_A_EC_KEY = 142; 1367 enum EVP_R_FIPS_MODE_NOT_SUPPORTED = 167; 1368 enum EVP_R_INITIALIZATION_ERROR = 134; 1369 enum EVP_R_INPUT_NOT_INITIALIZED = 111; 1370 enum EVP_R_INVALID_DIGEST = 152; 1371 enum EVP_R_INVALID_FIPS_MODE = 168; 1372 enum EVP_R_INVALID_KEY_LENGTH = 130; 1373 enum EVP_R_INVALID_OPERATION = 148; 1374 enum EVP_R_IV_TOO_LARGE = 102; 1375 enum EVP_R_KEYGEN_FAILURE = 120; 1376 enum EVP_R_MESSAGE_DIGEST_IS_NULL = 159; 1377 enum EVP_R_METHOD_NOT_SUPPORTED = 144; 1378 enum EVP_R_MISSING_PARAMETERS = 103; 1379 enum EVP_R_NO_CIPHER_SET = 131; 1380 enum EVP_R_NO_DEFAULT_DIGEST = 158; 1381 enum EVP_R_NO_DIGEST_SET = 139; 1382 enum EVP_R_NO_DSA_PARAMETERS = 116; 1383 enum EVP_R_NO_KEY_SET = 154; 1384 enum EVP_R_NO_OPERATION_SET = 149; 1385 enum EVP_R_NO_SIGN_FUNCTION_CONFIGURED = 104; 1386 enum EVP_R_NO_VERIFY_FUNCTION_CONFIGURED = 105; 1387 enum EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE = 150; 1388 enum EVP_R_OPERATON_NOT_INITIALIZED = 151; 1389 enum EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE = 117; 1390 enum EVP_R_PRIVATE_KEY_DECODE_ERROR = 145; 1391 enum EVP_R_PRIVATE_KEY_ENCODE_ERROR = 146; 1392 enum EVP_R_PUBLIC_KEY_NOT_RSA = 106; 1393 enum EVP_R_TOO_LARGE = 164; 1394 enum EVP_R_UNKNOWN_CIPHER = 160; 1395 enum EVP_R_UNKNOWN_DIGEST = 161; 1396 enum EVP_R_UNKNOWN_OPTION = 169; 1397 enum EVP_R_UNKNOWN_PBE_ALGORITHM = 121; 1398 enum EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS = 135; 1399 enum EVP_R_UNSUPPORTED_ALGORITHM = 156; 1400 enum EVP_R_UNSUPPORTED_CIPHER = 107; 1401 enum EVP_R_UNSUPPORTED_KEYLENGTH = 123; 1402 enum EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION = 124; 1403 enum EVP_R_UNSUPPORTED_KEY_SIZE = 108; 1404 enum EVP_R_UNSUPPORTED_PRF = 125; 1405 enum EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM = 118; 1406 enum EVP_R_UNSUPPORTED_SALT_TYPE = 126; 1407 enum EVP_R_WRONG_FINAL_BLOCK_LENGTH = 109; 1408 enum EVP_R_WRONG_PUBLIC_KEY_TYPE = 110;