10Sstevel@tonic-gate /* crypto/crypto.h */ 2*2139Sjp161948 /* ==================================================================== 3*2139Sjp161948 * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. 4*2139Sjp161948 * 5*2139Sjp161948 * Redistribution and use in source and binary forms, with or without 6*2139Sjp161948 * modification, are permitted provided that the following conditions 7*2139Sjp161948 * are met: 8*2139Sjp161948 * 9*2139Sjp161948 * 1. Redistributions of source code must retain the above copyright 10*2139Sjp161948 * notice, this list of conditions and the following disclaimer. 11*2139Sjp161948 * 12*2139Sjp161948 * 2. Redistributions in binary form must reproduce the above copyright 13*2139Sjp161948 * notice, this list of conditions and the following disclaimer in 14*2139Sjp161948 * the documentation and/or other materials provided with the 15*2139Sjp161948 * distribution. 16*2139Sjp161948 * 17*2139Sjp161948 * 3. All advertising materials mentioning features or use of this 18*2139Sjp161948 * software must display the following acknowledgment: 19*2139Sjp161948 * "This product includes software developed by the OpenSSL Project 20*2139Sjp161948 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 21*2139Sjp161948 * 22*2139Sjp161948 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 23*2139Sjp161948 * endorse or promote products derived from this software without 24*2139Sjp161948 * prior written permission. For written permission, please contact 25*2139Sjp161948 * openssl-core@openssl.org. 26*2139Sjp161948 * 27*2139Sjp161948 * 5. Products derived from this software may not be called "OpenSSL" 28*2139Sjp161948 * nor may "OpenSSL" appear in their names without prior written 29*2139Sjp161948 * permission of the OpenSSL Project. 30*2139Sjp161948 * 31*2139Sjp161948 * 6. Redistributions of any form whatsoever must retain the following 32*2139Sjp161948 * acknowledgment: 33*2139Sjp161948 * "This product includes software developed by the OpenSSL Project 34*2139Sjp161948 * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 35*2139Sjp161948 * 36*2139Sjp161948 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 37*2139Sjp161948 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 38*2139Sjp161948 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 39*2139Sjp161948 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 40*2139Sjp161948 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 41*2139Sjp161948 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 42*2139Sjp161948 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 43*2139Sjp161948 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 44*2139Sjp161948 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 45*2139Sjp161948 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 46*2139Sjp161948 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 47*2139Sjp161948 * OF THE POSSIBILITY OF SUCH DAMAGE. 48*2139Sjp161948 * ==================================================================== 49*2139Sjp161948 * 50*2139Sjp161948 * This product includes cryptographic software written by Eric Young 51*2139Sjp161948 * (eay@cryptsoft.com). This product includes software written by Tim 52*2139Sjp161948 * Hudson (tjh@cryptsoft.com). 53*2139Sjp161948 * 54*2139Sjp161948 */ 550Sstevel@tonic-gate /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 560Sstevel@tonic-gate * All rights reserved. 570Sstevel@tonic-gate * 580Sstevel@tonic-gate * This package is an SSL implementation written 590Sstevel@tonic-gate * by Eric Young (eay@cryptsoft.com). 600Sstevel@tonic-gate * The implementation was written so as to conform with Netscapes SSL. 610Sstevel@tonic-gate * 620Sstevel@tonic-gate * This library is free for commercial and non-commercial use as long as 630Sstevel@tonic-gate * the following conditions are aheared to. The following conditions 640Sstevel@tonic-gate * apply to all code found in this distribution, be it the RC4, RSA, 650Sstevel@tonic-gate * lhash, DES, etc., code; not just the SSL code. The SSL documentation 660Sstevel@tonic-gate * included with this distribution is covered by the same copyright terms 670Sstevel@tonic-gate * except that the holder is Tim Hudson (tjh@cryptsoft.com). 680Sstevel@tonic-gate * 690Sstevel@tonic-gate * Copyright remains Eric Young's, and as such any Copyright notices in 700Sstevel@tonic-gate * the code are not to be removed. 710Sstevel@tonic-gate * If this package is used in a product, Eric Young should be given attribution 720Sstevel@tonic-gate * as the author of the parts of the library used. 730Sstevel@tonic-gate * This can be in the form of a textual message at program startup or 740Sstevel@tonic-gate * in documentation (online or textual) provided with the package. 750Sstevel@tonic-gate * 760Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without 770Sstevel@tonic-gate * modification, are permitted provided that the following conditions 780Sstevel@tonic-gate * are met: 790Sstevel@tonic-gate * 1. Redistributions of source code must retain the copyright 800Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer. 810Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright 820Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in the 830Sstevel@tonic-gate * documentation and/or other materials provided with the distribution. 840Sstevel@tonic-gate * 3. All advertising materials mentioning features or use of this software 850Sstevel@tonic-gate * must display the following acknowledgement: 860Sstevel@tonic-gate * "This product includes cryptographic software written by 870Sstevel@tonic-gate * Eric Young (eay@cryptsoft.com)" 880Sstevel@tonic-gate * The word 'cryptographic' can be left out if the rouines from the library 890Sstevel@tonic-gate * being used are not cryptographic related :-). 900Sstevel@tonic-gate * 4. If you include any Windows specific code (or a derivative thereof) from 910Sstevel@tonic-gate * the apps directory (application code) you must include an acknowledgement: 920Sstevel@tonic-gate * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 930Sstevel@tonic-gate * 940Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 950Sstevel@tonic-gate * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 960Sstevel@tonic-gate * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 970Sstevel@tonic-gate * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 980Sstevel@tonic-gate * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 990Sstevel@tonic-gate * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 1000Sstevel@tonic-gate * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 1010Sstevel@tonic-gate * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 1020Sstevel@tonic-gate * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 1030Sstevel@tonic-gate * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 1040Sstevel@tonic-gate * SUCH DAMAGE. 1050Sstevel@tonic-gate * 1060Sstevel@tonic-gate * The licence and distribution terms for any publically available version or 1070Sstevel@tonic-gate * derivative of this code cannot be changed. i.e. this code cannot simply be 1080Sstevel@tonic-gate * copied and put under another distribution licence 1090Sstevel@tonic-gate * [including the GNU Public Licence.] 1100Sstevel@tonic-gate */ 111*2139Sjp161948 /* ==================================================================== 112*2139Sjp161948 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. 113*2139Sjp161948 * ECDH support in OpenSSL originally developed by 114*2139Sjp161948 * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. 115*2139Sjp161948 */ 1160Sstevel@tonic-gate 1170Sstevel@tonic-gate #ifndef HEADER_CRYPTO_H 1180Sstevel@tonic-gate #define HEADER_CRYPTO_H 1190Sstevel@tonic-gate 1200Sstevel@tonic-gate #include <stdlib.h> 1210Sstevel@tonic-gate 122*2139Sjp161948 #include <openssl/e_os2.h> 123*2139Sjp161948 1240Sstevel@tonic-gate #ifndef OPENSSL_NO_FP_API 1250Sstevel@tonic-gate #include <stdio.h> 1260Sstevel@tonic-gate #endif 1270Sstevel@tonic-gate 1280Sstevel@tonic-gate #include <openssl/stack.h> 1290Sstevel@tonic-gate #include <openssl/safestack.h> 1300Sstevel@tonic-gate #include <openssl/opensslv.h> 131*2139Sjp161948 #include <openssl/ossl_typ.h> 1320Sstevel@tonic-gate 1330Sstevel@tonic-gate #ifdef CHARSET_EBCDIC 1340Sstevel@tonic-gate #include <openssl/ebcdic.h> 1350Sstevel@tonic-gate #endif 1360Sstevel@tonic-gate 1370Sstevel@tonic-gate /* Resolve problems on some operating systems with symbol names that clash 1380Sstevel@tonic-gate one way or another */ 1390Sstevel@tonic-gate #include <openssl/symhacks.h> 1400Sstevel@tonic-gate 1410Sstevel@tonic-gate #ifdef __cplusplus 1420Sstevel@tonic-gate extern "C" { 1430Sstevel@tonic-gate #endif 1440Sstevel@tonic-gate 1450Sstevel@tonic-gate /* Backward compatibility to SSLeay */ 1460Sstevel@tonic-gate /* This is more to be used to check the correct DLL is being used 1470Sstevel@tonic-gate * in the MS world. */ 1480Sstevel@tonic-gate #define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER 1490Sstevel@tonic-gate #define SSLEAY_VERSION 0 1500Sstevel@tonic-gate /* #define SSLEAY_OPTIONS 1 no longer supported */ 1510Sstevel@tonic-gate #define SSLEAY_CFLAGS 2 1520Sstevel@tonic-gate #define SSLEAY_BUILT_ON 3 1530Sstevel@tonic-gate #define SSLEAY_PLATFORM 4 1540Sstevel@tonic-gate #define SSLEAY_DIR 5 1550Sstevel@tonic-gate 156*2139Sjp161948 /* Already declared in ossl_typ.h */ 157*2139Sjp161948 #if 0 158*2139Sjp161948 typedef struct crypto_ex_data_st CRYPTO_EX_DATA; 159*2139Sjp161948 /* Called when a new object is created */ 160*2139Sjp161948 typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad, 161*2139Sjp161948 int idx, long argl, void *argp); 162*2139Sjp161948 /* Called when an object is free()ed */ 163*2139Sjp161948 typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad, 164*2139Sjp161948 int idx, long argl, void *argp); 165*2139Sjp161948 /* Called when we need to dup an object */ 166*2139Sjp161948 typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d, 167*2139Sjp161948 int idx, long argl, void *argp); 168*2139Sjp161948 #endif 169*2139Sjp161948 170*2139Sjp161948 /* A generic structure to pass assorted data in a expandable way */ 171*2139Sjp161948 typedef struct openssl_item_st 172*2139Sjp161948 { 173*2139Sjp161948 int code; 174*2139Sjp161948 void *value; /* Not used for flag attributes */ 175*2139Sjp161948 size_t value_size; /* Max size of value for output, length for input */ 176*2139Sjp161948 size_t *value_length; /* Returned length of value for output */ 177*2139Sjp161948 } OPENSSL_ITEM; 178*2139Sjp161948 179*2139Sjp161948 1800Sstevel@tonic-gate /* When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock 1810Sstevel@tonic-gate * names in cryptlib.c 1820Sstevel@tonic-gate */ 1830Sstevel@tonic-gate 184*2139Sjp161948 #define CRYPTO_LOCK_ERR 1 185*2139Sjp161948 #define CRYPTO_LOCK_EX_DATA 2 186*2139Sjp161948 #define CRYPTO_LOCK_X509 3 187*2139Sjp161948 #define CRYPTO_LOCK_X509_INFO 4 188*2139Sjp161948 #define CRYPTO_LOCK_X509_PKEY 5 1890Sstevel@tonic-gate #define CRYPTO_LOCK_X509_CRL 6 1900Sstevel@tonic-gate #define CRYPTO_LOCK_X509_REQ 7 1910Sstevel@tonic-gate #define CRYPTO_LOCK_DSA 8 1920Sstevel@tonic-gate #define CRYPTO_LOCK_RSA 9 1930Sstevel@tonic-gate #define CRYPTO_LOCK_EVP_PKEY 10 1940Sstevel@tonic-gate #define CRYPTO_LOCK_X509_STORE 11 1950Sstevel@tonic-gate #define CRYPTO_LOCK_SSL_CTX 12 1960Sstevel@tonic-gate #define CRYPTO_LOCK_SSL_CERT 13 1970Sstevel@tonic-gate #define CRYPTO_LOCK_SSL_SESSION 14 1980Sstevel@tonic-gate #define CRYPTO_LOCK_SSL_SESS_CERT 15 1990Sstevel@tonic-gate #define CRYPTO_LOCK_SSL 16 2000Sstevel@tonic-gate #define CRYPTO_LOCK_SSL_METHOD 17 2010Sstevel@tonic-gate #define CRYPTO_LOCK_RAND 18 2020Sstevel@tonic-gate #define CRYPTO_LOCK_RAND2 19 2030Sstevel@tonic-gate #define CRYPTO_LOCK_MALLOC 20 2040Sstevel@tonic-gate #define CRYPTO_LOCK_BIO 21 2050Sstevel@tonic-gate #define CRYPTO_LOCK_GETHOSTBYNAME 22 2060Sstevel@tonic-gate #define CRYPTO_LOCK_GETSERVBYNAME 23 2070Sstevel@tonic-gate #define CRYPTO_LOCK_READDIR 24 2080Sstevel@tonic-gate #define CRYPTO_LOCK_RSA_BLINDING 25 2090Sstevel@tonic-gate #define CRYPTO_LOCK_DH 26 2100Sstevel@tonic-gate #define CRYPTO_LOCK_MALLOC2 27 2110Sstevel@tonic-gate #define CRYPTO_LOCK_DSO 28 2120Sstevel@tonic-gate #define CRYPTO_LOCK_DYNLOCK 29 2130Sstevel@tonic-gate #define CRYPTO_LOCK_ENGINE 30 2140Sstevel@tonic-gate #define CRYPTO_LOCK_UI 31 215*2139Sjp161948 #define CRYPTO_LOCK_ECDSA 32 216*2139Sjp161948 #define CRYPTO_LOCK_EC 33 217*2139Sjp161948 #define CRYPTO_LOCK_ECDH 34 218*2139Sjp161948 #define CRYPTO_LOCK_BN 35 219*2139Sjp161948 #define CRYPTO_LOCK_EC_PRE_COMP 36 220*2139Sjp161948 #define CRYPTO_LOCK_STORE 37 221*2139Sjp161948 #define CRYPTO_LOCK_COMP 38 222*2139Sjp161948 #define CRYPTO_NUM_LOCKS 39 2230Sstevel@tonic-gate 2240Sstevel@tonic-gate #define CRYPTO_LOCK 1 2250Sstevel@tonic-gate #define CRYPTO_UNLOCK 2 2260Sstevel@tonic-gate #define CRYPTO_READ 4 2270Sstevel@tonic-gate #define CRYPTO_WRITE 8 2280Sstevel@tonic-gate 2290Sstevel@tonic-gate #ifndef OPENSSL_NO_LOCKING 2300Sstevel@tonic-gate #ifndef CRYPTO_w_lock 2310Sstevel@tonic-gate #define CRYPTO_w_lock(type) \ 2320Sstevel@tonic-gate CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__) 2330Sstevel@tonic-gate #define CRYPTO_w_unlock(type) \ 2340Sstevel@tonic-gate CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__) 2350Sstevel@tonic-gate #define CRYPTO_r_lock(type) \ 2360Sstevel@tonic-gate CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__) 2370Sstevel@tonic-gate #define CRYPTO_r_unlock(type) \ 2380Sstevel@tonic-gate CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__) 2390Sstevel@tonic-gate #define CRYPTO_add(addr,amount,type) \ 2400Sstevel@tonic-gate CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__) 2410Sstevel@tonic-gate #endif 2420Sstevel@tonic-gate #else 2430Sstevel@tonic-gate #define CRYPTO_w_lock(a) 2440Sstevel@tonic-gate #define CRYPTO_w_unlock(a) 2450Sstevel@tonic-gate #define CRYPTO_r_lock(a) 2460Sstevel@tonic-gate #define CRYPTO_r_unlock(a) 2470Sstevel@tonic-gate #define CRYPTO_add(a,b,c) ((*(a))+=(b)) 2480Sstevel@tonic-gate #endif 2490Sstevel@tonic-gate 2500Sstevel@tonic-gate /* Some applications as well as some parts of OpenSSL need to allocate 2510Sstevel@tonic-gate and deallocate locks in a dynamic fashion. The following typedef 2520Sstevel@tonic-gate makes this possible in a type-safe manner. */ 2530Sstevel@tonic-gate /* struct CRYPTO_dynlock_value has to be defined by the application. */ 2540Sstevel@tonic-gate typedef struct 2550Sstevel@tonic-gate { 2560Sstevel@tonic-gate int references; 2570Sstevel@tonic-gate struct CRYPTO_dynlock_value *data; 2580Sstevel@tonic-gate } CRYPTO_dynlock; 2590Sstevel@tonic-gate 2600Sstevel@tonic-gate 2610Sstevel@tonic-gate /* The following can be used to detect memory leaks in the SSLeay library. 2620Sstevel@tonic-gate * It used, it turns on malloc checking */ 2630Sstevel@tonic-gate 2640Sstevel@tonic-gate #define CRYPTO_MEM_CHECK_OFF 0x0 /* an enume */ 2650Sstevel@tonic-gate #define CRYPTO_MEM_CHECK_ON 0x1 /* a bit */ 2660Sstevel@tonic-gate #define CRYPTO_MEM_CHECK_ENABLE 0x2 /* a bit */ 2670Sstevel@tonic-gate #define CRYPTO_MEM_CHECK_DISABLE 0x3 /* an enume */ 2680Sstevel@tonic-gate 2690Sstevel@tonic-gate /* The following are bit values to turn on or off options connected to the 2700Sstevel@tonic-gate * malloc checking functionality */ 2710Sstevel@tonic-gate 2720Sstevel@tonic-gate /* Adds time to the memory checking information */ 2730Sstevel@tonic-gate #define V_CRYPTO_MDEBUG_TIME 0x1 /* a bit */ 2740Sstevel@tonic-gate /* Adds thread number to the memory checking information */ 2750Sstevel@tonic-gate #define V_CRYPTO_MDEBUG_THREAD 0x2 /* a bit */ 2760Sstevel@tonic-gate 2770Sstevel@tonic-gate #define V_CRYPTO_MDEBUG_ALL (V_CRYPTO_MDEBUG_TIME | V_CRYPTO_MDEBUG_THREAD) 2780Sstevel@tonic-gate 2790Sstevel@tonic-gate 2800Sstevel@tonic-gate /* predec of the BIO type */ 2810Sstevel@tonic-gate typedef struct bio_st BIO_dummy; 2820Sstevel@tonic-gate 283*2139Sjp161948 struct crypto_ex_data_st 2840Sstevel@tonic-gate { 2850Sstevel@tonic-gate STACK *sk; 2860Sstevel@tonic-gate int dummy; /* gcc is screwing up this data structure :-( */ 287*2139Sjp161948 }; 2880Sstevel@tonic-gate 2890Sstevel@tonic-gate /* This stuff is basically class callback functions 2900Sstevel@tonic-gate * The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more */ 2910Sstevel@tonic-gate 2920Sstevel@tonic-gate typedef struct crypto_ex_data_func_st 2930Sstevel@tonic-gate { 2940Sstevel@tonic-gate long argl; /* Arbitary long */ 2950Sstevel@tonic-gate void *argp; /* Arbitary void * */ 2960Sstevel@tonic-gate CRYPTO_EX_new *new_func; 2970Sstevel@tonic-gate CRYPTO_EX_free *free_func; 2980Sstevel@tonic-gate CRYPTO_EX_dup *dup_func; 2990Sstevel@tonic-gate } CRYPTO_EX_DATA_FUNCS; 3000Sstevel@tonic-gate 3010Sstevel@tonic-gate DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS) 3020Sstevel@tonic-gate 3030Sstevel@tonic-gate /* Per class, we have a STACK of CRYPTO_EX_DATA_FUNCS for each CRYPTO_EX_DATA 3040Sstevel@tonic-gate * entry. 3050Sstevel@tonic-gate */ 3060Sstevel@tonic-gate 3070Sstevel@tonic-gate #define CRYPTO_EX_INDEX_BIO 0 3080Sstevel@tonic-gate #define CRYPTO_EX_INDEX_SSL 1 3090Sstevel@tonic-gate #define CRYPTO_EX_INDEX_SSL_CTX 2 3100Sstevel@tonic-gate #define CRYPTO_EX_INDEX_SSL_SESSION 3 3110Sstevel@tonic-gate #define CRYPTO_EX_INDEX_X509_STORE 4 3120Sstevel@tonic-gate #define CRYPTO_EX_INDEX_X509_STORE_CTX 5 3130Sstevel@tonic-gate #define CRYPTO_EX_INDEX_RSA 6 3140Sstevel@tonic-gate #define CRYPTO_EX_INDEX_DSA 7 3150Sstevel@tonic-gate #define CRYPTO_EX_INDEX_DH 8 3160Sstevel@tonic-gate #define CRYPTO_EX_INDEX_ENGINE 9 3170Sstevel@tonic-gate #define CRYPTO_EX_INDEX_X509 10 3180Sstevel@tonic-gate #define CRYPTO_EX_INDEX_UI 11 319*2139Sjp161948 #define CRYPTO_EX_INDEX_ECDSA 12 320*2139Sjp161948 #define CRYPTO_EX_INDEX_ECDH 13 321*2139Sjp161948 #define CRYPTO_EX_INDEX_COMP 14 322*2139Sjp161948 #define CRYPTO_EX_INDEX_STORE 15 3230Sstevel@tonic-gate 3240Sstevel@tonic-gate /* Dynamically assigned indexes start from this value (don't use directly, use 3250Sstevel@tonic-gate * via CRYPTO_ex_data_new_class). */ 3260Sstevel@tonic-gate #define CRYPTO_EX_INDEX_USER 100 3270Sstevel@tonic-gate 3280Sstevel@tonic-gate 3290Sstevel@tonic-gate /* This is the default callbacks, but we can have others as well: 3300Sstevel@tonic-gate * this is needed in Win32 where the application malloc and the 3310Sstevel@tonic-gate * library malloc may not be the same. 3320Sstevel@tonic-gate */ 3330Sstevel@tonic-gate #define CRYPTO_malloc_init() CRYPTO_set_mem_functions(\ 3340Sstevel@tonic-gate malloc, realloc, free) 3350Sstevel@tonic-gate 3360Sstevel@tonic-gate #if defined CRYPTO_MDEBUG_ALL || defined CRYPTO_MDEBUG_TIME || defined CRYPTO_MDEBUG_THREAD 3370Sstevel@tonic-gate # ifndef CRYPTO_MDEBUG /* avoid duplicate #define */ 3380Sstevel@tonic-gate # define CRYPTO_MDEBUG 3390Sstevel@tonic-gate # endif 3400Sstevel@tonic-gate #endif 3410Sstevel@tonic-gate 3420Sstevel@tonic-gate /* Set standard debugging functions (not done by default 3430Sstevel@tonic-gate * unless CRYPTO_MDEBUG is defined) */ 3440Sstevel@tonic-gate #define CRYPTO_malloc_debug_init() do {\ 3450Sstevel@tonic-gate CRYPTO_set_mem_debug_functions(\ 3460Sstevel@tonic-gate CRYPTO_dbg_malloc,\ 3470Sstevel@tonic-gate CRYPTO_dbg_realloc,\ 3480Sstevel@tonic-gate CRYPTO_dbg_free,\ 3490Sstevel@tonic-gate CRYPTO_dbg_set_options,\ 3500Sstevel@tonic-gate CRYPTO_dbg_get_options);\ 3510Sstevel@tonic-gate } while(0) 3520Sstevel@tonic-gate 3530Sstevel@tonic-gate int CRYPTO_mem_ctrl(int mode); 3540Sstevel@tonic-gate int CRYPTO_is_mem_check_on(void); 3550Sstevel@tonic-gate 3560Sstevel@tonic-gate /* for applications */ 3570Sstevel@tonic-gate #define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON) 3580Sstevel@tonic-gate #define MemCheck_stop() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF) 3590Sstevel@tonic-gate 3600Sstevel@tonic-gate /* for library-internal use */ 3610Sstevel@tonic-gate #define MemCheck_on() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE) 3620Sstevel@tonic-gate #define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE) 3630Sstevel@tonic-gate #define is_MemCheck_on() CRYPTO_is_mem_check_on() 3640Sstevel@tonic-gate 3650Sstevel@tonic-gate #define OPENSSL_malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__) 3660Sstevel@tonic-gate #define OPENSSL_realloc(addr,num) \ 3670Sstevel@tonic-gate CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__) 3680Sstevel@tonic-gate #define OPENSSL_realloc_clean(addr,old_num,num) \ 3690Sstevel@tonic-gate CRYPTO_realloc_clean(addr,old_num,num,__FILE__,__LINE__) 3700Sstevel@tonic-gate #define OPENSSL_remalloc(addr,num) \ 3710Sstevel@tonic-gate CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__) 3720Sstevel@tonic-gate #define OPENSSL_freeFunc CRYPTO_free 3730Sstevel@tonic-gate #define OPENSSL_free(addr) CRYPTO_free(addr) 3740Sstevel@tonic-gate 3750Sstevel@tonic-gate #define OPENSSL_malloc_locked(num) \ 3760Sstevel@tonic-gate CRYPTO_malloc_locked((int)num,__FILE__,__LINE__) 3770Sstevel@tonic-gate #define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr) 3780Sstevel@tonic-gate 3790Sstevel@tonic-gate 3800Sstevel@tonic-gate const char *SSLeay_version(int type); 3810Sstevel@tonic-gate unsigned long SSLeay(void); 3820Sstevel@tonic-gate 3830Sstevel@tonic-gate int OPENSSL_issetugid(void); 3840Sstevel@tonic-gate 3850Sstevel@tonic-gate /* An opaque type representing an implementation of "ex_data" support */ 3860Sstevel@tonic-gate typedef struct st_CRYPTO_EX_DATA_IMPL CRYPTO_EX_DATA_IMPL; 3870Sstevel@tonic-gate /* Return an opaque pointer to the current "ex_data" implementation */ 3880Sstevel@tonic-gate const CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void); 3890Sstevel@tonic-gate /* Sets the "ex_data" implementation to be used (if it's not too late) */ 3900Sstevel@tonic-gate int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i); 3910Sstevel@tonic-gate /* Get a new "ex_data" class, and return the corresponding "class_index" */ 3920Sstevel@tonic-gate int CRYPTO_ex_data_new_class(void); 3930Sstevel@tonic-gate /* Within a given class, get/register a new index */ 3940Sstevel@tonic-gate int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp, 3950Sstevel@tonic-gate CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, 3960Sstevel@tonic-gate CRYPTO_EX_free *free_func); 3970Sstevel@tonic-gate /* Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a given 3980Sstevel@tonic-gate * class (invokes whatever per-class callbacks are applicable) */ 3990Sstevel@tonic-gate int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); 4000Sstevel@tonic-gate int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, 4010Sstevel@tonic-gate CRYPTO_EX_DATA *from); 4020Sstevel@tonic-gate void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); 4030Sstevel@tonic-gate /* Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular index 4040Sstevel@tonic-gate * (relative to the class type involved) */ 4050Sstevel@tonic-gate int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val); 4060Sstevel@tonic-gate void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad,int idx); 4070Sstevel@tonic-gate /* This function cleans up all "ex_data" state. It mustn't be called under 4080Sstevel@tonic-gate * potential race-conditions. */ 4090Sstevel@tonic-gate void CRYPTO_cleanup_all_ex_data(void); 4100Sstevel@tonic-gate 4110Sstevel@tonic-gate int CRYPTO_get_new_lockid(char *name); 4120Sstevel@tonic-gate 4130Sstevel@tonic-gate int CRYPTO_num_locks(void); /* return CRYPTO_NUM_LOCKS (shared libs!) */ 4140Sstevel@tonic-gate void CRYPTO_lock(int mode, int type,const char *file,int line); 4150Sstevel@tonic-gate void CRYPTO_set_locking_callback(void (*func)(int mode,int type, 4160Sstevel@tonic-gate const char *file,int line)); 4170Sstevel@tonic-gate void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char *file, 4180Sstevel@tonic-gate int line); 4190Sstevel@tonic-gate void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type, 4200Sstevel@tonic-gate const char *file, int line)); 4210Sstevel@tonic-gate int (*CRYPTO_get_add_lock_callback(void))(int *num,int mount,int type, 4220Sstevel@tonic-gate const char *file,int line); 4230Sstevel@tonic-gate void CRYPTO_set_id_callback(unsigned long (*func)(void)); 4240Sstevel@tonic-gate unsigned long (*CRYPTO_get_id_callback(void))(void); 4250Sstevel@tonic-gate unsigned long CRYPTO_thread_id(void); 4260Sstevel@tonic-gate const char *CRYPTO_get_lock_name(int type); 4270Sstevel@tonic-gate int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file, 4280Sstevel@tonic-gate int line); 4290Sstevel@tonic-gate 4300Sstevel@tonic-gate int CRYPTO_get_new_dynlockid(void); 4310Sstevel@tonic-gate void CRYPTO_destroy_dynlockid(int i); 4320Sstevel@tonic-gate struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i); 4330Sstevel@tonic-gate void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*dyn_create_function)(const char *file, int line)); 4340Sstevel@tonic-gate void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line)); 4350Sstevel@tonic-gate void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)(struct CRYPTO_dynlock_value *l, const char *file, int line)); 4360Sstevel@tonic-gate struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))(const char *file,int line); 4370Sstevel@tonic-gate void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, struct CRYPTO_dynlock_value *l, const char *file,int line); 4380Sstevel@tonic-gate void (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l, const char *file,int line); 4390Sstevel@tonic-gate 4400Sstevel@tonic-gate /* CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions -- 4410Sstevel@tonic-gate * call the latter last if you need different functions */ 4420Sstevel@tonic-gate int CRYPTO_set_mem_functions(void *(*m)(size_t),void *(*r)(void *,size_t), void (*f)(void *)); 4430Sstevel@tonic-gate int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*free_func)(void *)); 4440Sstevel@tonic-gate int CRYPTO_set_mem_ex_functions(void *(*m)(size_t,const char *,int), 4450Sstevel@tonic-gate void *(*r)(void *,size_t,const char *,int), 4460Sstevel@tonic-gate void (*f)(void *)); 4470Sstevel@tonic-gate int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t,const char *,int), 4480Sstevel@tonic-gate void (*free_func)(void *)); 4490Sstevel@tonic-gate int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int), 4500Sstevel@tonic-gate void (*r)(void *,void *,int,const char *,int,int), 4510Sstevel@tonic-gate void (*f)(void *,int), 4520Sstevel@tonic-gate void (*so)(long), 4530Sstevel@tonic-gate long (*go)(void)); 4540Sstevel@tonic-gate void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), void (**f)(void *)); 4550Sstevel@tonic-gate void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *)); 4560Sstevel@tonic-gate void CRYPTO_get_mem_ex_functions(void *(**m)(size_t,const char *,int), 4570Sstevel@tonic-gate void *(**r)(void *, size_t,const char *,int), 4580Sstevel@tonic-gate void (**f)(void *)); 4590Sstevel@tonic-gate void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t,const char *,int), 4600Sstevel@tonic-gate void (**f)(void *)); 4610Sstevel@tonic-gate void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int), 4620Sstevel@tonic-gate void (**r)(void *,void *,int,const char *,int,int), 4630Sstevel@tonic-gate void (**f)(void *,int), 4640Sstevel@tonic-gate void (**so)(long), 4650Sstevel@tonic-gate long (**go)(void)); 4660Sstevel@tonic-gate 4670Sstevel@tonic-gate void *CRYPTO_malloc_locked(int num, const char *file, int line); 4680Sstevel@tonic-gate void CRYPTO_free_locked(void *); 4690Sstevel@tonic-gate void *CRYPTO_malloc(int num, const char *file, int line); 4700Sstevel@tonic-gate void CRYPTO_free(void *); 4710Sstevel@tonic-gate void *CRYPTO_realloc(void *addr,int num, const char *file, int line); 4720Sstevel@tonic-gate void *CRYPTO_realloc_clean(void *addr,int old_num,int num,const char *file, 4730Sstevel@tonic-gate int line); 4740Sstevel@tonic-gate void *CRYPTO_remalloc(void *addr,int num, const char *file, int line); 4750Sstevel@tonic-gate 4760Sstevel@tonic-gate void OPENSSL_cleanse(void *ptr, size_t len); 4770Sstevel@tonic-gate 4780Sstevel@tonic-gate void CRYPTO_set_mem_debug_options(long bits); 4790Sstevel@tonic-gate long CRYPTO_get_mem_debug_options(void); 4800Sstevel@tonic-gate 4810Sstevel@tonic-gate #define CRYPTO_push_info(info) \ 4820Sstevel@tonic-gate CRYPTO_push_info_(info, __FILE__, __LINE__); 4830Sstevel@tonic-gate int CRYPTO_push_info_(const char *info, const char *file, int line); 4840Sstevel@tonic-gate int CRYPTO_pop_info(void); 4850Sstevel@tonic-gate int CRYPTO_remove_all_info(void); 4860Sstevel@tonic-gate 4870Sstevel@tonic-gate 4880Sstevel@tonic-gate /* Default debugging functions (enabled by CRYPTO_malloc_debug_init() macro; 4890Sstevel@tonic-gate * used as default in CRYPTO_MDEBUG compilations): */ 4900Sstevel@tonic-gate /* The last argument has the following significance: 4910Sstevel@tonic-gate * 4920Sstevel@tonic-gate * 0: called before the actual memory allocation has taken place 4930Sstevel@tonic-gate * 1: called after the actual memory allocation has taken place 4940Sstevel@tonic-gate */ 4950Sstevel@tonic-gate void CRYPTO_dbg_malloc(void *addr,int num,const char *file,int line,int before_p); 4960Sstevel@tonic-gate void CRYPTO_dbg_realloc(void *addr1,void *addr2,int num,const char *file,int line,int before_p); 4970Sstevel@tonic-gate void CRYPTO_dbg_free(void *addr,int before_p); 4980Sstevel@tonic-gate /* Tell the debugging code about options. By default, the following values 4990Sstevel@tonic-gate * apply: 5000Sstevel@tonic-gate * 5010Sstevel@tonic-gate * 0: Clear all options. 5020Sstevel@tonic-gate * V_CRYPTO_MDEBUG_TIME (1): Set the "Show Time" option. 5030Sstevel@tonic-gate * V_CRYPTO_MDEBUG_THREAD (2): Set the "Show Thread Number" option. 5040Sstevel@tonic-gate * V_CRYPTO_MDEBUG_ALL (3): 1 + 2 5050Sstevel@tonic-gate */ 5060Sstevel@tonic-gate void CRYPTO_dbg_set_options(long bits); 5070Sstevel@tonic-gate long CRYPTO_dbg_get_options(void); 5080Sstevel@tonic-gate 5090Sstevel@tonic-gate 5100Sstevel@tonic-gate #ifndef OPENSSL_NO_FP_API 5110Sstevel@tonic-gate void CRYPTO_mem_leaks_fp(FILE *); 5120Sstevel@tonic-gate #endif 5130Sstevel@tonic-gate void CRYPTO_mem_leaks(struct bio_st *bio); 5140Sstevel@tonic-gate /* unsigned long order, char *file, int line, int num_bytes, char *addr */ 5150Sstevel@tonic-gate typedef void *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *); 5160Sstevel@tonic-gate void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb); 5170Sstevel@tonic-gate 5180Sstevel@tonic-gate /* die if we have to */ 5190Sstevel@tonic-gate void OpenSSLDie(const char *file,int line,const char *assertion); 520*2139Sjp161948 #define OPENSSL_assert(e) (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1)) 521*2139Sjp161948 522*2139Sjp161948 unsigned long *OPENSSL_ia32cap_loc(void); 523*2139Sjp161948 #define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc())) 5240Sstevel@tonic-gate 5250Sstevel@tonic-gate /* BEGIN ERROR CODES */ 5260Sstevel@tonic-gate /* The following lines are auto generated by the script mkerr.pl. Any changes 5270Sstevel@tonic-gate * made after this point may be overwritten when the script is next run. 5280Sstevel@tonic-gate */ 5290Sstevel@tonic-gate void ERR_load_CRYPTO_strings(void); 5300Sstevel@tonic-gate 5310Sstevel@tonic-gate /* Error codes for the CRYPTO functions. */ 5320Sstevel@tonic-gate 5330Sstevel@tonic-gate /* Function codes. */ 5340Sstevel@tonic-gate #define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 100 5350Sstevel@tonic-gate #define CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID 103 5360Sstevel@tonic-gate #define CRYPTO_F_CRYPTO_GET_NEW_LOCKID 101 5370Sstevel@tonic-gate #define CRYPTO_F_CRYPTO_SET_EX_DATA 102 5380Sstevel@tonic-gate #define CRYPTO_F_DEF_ADD_INDEX 104 5390Sstevel@tonic-gate #define CRYPTO_F_DEF_GET_CLASS 105 5400Sstevel@tonic-gate #define CRYPTO_F_INT_DUP_EX_DATA 106 5410Sstevel@tonic-gate #define CRYPTO_F_INT_FREE_EX_DATA 107 5420Sstevel@tonic-gate #define CRYPTO_F_INT_NEW_EX_DATA 108 5430Sstevel@tonic-gate 5440Sstevel@tonic-gate /* Reason codes. */ 5450Sstevel@tonic-gate #define CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK 100 5460Sstevel@tonic-gate 5470Sstevel@tonic-gate #ifdef __cplusplus 5480Sstevel@tonic-gate } 5490Sstevel@tonic-gate #endif 5500Sstevel@tonic-gate #endif 551