1 /* $OpenBSD: crypto.h,v 1.50 2019/01/19 01:07:00 tb Exp $ */ 2 /* ==================================================================== 3 * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in 14 * the documentation and/or other materials provided with the 15 * distribution. 16 * 17 * 3. All advertising materials mentioning features or use of this 18 * software must display the following acknowledgment: 19 * "This product includes software developed by the OpenSSL Project 20 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 21 * 22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 23 * endorse or promote products derived from this software without 24 * prior written permission. For written permission, please contact 25 * openssl-core@openssl.org. 26 * 27 * 5. Products derived from this software may not be called "OpenSSL" 28 * nor may "OpenSSL" appear in their names without prior written 29 * permission of the OpenSSL Project. 30 * 31 * 6. Redistributions of any form whatsoever must retain the following 32 * acknowledgment: 33 * "This product includes software developed by the OpenSSL Project 34 * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 35 * 36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 47 * OF THE POSSIBILITY OF SUCH DAMAGE. 48 * ==================================================================== 49 * 50 * This product includes cryptographic software written by Eric Young 51 * (eay@cryptsoft.com). This product includes software written by Tim 52 * Hudson (tjh@cryptsoft.com). 53 * 54 */ 55 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 56 * All rights reserved. 57 * 58 * This package is an SSL implementation written 59 * by Eric Young (eay@cryptsoft.com). 60 * The implementation was written so as to conform with Netscapes SSL. 61 * 62 * This library is free for commercial and non-commercial use as core.stdc.config.c_long as 63 * the following conditions are aheared to. The following conditions 64 * apply to all code found in this distribution, be it the RC4, RSA, 65 * lhash, DES, etc., code; not just the SSL code. The SSL documentation 66 * included with this distribution is covered by the same copyright terms 67 * except that the holder is Tim Hudson (tjh@cryptsoft.com). 68 * 69 * Copyright remains Eric Young's, and as such any Copyright notices in 70 * the code are not to be removed. 71 * If this package is used in a product, Eric Young should be given attribution 72 * as the author of the parts of the library used. 73 * This can be in the form of a textual message at program startup or 74 * in documentation (online or textual) provided with the package. 75 * 76 * Redistribution and use in source and binary forms, with or without 77 * modification, are permitted provided that the following conditions 78 * are met: 79 * 1. Redistributions of source code must retain the copyright 80 * notice, this list of conditions and the following disclaimer. 81 * 2. Redistributions in binary form must reproduce the above copyright 82 * notice, this list of conditions and the following disclaimer in the 83 * documentation and/or other materials provided with the distribution. 84 * 3. All advertising materials mentioning features or use of this software 85 * must display the following acknowledgement: 86 * "This product includes cryptographic software written by 87 * Eric Young (eay@cryptsoft.com)" 88 * The word 'cryptographic' can be left out if the rouines from the library 89 * being used are not cryptographic related :-). 90 * 4. If you include any Windows specific code (or a derivative thereof) from 91 * the apps directory (application code) you must include an acknowledgement: 92 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 93 * 94 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 95 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 96 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 97 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 98 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 99 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 100 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 101 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 102 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 103 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 104 * SUCH DAMAGE. 105 * 106 * The licence and distribution terms for any publically available version or 107 * derivative of this code cannot be changed. i.e. this code cannot simply be 108 * copied and put under another distribution licence 109 * [including the GNU Public Licence.] 110 */ 111 /* ==================================================================== 112 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. 113 * ECDH support in OpenSSL originally developed by 114 * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. 115 */ 116 module libressl_d.openssl.crypto; 117 118 119 private static import core.stdc.config; 120 private static import libressl_d.openssl.bio; 121 public import core.stdc.stdint; 122 public import libressl_d.compat.stdio; 123 public import libressl_d.compat.stdlib; 124 public import libressl_d.openssl.opensslconf; 125 public import libressl_d.openssl.opensslv; 126 public import libressl_d.openssl.ossl_typ; 127 public import libressl_d.openssl.safestack; 128 public import libressl_d.openssl.stack; 129 130 extern (C): 131 nothrow @nogc: 132 133 /* Backward compatibility to SSLeay */ 134 /* 135 * This is more to be used to check the correct DLL is being used 136 * in the MS world. 137 */ 138 enum SSLEAY_VERSION_NUMBER = libressl_d.openssl.opensslv.OPENSSL_VERSION_NUMBER; 139 enum SSLEAY_VERSION = 0; 140 141 /** 142 * no longer supported 143 */ 144 @disable 145 enum SSLEAY_OPTIONS = 1; 146 147 enum SSLEAY_CFLAGS = 2; 148 enum SSLEAY_BUILT_ON = 3; 149 enum SSLEAY_PLATFORM = 4; 150 enum SSLEAY_DIR = 5; 151 152 /** 153 * A generic structure to pass assorted data in a expandable way 154 */ 155 struct openssl_item_st 156 { 157 int code; 158 159 /** 160 * Not used for flag attributes 161 */ 162 void* value; 163 164 /** 165 * Max size of value for output, length for input 166 */ 167 size_t value_size; 168 169 /** 170 * Returned length of value for output 171 */ 172 size_t* value_length; 173 } 174 175 alias OPENSSL_ITEM = .openssl_item_st; 176 177 /* 178 * When changing the CRYPTO_LOCK_* list, be sure to maintain the text lock 179 * names in cryptlib.c 180 */ 181 182 enum CRYPTO_LOCK_ERR = 1; 183 enum CRYPTO_LOCK_EX_DATA = 2; 184 enum CRYPTO_LOCK_X509 = 3; 185 enum CRYPTO_LOCK_X509_INFO = 4; 186 enum CRYPTO_LOCK_X509_PKEY = 5; 187 enum CRYPTO_LOCK_X509_CRL = 6; 188 enum CRYPTO_LOCK_X509_REQ = 7; 189 enum CRYPTO_LOCK_DSA = 8; 190 enum CRYPTO_LOCK_RSA = 9; 191 enum CRYPTO_LOCK_EVP_PKEY = 10; 192 enum CRYPTO_LOCK_X509_STORE = 11; 193 enum CRYPTO_LOCK_SSL_CTX = 12; 194 enum CRYPTO_LOCK_SSL_CERT = 13; 195 enum CRYPTO_LOCK_SSL_SESSION = 14; 196 enum CRYPTO_LOCK_SSL_SESS_CERT = 15; 197 enum CRYPTO_LOCK_SSL = 16; 198 enum CRYPTO_LOCK_SSL_METHOD = 17; 199 enum CRYPTO_LOCK_RAND = 18; 200 enum CRYPTO_LOCK_RAND2 = 19; 201 enum CRYPTO_LOCK_MALLOC = 20; 202 enum CRYPTO_LOCK_BIO = 21; 203 enum CRYPTO_LOCK_GETHOSTBYNAME = 22; 204 enum CRYPTO_LOCK_GETSERVBYNAME = 23; 205 enum CRYPTO_LOCK_READDIR = 24; 206 enum CRYPTO_LOCK_RSA_BLINDING = 25; 207 enum CRYPTO_LOCK_DH = 26; 208 enum CRYPTO_LOCK_MALLOC2 = 27; 209 enum CRYPTO_LOCK_DSO = 28; 210 enum CRYPTO_LOCK_DYNLOCK = 29; 211 enum CRYPTO_LOCK_ENGINE = 30; 212 enum CRYPTO_LOCK_UI = 31; 213 enum CRYPTO_LOCK_ECDSA = 32; 214 enum CRYPTO_LOCK_EC = 33; 215 enum CRYPTO_LOCK_ECDH = 34; 216 enum CRYPTO_LOCK_BN = 35; 217 enum CRYPTO_LOCK_EC_PRE_COMP = 36; 218 enum CRYPTO_LOCK_STORE = 37; 219 enum CRYPTO_LOCK_COMP = 38; 220 enum CRYPTO_LOCK_FIPS = 39; 221 enum CRYPTO_LOCK_FIPS2 = 40; 222 enum CRYPTO_NUM_LOCKS = 41; 223 224 enum CRYPTO_LOCK = 1; 225 enum CRYPTO_UNLOCK = 2; 226 enum CRYPTO_READ = 4; 227 enum CRYPTO_WRITE = 8; 228 229 version (CRYPTO_w_lock) { 230 } else { 231 template CRYPTO_w_lock(string type) 232 { 233 enum CRYPTO_w_lock = "libressl_d.openssl.crypto.CRYPTO_lock(libressl_d.openssl.crypto.CRYPTO_LOCK | libressl_d.openssl.crypto.CRYPTO_WRITE, " ~ type ~ ", __FILE__, __LINE__);"; 234 } 235 236 template CRYPTO_w_unlock(string type) 237 { 238 enum CRYPTO_w_unlock = "libressl_d.openssl.crypto.CRYPTO_lock(libressl_d.openssl.crypto.CRYPTO_UNLOCK | libressl_d.openssl.crypto.CRYPTO_WRITE, " ~ type ~ ", __FILE__, __LINE__);"; 239 } 240 241 template CRYPTO_r_lock(string type) 242 { 243 enum CRYPTO_r_lock = "libressl_d.openssl.crypto.CRYPTO_lock(libressl_d.openssl.crypto.CRYPTO_LOCK | libressl_d.openssl.crypto.CRYPTO_READ, " ~ type ~ ", __FILE__, __LINE__);"; 244 } 245 246 template CRYPTO_r_unlock(string type) 247 { 248 enum CRYPTO_r_unlock = "libressl_d.openssl.crypto.CRYPTO_lock(libressl_d.openssl.crypto.CRYPTO_UNLOCK | libressl_d.openssl.crypto.CRYPTO_READ, " ~ type ~ ", __FILE__, __LINE__);"; 249 } 250 251 template CRYPTO_add(string addr, string amount, string type) 252 { 253 enum CRYPTO_add = "libressl_d.openssl.crypto.CRYPTO_add_lock(" ~ addr ~ ", " ~ amount ~ ", " ~ type ~ ", __FILE__, __LINE__);"; 254 } 255 } 256 257 /** 258 * Some applications as well as some parts of OpenSSL need to allocate 259 * and deallocate locks in a dynamic fashion. The following typedef 260 * makes this possible in a type-safe manner. 261 */ 262 alias CRYPTO_dynlock_value = void; 263 264 /** 265 * CRYPTO_dynlock_value has to be defined by the application. 266 */ 267 struct CRYPTO_dynlock 268 { 269 int references; 270 .CRYPTO_dynlock_value* data; 271 } 272 273 /* 274 * The following can be used to detect memory leaks in the SSLeay library. 275 * It used, it turns on malloc checking 276 */ 277 278 /** 279 * an enume 280 */ 281 enum CRYPTO_MEM_CHECK_OFF = 0x00; 282 283 /** 284 * a bit 285 */ 286 enum CRYPTO_MEM_CHECK_ON = 0x01; 287 288 ///Ditto 289 enum CRYPTO_MEM_CHECK_ENABLE = 0x02; 290 291 /** 292 * an enume 293 */ 294 enum CRYPTO_MEM_CHECK_DISABLE = 0x03; 295 296 /* 297 * The following are bit values to turn on or off options connected to the 298 * malloc checking functionality 299 */ 300 301 /** 302 * Adds time to the memory checking information 303 */ 304 /* a bit */ 305 enum V_CRYPTO_MDEBUG_TIME = 0x01; 306 307 /** 308 * Adds thread number to the memory checking information 309 */ 310 /* a bit */ 311 enum V_CRYPTO_MDEBUG_THREAD = 0x02; 312 313 enum V_CRYPTO_MDEBUG_ALL = .V_CRYPTO_MDEBUG_TIME | .V_CRYPTO_MDEBUG_THREAD; 314 315 /** 316 * predec of the BIO type 317 */ 318 alias BIO_dummy = libressl_d.openssl.bio.bio_st; 319 320 struct crypto_ex_data_st 321 { 322 .stack_st_void* sk; 323 } 324 325 //DECLARE_STACK_OF(void) 326 struct stack_st_void 327 { 328 libressl_d.openssl.stack._STACK stack; 329 } 330 331 /** 332 * This stuff is basically class callback functions 333 * The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more 334 */ 335 struct crypto_ex_data_func_st 336 { 337 /** 338 * Arbitary core.stdc.config.c_long 339 */ 340 core.stdc.config.c_long argl; 341 342 /** 343 * Arbitary void * 344 */ 345 void* argp; 346 347 libressl_d.openssl.ossl_typ.CRYPTO_EX_new* new_func; 348 libressl_d.openssl.ossl_typ.CRYPTO_EX_free* free_func; 349 libressl_d.openssl.ossl_typ.CRYPTO_EX_dup* dup_func; 350 } 351 352 alias CRYPTO_EX_DATA_FUNCS = .crypto_ex_data_func_st; 353 354 //DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS) 355 struct stack_st_CRYPTO_EX_DATA_FUNCS 356 { 357 libressl_d.openssl.stack._STACK stack; 358 } 359 360 /* 361 * Per class, we have a STACK of CRYPTO_EX_DATA_FUNCS for each CRYPTO_EX_DATA 362 * entry. 363 */ 364 365 enum CRYPTO_EX_INDEX_BIO = 0; 366 enum CRYPTO_EX_INDEX_SSL = 1; 367 enum CRYPTO_EX_INDEX_SSL_CTX = 2; 368 enum CRYPTO_EX_INDEX_SSL_SESSION = 3; 369 enum CRYPTO_EX_INDEX_X509_STORE = 4; 370 enum CRYPTO_EX_INDEX_X509_STORE_CTX = 5; 371 enum CRYPTO_EX_INDEX_RSA = 6; 372 enum CRYPTO_EX_INDEX_DSA = 7; 373 enum CRYPTO_EX_INDEX_DH = 8; 374 enum CRYPTO_EX_INDEX_ENGINE = 9; 375 enum CRYPTO_EX_INDEX_X509 = 10; 376 enum CRYPTO_EX_INDEX_UI = 11; 377 enum CRYPTO_EX_INDEX_ECDSA = 12; 378 enum CRYPTO_EX_INDEX_ECDH = 13; 379 enum CRYPTO_EX_INDEX_COMP = 14; 380 enum CRYPTO_EX_INDEX_STORE = 15; 381 enum CRYPTO_EX_INDEX_EC_KEY = 16; 382 383 /** 384 * Dynamically assigned indexes start from this value (don't use directly, use 385 * via CRYPTO_ex_data_new_class). 386 */ 387 enum CRYPTO_EX_INDEX_USER = 100; 388 389 version (LIBRESSL_INTERNAL) { 390 } else { 391 pragma(inline, true) 392 pure nothrow @safe @nogc @live 393 int CRYPTO_malloc_init() 394 395 do 396 { 397 return 0; 398 } 399 400 pragma(inline, true) 401 pure nothrow @safe @nogc @live 402 int CRYPTO_malloc_debug_init() 403 404 do 405 { 406 return 0; 407 } 408 409 //#if defined(CRYPTO_MDEBUG_ALL) || defined(CRYPTO_MDEBUG_TIME) || defined(CRYPTO_MDEBUG_THREAD) 410 /* avoid duplicate #define */ 411 version (CRYPTO_MDEBUG) { 412 } else { 413 //#define CRYPTO_MDEBUG 414 } 415 //#endif 416 417 int CRYPTO_mem_ctrl(int mode); 418 int CRYPTO_is_mem_check_on(); 419 420 /* for applications */ 421 pragma(inline, true) 422 int MemCheck_start() 423 424 do 425 { 426 return .CRYPTO_mem_ctrl(.CRYPTO_MEM_CHECK_ON); 427 } 428 429 pragma(inline, true) 430 int MemCheck_stop() 431 432 do 433 { 434 return .CRYPTO_mem_ctrl(.CRYPTO_MEM_CHECK_OFF); 435 } 436 437 template OPENSSL_malloc(string num) 438 { 439 enum OPENSSL_malloc = "libressl_d.openssl.crypto.CRYPTO_malloc(cast(int)(" ~ num ~ "), __FILE__, __LINE__)"; 440 } 441 442 template OPENSSL_strdup(string str) 443 { 444 enum OPENSSL_strdup = "libressl_d.openssl.crypto.CRYPTO_strdup(" ~ str ~ ", __FILE__, __LINE__)"; 445 } 446 447 template OPENSSL_realloc(string addr, string num) 448 { 449 enum OPENSSL_realloc = "libressl_d.openssl.crypto.CRYPTO_realloc(cast(char*)(" ~ addr ~ "), cast(int)(" ~ num ~ "), __FILE__, __LINE__)"; 450 } 451 452 template OPENSSL_realloc_clean(string addr, string old_num, string num) 453 { 454 enum OPENSSL_realloc_clean = "libressl_d.openssl.crypto.CRYPTO_realloc_clean(" ~ addr ~ ", " ~ old_num ~ ", " ~ num ~ ", __FILE__, __LINE__)"; 455 } 456 457 template OPENSSL_remalloc(string addr, string num) 458 { 459 enum OPENSSL_remalloc = "libressl_d.openssl.crypto.CRYPTO_remalloc(cast(char**)(" ~ addr ~ "), cast(int)(" ~ num ~ "), __FILE__, __LINE__)"; 460 } 461 462 alias OPENSSL_freeFunc = .CRYPTO_free; 463 alias OPENSSL_free = .CRYPTO_free; 464 465 template OPENSSL_malloc_locked(num) 466 { 467 enum OPENSSL_malloc_locked = "libressl_d.openssl.crypto.CRYPTO_malloc_locked(cast(int)(" ~ num ~ "), __FILE__, __LINE__)"; 468 } 469 470 alias OPENSSL_free_locked = .CRYPTO_free_locked; 471 } 472 473 const (char)* OpenSSL_version(int type); 474 enum OPENSSL_VERSION = 0; 475 enum OPENSSL_CFLAGS = 1; 476 enum OPENSSL_BUILT_ON = 2; 477 enum OPENSSL_PLATFORM = 3; 478 enum OPENSSL_DIR = 4; 479 enum OPENSSL_ENGINES_DIR = 5; 480 core.stdc.config.c_ulong OpenSSL_version_num(); 481 482 const (char)* SSLeay_version(int type); 483 core.stdc.config.c_ulong SSLeay(); 484 485 /* An opaque type representing an implementation of "ex_data" support */ 486 struct st_CRYPTO_EX_DATA_IMPL; 487 alias CRYPTO_EX_DATA_IMPL = .st_CRYPTO_EX_DATA_IMPL; 488 489 /** 490 * Return an opaque pointer to the current "ex_data" implementation 491 */ 492 const (.CRYPTO_EX_DATA_IMPL)* CRYPTO_get_ex_data_implementation(); 493 494 /** 495 * Sets the "ex_data" implementation to be used (if it's not too late) 496 */ 497 int CRYPTO_set_ex_data_implementation(const (.CRYPTO_EX_DATA_IMPL)* i); 498 499 /** 500 * Get a new "ex_data" class, and return the corresponding "class_index" 501 */ 502 int CRYPTO_ex_data_new_class(); 503 504 /** 505 * Within a given class, get/register a new index 506 */ 507 int CRYPTO_get_ex_new_index(int class_index, core.stdc.config.c_long argl, void* argp, libressl_d.openssl.ossl_typ.CRYPTO_EX_new* new_func, libressl_d.openssl.ossl_typ.CRYPTO_EX_dup* dup_func, libressl_d.openssl.ossl_typ.CRYPTO_EX_free* free_func); 508 509 /* 510 * Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a given 511 * class (invokes whatever per-class callbacks are applicable) 512 */ 513 int CRYPTO_new_ex_data(int class_index, void* obj, libressl_d.openssl.ossl_typ.CRYPTO_EX_DATA* ad); 514 int CRYPTO_dup_ex_data(int class_index, libressl_d.openssl.ossl_typ.CRYPTO_EX_DATA* to, libressl_d.openssl.ossl_typ.CRYPTO_EX_DATA* from); 515 void CRYPTO_free_ex_data(int class_index, void* obj, libressl_d.openssl.ossl_typ.CRYPTO_EX_DATA* ad); 516 517 /* 518 * Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular index 519 * (relative to the class type involved) 520 */ 521 int CRYPTO_set_ex_data(libressl_d.openssl.ossl_typ.CRYPTO_EX_DATA* ad, int idx, void* val); 522 void* CRYPTO_get_ex_data(const (libressl_d.openssl.ossl_typ.CRYPTO_EX_DATA)* ad, int idx); 523 524 /** 525 * This function cleans up all "ex_data" state. It mustn't be called under 526 * potential race-conditions. 527 */ 528 void CRYPTO_cleanup_all_ex_data(); 529 530 void CRYPTO_lock(int mode, int type, const (char)* file, int line); 531 int CRYPTO_add_lock(int* pointer, int amount, int type, const (char)* file, int line); 532 533 /** 534 * Don't use this structure directly. 535 */ 536 struct crypto_threadid_st 537 { 538 void* ptr_; 539 core.stdc.config.c_ulong val; 540 } 541 542 alias CRYPTO_THREADID = .crypto_threadid_st; 543 void CRYPTO_THREADID_current(.CRYPTO_THREADID* id); 544 int CRYPTO_THREADID_cmp(const (.CRYPTO_THREADID)* a, const (.CRYPTO_THREADID)* b); 545 void CRYPTO_THREADID_cpy(.CRYPTO_THREADID* dest, const (.CRYPTO_THREADID)* src); 546 core.stdc.config.c_ulong CRYPTO_THREADID_hash(const (.CRYPTO_THREADID)* id); 547 548 version (LIBRESSL_INTERNAL) { 549 } else { 550 /* These functions are deprecated no-op stubs */ 551 void CRYPTO_set_id_callback(core.stdc.config.c_ulong function() func); 552 //core.stdc.config.c_ulong (*CRYPTO_get_id_callback(void))(); 553 core.stdc.config.c_ulong CRYPTO_thread_id(); 554 555 int CRYPTO_get_new_lockid(char* name); 556 const (char)* CRYPTO_get_lock_name(int type); 557 558 int CRYPTO_num_locks(); 559 void CRYPTO_set_locking_callback(void function(int mode, int type, const (char)* file, int line) func); 560 //void (*CRYPTO_get_locking_callback(void))(int mode, int type, const (char)* file, int line); 561 void CRYPTO_set_add_lock_callback(int function(int* num, int mount, int type, const (char)* file, int line) func); 562 //int (*CRYPTO_get_add_lock_callback(void))(int* num, int mount, int type, const (char)* file, int line); 563 564 void CRYPTO_THREADID_set_numeric(.CRYPTO_THREADID* id, core.stdc.config.c_ulong val); 565 void CRYPTO_THREADID_set_pointer(.CRYPTO_THREADID* id, void* ptr_); 566 int CRYPTO_THREADID_set_callback(void function(.CRYPTO_THREADID*) threadid_func); 567 //void (*CRYPTO_THREADID_get_callback(void))(.CRYPTO_THREADID*); 568 569 int CRYPTO_get_new_dynlockid(); 570 void CRYPTO_destroy_dynlockid(int i); 571 .CRYPTO_dynlock_value* CRYPTO_get_dynlock_value(int i); 572 void CRYPTO_set_dynlock_create_callback(.CRYPTO_dynlock_value* function(const (char)* file, int line) dyn_create_function); 573 void CRYPTO_set_dynlock_lock_callback(void function(int mode, .CRYPTO_dynlock_value* l, const (char)* file, int line) dyn_lock_function); 574 void CRYPTO_set_dynlock_destroy_callback(void function(.CRYPTO_dynlock_value* l, const (char)* file, int line) dyn_destroy_function); 575 //.CRYPTO_dynlock_value* (*CRYPTO_get_dynlock_create_callback(void))(const (char)* file, int line); 576 //void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, .CRYPTO_dynlock_value* l, const (char)* file, int line); 577 //void (*CRYPTO_get_dynlock_destroy_callback(void))(.CRYPTO_dynlock_value* l, const (char)* file, int line); 578 } 579 580 /* 581 * CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions -- 582 * call the latter last if you need different functions 583 */ 584 int CRYPTO_set_mem_functions(void* function(size_t) m, void* function(void*, size_t) r, void function(void*) f); 585 int CRYPTO_set_locked_mem_functions(void* function(size_t) m, void function(void*) free_func); 586 int CRYPTO_set_mem_ex_functions(void* function(size_t, const (char)*, int) m, void* function(void*, size_t, const (char)*, int) r, void function(void*) f); 587 int CRYPTO_set_locked_mem_ex_functions(void* function(size_t, const (char)*, int) m, void function(void*) free_func); 588 int CRYPTO_set_mem_debug_functions(void function(void*, int, const (char)*, int, int) m, void function(void*, void*, int, const (char)*, int, int) r, void function(void*, int) f, void function(core.stdc.config.c_long) so, core.stdc.config.c_long function() go); 589 void CRYPTO_get_mem_functions(void* function(size_t)* m, void* function(void*, size_t)* r, void function(void*)* f); 590 void CRYPTO_get_locked_mem_functions(void* function(size_t)* m, void function(void*)* f); 591 void CRYPTO_get_mem_ex_functions(void* function(size_t, const (char)*, int)* m, void* function(void*, size_t, const (char)*, int)* r, void function(void*)* f); 592 void CRYPTO_get_locked_mem_ex_functions(void* function(size_t, const (char)*, int)* m, void function(void*)* f); 593 void CRYPTO_get_mem_debug_functions(void function(void*, int, const (char)*, int, int)* m, void function(void*, void*, int, const (char)*, int, int)* r, void function(void*, int)* f, void function(core.stdc.config.c_long)* so, core.stdc.config.c_long function()* go); 594 595 version (LIBRESSL_INTERNAL) { 596 } else { 597 void* CRYPTO_malloc_locked(int num, const (char)* file, int line); 598 void CRYPTO_free_locked(void* ptr_); 599 void* CRYPTO_malloc(int num, const (char)* file, int line); 600 char* CRYPTO_strdup(const (char)* str, const (char)* file, int line); 601 void CRYPTO_free(void* ptr_); 602 void* CRYPTO_realloc(void* addr, int num, const (char)* file, int line); 603 } 604 605 void* CRYPTO_realloc_clean(void* addr, int old_num, int num, const (char)* file, int line); 606 void* CRYPTO_remalloc(void* addr, int num, const (char)* file, int line); 607 608 version (LIBRESSL_INTERNAL) { 609 } else { 610 void OPENSSL_cleanse(void* ptr_, size_t len); 611 } 612 613 void CRYPTO_set_mem_debug_options(core.stdc.config.c_long bits); 614 core.stdc.config.c_long CRYPTO_get_mem_debug_options(); 615 616 template CRYPTO_push_info(string info) 617 { 618 enum CRYPTO_push_info = "libressl_d.openssl.crypto.CRYPTO_push_info_(" ~ info ~ ", __FILE__, __LINE__)"; 619 } 620 621 int CRYPTO_push_info_(const (char)* info, const (char)* file, int line); 622 int CRYPTO_pop_info(); 623 int CRYPTO_remove_all_info(); 624 625 /* 626 * Default debugging functions (enabled by CRYPTO_malloc_debug_init() macro; 627 * used as default in CRYPTO_MDEBUG compilations): 628 */ 629 /* 630 * The last argument has the following significance: 631 * 632 * 0: called before the actual memory allocation has taken place 633 * 1: called after the actual memory allocation has taken place 634 */ 635 deprecated 636 void CRYPTO_dbg_malloc(void* addr, int num, const (char)* file, int line, int before_p); 637 638 deprecated 639 void CRYPTO_dbg_realloc(void* addr1, void* addr2, int num, const (char)* file, int line, int before_p); 640 641 deprecated 642 void CRYPTO_dbg_free(void* addr, int before_p); 643 644 /* 645 * Tell the debugging code about options. By default, the following values 646 * apply: 647 * 648 * 0: Clear all options. 649 * V_CRYPTO_MDEBUG_TIME (1): Set the "Show Time" option. 650 * V_CRYPTO_MDEBUG_THREAD (2): Set the "Show Thread Number" option. 651 * V_CRYPTO_MDEBUG_ALL (3): 1 + 2 652 */ 653 deprecated 654 void CRYPTO_dbg_set_options(core.stdc.config.c_long bits); 655 656 deprecated 657 core.stdc.config.c_long CRYPTO_dbg_get_options(); 658 659 int CRYPTO_mem_leaks_fp(libressl_d.compat.stdio.FILE*); 660 int CRYPTO_mem_leaks(libressl_d.openssl.bio.bio_st* bio); 661 /* core.stdc.config.c_ulong order, char* ile, int line, int num_bytes, char* ddr */ 662 alias CRYPTO_MEM_LEAK_CB = extern (C) nothrow @nogc int* function(core.stdc.config.c_ulong, const (char)*, int, int, void*); 663 int CRYPTO_mem_leaks_cb(.CRYPTO_MEM_LEAK_CB* cb); 664 665 /** 666 * die if we have to 667 */ 668 void OpenSSLDie(const (char)* file, int line, const (char)* assertion); 669 //#define OPENSSL_assert(e) cast(void)(e ? (0) : (.OpenSSLDie(__FILE__, __LINE__, #e), 1)) 670 671 core.stdc.stdint.uint64_t OPENSSL_cpu_caps(); 672 673 int OPENSSL_isservice(); 674 675 version (LIBRESSL_INTERNAL) { 676 } else { 677 void OPENSSL_init(); 678 679 /** 680 * CRYPTO_memcmp returns zero iff the |len| bytes at |a| and |b| are equal. It 681 * takes an amount of time dependent on |len|, but independent of the contents 682 * of |a| and |b|. Unlike memcmp, it cannot be used to put elements into a 683 * defined order as the return value when a != b is undefined, other than to be 684 * non-zero. 685 */ 686 int CRYPTO_memcmp(const (void)* a, const (void)* b, size_t len); 687 } 688 689 /* BEGIN ERROR CODES */ 690 /** 691 * The following lines are auto generated by the script mkerr.pl. Any changes 692 * made after this point may be overwritten when the script is next run. 693 */ 694 void ERR_load_CRYPTO_strings(); 695 696 /* Error codes for the CRYPTO functions. */ 697 698 /* Function codes. */ 699 enum CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX = 100; 700 enum CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID = 103; 701 enum CRYPTO_F_CRYPTO_GET_NEW_LOCKID = 101; 702 enum CRYPTO_F_CRYPTO_SET_EX_DATA = 102; 703 enum CRYPTO_F_DEF_ADD_INDEX = 104; 704 enum CRYPTO_F_DEF_GET_CLASS = 105; 705 enum CRYPTO_F_FIPS_MODE_SET = 109; 706 enum CRYPTO_F_INT_DUP_EX_DATA = 106; 707 enum CRYPTO_F_INT_FREE_EX_DATA = 107; 708 enum CRYPTO_F_INT_NEW_EX_DATA = 108; 709 710 /* Reason codes. */ 711 enum CRYPTO_R_FIPS_MODE_NOT_SUPPORTED = 101; 712 enum CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK = 100; 713 714 /* 715 * OpenSSL compatible OPENSSL_INIT options. 716 */ 717 718 enum OPENSSL_INIT_NO_LOAD_CONFIG = 0x00000001L; 719 enum OPENSSL_INIT_LOAD_CONFIG = 0x00000002L; 720 721 /* LibreSSL specific */ 722 enum _OPENSSL_INIT_FLAG_NOOP = 0x80000000L; 723 724 /* 725 * These are provided for compatibiliy, but have no effect 726 * on how LibreSSL is initialized. 727 */ 728 enum OPENSSL_INIT_NO_LOAD_CRYPTO_STRINGS = ._OPENSSL_INIT_FLAG_NOOP; 729 enum OPENSSL_INIT_LOAD_CRYPTO_STRINGS = ._OPENSSL_INIT_FLAG_NOOP; 730 enum OPENSSL_INIT_ADD_ALL_CIPHERS = ._OPENSSL_INIT_FLAG_NOOP; 731 enum OPENSSL_INIT_ADD_ALL_DIGESTS = ._OPENSSL_INIT_FLAG_NOOP; 732 enum OPENSSL_INIT_NO_ADD_ALL_CIPHERS = ._OPENSSL_INIT_FLAG_NOOP; 733 enum OPENSSL_INIT_NO_ADD_ALL_DIGESTS = ._OPENSSL_INIT_FLAG_NOOP; 734 enum OPENSSL_INIT_ASYNC = ._OPENSSL_INIT_FLAG_NOOP; 735 enum OPENSSL_INIT_ENGINE_RDRAND = ._OPENSSL_INIT_FLAG_NOOP; 736 enum OPENSSL_INIT_ENGINE_DYNAMIC = ._OPENSSL_INIT_FLAG_NOOP; 737 enum OPENSSL_INIT_ENGINE_OPENSSL = ._OPENSSL_INIT_FLAG_NOOP; 738 enum OPENSSL_INIT_ENGINE_CRYPTODEV = ._OPENSSL_INIT_FLAG_NOOP; 739 enum OPENSSL_INIT_ENGINE_CAPI = ._OPENSSL_INIT_FLAG_NOOP; 740 enum OPENSSL_INIT_ENGINE_PADLOCK = ._OPENSSL_INIT_FLAG_NOOP; 741 enum OPENSSL_INIT_ENGINE_AFALG = ._OPENSSL_INIT_FLAG_NOOP; 742 enum OPENSSL_INIT_reserved_internal = ._OPENSSL_INIT_FLAG_NOOP; 743 enum OPENSSL_INIT_ATFORK = ._OPENSSL_INIT_FLAG_NOOP; 744 enum OPENSSL_INIT_ENGINE_ALL_BUILTIN = ._OPENSSL_INIT_FLAG_NOOP; 745 746 int OPENSSL_init_crypto(core.stdc.stdint.uint64_t opts, const (void)* settings);