xref: /onnv-gate/usr/src/common/openssl/crypto/crypto.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /* crypto/crypto.h */
2*0Sstevel@tonic-gate /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3*0Sstevel@tonic-gate  * All rights reserved.
4*0Sstevel@tonic-gate  *
5*0Sstevel@tonic-gate  * This package is an SSL implementation written
6*0Sstevel@tonic-gate  * by Eric Young (eay@cryptsoft.com).
7*0Sstevel@tonic-gate  * The implementation was written so as to conform with Netscapes SSL.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * This library is free for commercial and non-commercial use as long as
10*0Sstevel@tonic-gate  * the following conditions are aheared to.  The following conditions
11*0Sstevel@tonic-gate  * apply to all code found in this distribution, be it the RC4, RSA,
12*0Sstevel@tonic-gate  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
13*0Sstevel@tonic-gate  * included with this distribution is covered by the same copyright terms
14*0Sstevel@tonic-gate  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15*0Sstevel@tonic-gate  *
16*0Sstevel@tonic-gate  * Copyright remains Eric Young's, and as such any Copyright notices in
17*0Sstevel@tonic-gate  * the code are not to be removed.
18*0Sstevel@tonic-gate  * If this package is used in a product, Eric Young should be given attribution
19*0Sstevel@tonic-gate  * as the author of the parts of the library used.
20*0Sstevel@tonic-gate  * This can be in the form of a textual message at program startup or
21*0Sstevel@tonic-gate  * in documentation (online or textual) provided with the package.
22*0Sstevel@tonic-gate  *
23*0Sstevel@tonic-gate  * Redistribution and use in source and binary forms, with or without
24*0Sstevel@tonic-gate  * modification, are permitted provided that the following conditions
25*0Sstevel@tonic-gate  * are met:
26*0Sstevel@tonic-gate  * 1. Redistributions of source code must retain the copyright
27*0Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer.
28*0Sstevel@tonic-gate  * 2. Redistributions in binary form must reproduce the above copyright
29*0Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer in the
30*0Sstevel@tonic-gate  *    documentation and/or other materials provided with the distribution.
31*0Sstevel@tonic-gate  * 3. All advertising materials mentioning features or use of this software
32*0Sstevel@tonic-gate  *    must display the following acknowledgement:
33*0Sstevel@tonic-gate  *    "This product includes cryptographic software written by
34*0Sstevel@tonic-gate  *     Eric Young (eay@cryptsoft.com)"
35*0Sstevel@tonic-gate  *    The word 'cryptographic' can be left out if the rouines from the library
36*0Sstevel@tonic-gate  *    being used are not cryptographic related :-).
37*0Sstevel@tonic-gate  * 4. If you include any Windows specific code (or a derivative thereof) from
38*0Sstevel@tonic-gate  *    the apps directory (application code) you must include an acknowledgement:
39*0Sstevel@tonic-gate  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40*0Sstevel@tonic-gate  *
41*0Sstevel@tonic-gate  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42*0Sstevel@tonic-gate  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43*0Sstevel@tonic-gate  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44*0Sstevel@tonic-gate  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45*0Sstevel@tonic-gate  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46*0Sstevel@tonic-gate  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47*0Sstevel@tonic-gate  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48*0Sstevel@tonic-gate  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49*0Sstevel@tonic-gate  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50*0Sstevel@tonic-gate  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51*0Sstevel@tonic-gate  * SUCH DAMAGE.
52*0Sstevel@tonic-gate  *
53*0Sstevel@tonic-gate  * The licence and distribution terms for any publically available version or
54*0Sstevel@tonic-gate  * derivative of this code cannot be changed.  i.e. this code cannot simply be
55*0Sstevel@tonic-gate  * copied and put under another distribution licence
56*0Sstevel@tonic-gate  * [including the GNU Public Licence.]
57*0Sstevel@tonic-gate  */
58*0Sstevel@tonic-gate 
59*0Sstevel@tonic-gate #ifndef HEADER_CRYPTO_H
60*0Sstevel@tonic-gate #define HEADER_CRYPTO_H
61*0Sstevel@tonic-gate 
62*0Sstevel@tonic-gate #include <stdlib.h>
63*0Sstevel@tonic-gate 
64*0Sstevel@tonic-gate #ifndef OPENSSL_NO_FP_API
65*0Sstevel@tonic-gate #include <stdio.h>
66*0Sstevel@tonic-gate #endif
67*0Sstevel@tonic-gate 
68*0Sstevel@tonic-gate #include <openssl/stack.h>
69*0Sstevel@tonic-gate #include <openssl/safestack.h>
70*0Sstevel@tonic-gate #include <openssl/opensslv.h>
71*0Sstevel@tonic-gate 
72*0Sstevel@tonic-gate #ifdef CHARSET_EBCDIC
73*0Sstevel@tonic-gate #include <openssl/ebcdic.h>
74*0Sstevel@tonic-gate #endif
75*0Sstevel@tonic-gate 
76*0Sstevel@tonic-gate /* Resolve problems on some operating systems with symbol names that clash
77*0Sstevel@tonic-gate    one way or another */
78*0Sstevel@tonic-gate #include <openssl/symhacks.h>
79*0Sstevel@tonic-gate 
80*0Sstevel@tonic-gate #ifdef  __cplusplus
81*0Sstevel@tonic-gate extern "C" {
82*0Sstevel@tonic-gate #endif
83*0Sstevel@tonic-gate 
84*0Sstevel@tonic-gate /* Backward compatibility to SSLeay */
85*0Sstevel@tonic-gate /* This is more to be used to check the correct DLL is being used
86*0Sstevel@tonic-gate  * in the MS world. */
87*0Sstevel@tonic-gate #define SSLEAY_VERSION_NUMBER	OPENSSL_VERSION_NUMBER
88*0Sstevel@tonic-gate #define SSLEAY_VERSION		0
89*0Sstevel@tonic-gate /* #define SSLEAY_OPTIONS	1 no longer supported */
90*0Sstevel@tonic-gate #define SSLEAY_CFLAGS		2
91*0Sstevel@tonic-gate #define SSLEAY_BUILT_ON		3
92*0Sstevel@tonic-gate #define SSLEAY_PLATFORM		4
93*0Sstevel@tonic-gate #define SSLEAY_DIR		5
94*0Sstevel@tonic-gate 
95*0Sstevel@tonic-gate /* When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock
96*0Sstevel@tonic-gate  * names in cryptlib.c
97*0Sstevel@tonic-gate  */
98*0Sstevel@tonic-gate 
99*0Sstevel@tonic-gate #define CRYPTO_LOCK_ERR			1
100*0Sstevel@tonic-gate #define CRYPTO_LOCK_EX_DATA		2
101*0Sstevel@tonic-gate #define CRYPTO_LOCK_X509		3
102*0Sstevel@tonic-gate #define CRYPTO_LOCK_X509_INFO		4
103*0Sstevel@tonic-gate #define CRYPTO_LOCK_X509_PKEY		5
104*0Sstevel@tonic-gate #define CRYPTO_LOCK_X509_CRL		6
105*0Sstevel@tonic-gate #define CRYPTO_LOCK_X509_REQ		7
106*0Sstevel@tonic-gate #define CRYPTO_LOCK_DSA			8
107*0Sstevel@tonic-gate #define CRYPTO_LOCK_RSA			9
108*0Sstevel@tonic-gate #define CRYPTO_LOCK_EVP_PKEY		10
109*0Sstevel@tonic-gate #define CRYPTO_LOCK_X509_STORE		11
110*0Sstevel@tonic-gate #define CRYPTO_LOCK_SSL_CTX		12
111*0Sstevel@tonic-gate #define CRYPTO_LOCK_SSL_CERT		13
112*0Sstevel@tonic-gate #define CRYPTO_LOCK_SSL_SESSION		14
113*0Sstevel@tonic-gate #define CRYPTO_LOCK_SSL_SESS_CERT	15
114*0Sstevel@tonic-gate #define CRYPTO_LOCK_SSL			16
115*0Sstevel@tonic-gate #define CRYPTO_LOCK_SSL_METHOD		17
116*0Sstevel@tonic-gate #define CRYPTO_LOCK_RAND		18
117*0Sstevel@tonic-gate #define CRYPTO_LOCK_RAND2		19
118*0Sstevel@tonic-gate #define CRYPTO_LOCK_MALLOC		20
119*0Sstevel@tonic-gate #define CRYPTO_LOCK_BIO			21
120*0Sstevel@tonic-gate #define CRYPTO_LOCK_GETHOSTBYNAME	22
121*0Sstevel@tonic-gate #define CRYPTO_LOCK_GETSERVBYNAME	23
122*0Sstevel@tonic-gate #define CRYPTO_LOCK_READDIR		24
123*0Sstevel@tonic-gate #define CRYPTO_LOCK_RSA_BLINDING	25
124*0Sstevel@tonic-gate #define CRYPTO_LOCK_DH			26
125*0Sstevel@tonic-gate #define CRYPTO_LOCK_MALLOC2		27
126*0Sstevel@tonic-gate #define CRYPTO_LOCK_DSO			28
127*0Sstevel@tonic-gate #define CRYPTO_LOCK_DYNLOCK		29
128*0Sstevel@tonic-gate #define CRYPTO_LOCK_ENGINE		30
129*0Sstevel@tonic-gate #define CRYPTO_LOCK_UI			31
130*0Sstevel@tonic-gate #define CRYPTO_LOCK_HWCRHK		32 /* This is a HACK which will disappear in 0.9.8 */
131*0Sstevel@tonic-gate #define CRYPTO_NUM_LOCKS		33
132*0Sstevel@tonic-gate 
133*0Sstevel@tonic-gate #define CRYPTO_LOCK		1
134*0Sstevel@tonic-gate #define CRYPTO_UNLOCK		2
135*0Sstevel@tonic-gate #define CRYPTO_READ		4
136*0Sstevel@tonic-gate #define CRYPTO_WRITE		8
137*0Sstevel@tonic-gate 
138*0Sstevel@tonic-gate #ifndef OPENSSL_NO_LOCKING
139*0Sstevel@tonic-gate #ifndef CRYPTO_w_lock
140*0Sstevel@tonic-gate #define CRYPTO_w_lock(type)	\
141*0Sstevel@tonic-gate 	CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
142*0Sstevel@tonic-gate #define CRYPTO_w_unlock(type)	\
143*0Sstevel@tonic-gate 	CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
144*0Sstevel@tonic-gate #define CRYPTO_r_lock(type)	\
145*0Sstevel@tonic-gate 	CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__)
146*0Sstevel@tonic-gate #define CRYPTO_r_unlock(type)	\
147*0Sstevel@tonic-gate 	CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__)
148*0Sstevel@tonic-gate #define CRYPTO_add(addr,amount,type)	\
149*0Sstevel@tonic-gate 	CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__)
150*0Sstevel@tonic-gate #endif
151*0Sstevel@tonic-gate #else
152*0Sstevel@tonic-gate #define CRYPTO_w_lock(a)
153*0Sstevel@tonic-gate #define CRYPTO_w_unlock(a)
154*0Sstevel@tonic-gate #define CRYPTO_r_lock(a)
155*0Sstevel@tonic-gate #define CRYPTO_r_unlock(a)
156*0Sstevel@tonic-gate #define CRYPTO_add(a,b,c)	((*(a))+=(b))
157*0Sstevel@tonic-gate #endif
158*0Sstevel@tonic-gate 
159*0Sstevel@tonic-gate /* Some applications as well as some parts of OpenSSL need to allocate
160*0Sstevel@tonic-gate    and deallocate locks in a dynamic fashion.  The following typedef
161*0Sstevel@tonic-gate    makes this possible in a type-safe manner.  */
162*0Sstevel@tonic-gate /* struct CRYPTO_dynlock_value has to be defined by the application. */
163*0Sstevel@tonic-gate typedef struct
164*0Sstevel@tonic-gate 	{
165*0Sstevel@tonic-gate 	int references;
166*0Sstevel@tonic-gate 	struct CRYPTO_dynlock_value *data;
167*0Sstevel@tonic-gate 	} CRYPTO_dynlock;
168*0Sstevel@tonic-gate 
169*0Sstevel@tonic-gate 
170*0Sstevel@tonic-gate /* The following can be used to detect memory leaks in the SSLeay library.
171*0Sstevel@tonic-gate  * It used, it turns on malloc checking */
172*0Sstevel@tonic-gate 
173*0Sstevel@tonic-gate #define CRYPTO_MEM_CHECK_OFF	0x0	/* an enume */
174*0Sstevel@tonic-gate #define CRYPTO_MEM_CHECK_ON	0x1	/* a bit */
175*0Sstevel@tonic-gate #define CRYPTO_MEM_CHECK_ENABLE	0x2	/* a bit */
176*0Sstevel@tonic-gate #define CRYPTO_MEM_CHECK_DISABLE 0x3	/* an enume */
177*0Sstevel@tonic-gate 
178*0Sstevel@tonic-gate /* The following are bit values to turn on or off options connected to the
179*0Sstevel@tonic-gate  * malloc checking functionality */
180*0Sstevel@tonic-gate 
181*0Sstevel@tonic-gate /* Adds time to the memory checking information */
182*0Sstevel@tonic-gate #define V_CRYPTO_MDEBUG_TIME	0x1 /* a bit */
183*0Sstevel@tonic-gate /* Adds thread number to the memory checking information */
184*0Sstevel@tonic-gate #define V_CRYPTO_MDEBUG_THREAD	0x2 /* a bit */
185*0Sstevel@tonic-gate 
186*0Sstevel@tonic-gate #define V_CRYPTO_MDEBUG_ALL (V_CRYPTO_MDEBUG_TIME | V_CRYPTO_MDEBUG_THREAD)
187*0Sstevel@tonic-gate 
188*0Sstevel@tonic-gate 
189*0Sstevel@tonic-gate /* predec of the BIO type */
190*0Sstevel@tonic-gate typedef struct bio_st BIO_dummy;
191*0Sstevel@tonic-gate 
192*0Sstevel@tonic-gate typedef struct crypto_ex_data_st
193*0Sstevel@tonic-gate 	{
194*0Sstevel@tonic-gate 	STACK *sk;
195*0Sstevel@tonic-gate 	int dummy; /* gcc is screwing up this data structure :-( */
196*0Sstevel@tonic-gate 	} CRYPTO_EX_DATA;
197*0Sstevel@tonic-gate 
198*0Sstevel@tonic-gate /* Called when a new object is created */
199*0Sstevel@tonic-gate typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
200*0Sstevel@tonic-gate 					int idx, long argl, void *argp);
201*0Sstevel@tonic-gate /* Called when an object is free()ed */
202*0Sstevel@tonic-gate typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
203*0Sstevel@tonic-gate 					int idx, long argl, void *argp);
204*0Sstevel@tonic-gate /* Called when we need to dup an object */
205*0Sstevel@tonic-gate typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d,
206*0Sstevel@tonic-gate 					int idx, long argl, void *argp);
207*0Sstevel@tonic-gate 
208*0Sstevel@tonic-gate /* This stuff is basically class callback functions
209*0Sstevel@tonic-gate  * The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more */
210*0Sstevel@tonic-gate 
211*0Sstevel@tonic-gate typedef struct crypto_ex_data_func_st
212*0Sstevel@tonic-gate 	{
213*0Sstevel@tonic-gate 	long argl;	/* Arbitary long */
214*0Sstevel@tonic-gate 	void *argp;	/* Arbitary void * */
215*0Sstevel@tonic-gate 	CRYPTO_EX_new *new_func;
216*0Sstevel@tonic-gate 	CRYPTO_EX_free *free_func;
217*0Sstevel@tonic-gate 	CRYPTO_EX_dup *dup_func;
218*0Sstevel@tonic-gate 	} CRYPTO_EX_DATA_FUNCS;
219*0Sstevel@tonic-gate 
220*0Sstevel@tonic-gate DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS)
221*0Sstevel@tonic-gate 
222*0Sstevel@tonic-gate /* Per class, we have a STACK of CRYPTO_EX_DATA_FUNCS for each CRYPTO_EX_DATA
223*0Sstevel@tonic-gate  * entry.
224*0Sstevel@tonic-gate  */
225*0Sstevel@tonic-gate 
226*0Sstevel@tonic-gate #define CRYPTO_EX_INDEX_BIO		0
227*0Sstevel@tonic-gate #define CRYPTO_EX_INDEX_SSL		1
228*0Sstevel@tonic-gate #define CRYPTO_EX_INDEX_SSL_CTX		2
229*0Sstevel@tonic-gate #define CRYPTO_EX_INDEX_SSL_SESSION	3
230*0Sstevel@tonic-gate #define CRYPTO_EX_INDEX_X509_STORE	4
231*0Sstevel@tonic-gate #define CRYPTO_EX_INDEX_X509_STORE_CTX	5
232*0Sstevel@tonic-gate #define CRYPTO_EX_INDEX_RSA		6
233*0Sstevel@tonic-gate #define CRYPTO_EX_INDEX_DSA		7
234*0Sstevel@tonic-gate #define CRYPTO_EX_INDEX_DH		8
235*0Sstevel@tonic-gate #define CRYPTO_EX_INDEX_ENGINE		9
236*0Sstevel@tonic-gate #define CRYPTO_EX_INDEX_X509		10
237*0Sstevel@tonic-gate #define CRYPTO_EX_INDEX_UI		11
238*0Sstevel@tonic-gate 
239*0Sstevel@tonic-gate /* Dynamically assigned indexes start from this value (don't use directly, use
240*0Sstevel@tonic-gate  * via CRYPTO_ex_data_new_class). */
241*0Sstevel@tonic-gate #define CRYPTO_EX_INDEX_USER		100
242*0Sstevel@tonic-gate 
243*0Sstevel@tonic-gate 
244*0Sstevel@tonic-gate /* This is the default callbacks, but we can have others as well:
245*0Sstevel@tonic-gate  * this is needed in Win32 where the application malloc and the
246*0Sstevel@tonic-gate  * library malloc may not be the same.
247*0Sstevel@tonic-gate  */
248*0Sstevel@tonic-gate #define CRYPTO_malloc_init()	CRYPTO_set_mem_functions(\
249*0Sstevel@tonic-gate 	malloc, realloc, free)
250*0Sstevel@tonic-gate 
251*0Sstevel@tonic-gate #if defined CRYPTO_MDEBUG_ALL || defined CRYPTO_MDEBUG_TIME || defined CRYPTO_MDEBUG_THREAD
252*0Sstevel@tonic-gate # ifndef CRYPTO_MDEBUG /* avoid duplicate #define */
253*0Sstevel@tonic-gate #  define CRYPTO_MDEBUG
254*0Sstevel@tonic-gate # endif
255*0Sstevel@tonic-gate #endif
256*0Sstevel@tonic-gate 
257*0Sstevel@tonic-gate /* Set standard debugging functions (not done by default
258*0Sstevel@tonic-gate  * unless CRYPTO_MDEBUG is defined) */
259*0Sstevel@tonic-gate #define CRYPTO_malloc_debug_init()	do {\
260*0Sstevel@tonic-gate 	CRYPTO_set_mem_debug_functions(\
261*0Sstevel@tonic-gate 		CRYPTO_dbg_malloc,\
262*0Sstevel@tonic-gate 		CRYPTO_dbg_realloc,\
263*0Sstevel@tonic-gate 		CRYPTO_dbg_free,\
264*0Sstevel@tonic-gate 		CRYPTO_dbg_set_options,\
265*0Sstevel@tonic-gate 		CRYPTO_dbg_get_options);\
266*0Sstevel@tonic-gate 	} while(0)
267*0Sstevel@tonic-gate 
268*0Sstevel@tonic-gate int CRYPTO_mem_ctrl(int mode);
269*0Sstevel@tonic-gate int CRYPTO_is_mem_check_on(void);
270*0Sstevel@tonic-gate 
271*0Sstevel@tonic-gate /* for applications */
272*0Sstevel@tonic-gate #define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON)
273*0Sstevel@tonic-gate #define MemCheck_stop()	CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF)
274*0Sstevel@tonic-gate 
275*0Sstevel@tonic-gate /* for library-internal use */
276*0Sstevel@tonic-gate #define MemCheck_on()	CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE)
277*0Sstevel@tonic-gate #define MemCheck_off()	CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE)
278*0Sstevel@tonic-gate #define is_MemCheck_on() CRYPTO_is_mem_check_on()
279*0Sstevel@tonic-gate 
280*0Sstevel@tonic-gate #define OPENSSL_malloc(num)	CRYPTO_malloc((int)num,__FILE__,__LINE__)
281*0Sstevel@tonic-gate #define OPENSSL_realloc(addr,num) \
282*0Sstevel@tonic-gate 	CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__)
283*0Sstevel@tonic-gate #define OPENSSL_realloc_clean(addr,old_num,num) \
284*0Sstevel@tonic-gate 	CRYPTO_realloc_clean(addr,old_num,num,__FILE__,__LINE__)
285*0Sstevel@tonic-gate #define OPENSSL_remalloc(addr,num) \
286*0Sstevel@tonic-gate 	CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__)
287*0Sstevel@tonic-gate #define OPENSSL_freeFunc	CRYPTO_free
288*0Sstevel@tonic-gate #define OPENSSL_free(addr)	CRYPTO_free(addr)
289*0Sstevel@tonic-gate 
290*0Sstevel@tonic-gate #define OPENSSL_malloc_locked(num) \
291*0Sstevel@tonic-gate 	CRYPTO_malloc_locked((int)num,__FILE__,__LINE__)
292*0Sstevel@tonic-gate #define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr)
293*0Sstevel@tonic-gate 
294*0Sstevel@tonic-gate 
295*0Sstevel@tonic-gate const char *SSLeay_version(int type);
296*0Sstevel@tonic-gate unsigned long SSLeay(void);
297*0Sstevel@tonic-gate 
298*0Sstevel@tonic-gate int OPENSSL_issetugid(void);
299*0Sstevel@tonic-gate 
300*0Sstevel@tonic-gate /* An opaque type representing an implementation of "ex_data" support */
301*0Sstevel@tonic-gate typedef struct st_CRYPTO_EX_DATA_IMPL	CRYPTO_EX_DATA_IMPL;
302*0Sstevel@tonic-gate /* Return an opaque pointer to the current "ex_data" implementation */
303*0Sstevel@tonic-gate const CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void);
304*0Sstevel@tonic-gate /* Sets the "ex_data" implementation to be used (if it's not too late) */
305*0Sstevel@tonic-gate int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i);
306*0Sstevel@tonic-gate /* Get a new "ex_data" class, and return the corresponding "class_index" */
307*0Sstevel@tonic-gate int CRYPTO_ex_data_new_class(void);
308*0Sstevel@tonic-gate /* Within a given class, get/register a new index */
309*0Sstevel@tonic-gate int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,
310*0Sstevel@tonic-gate 		CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
311*0Sstevel@tonic-gate 		CRYPTO_EX_free *free_func);
312*0Sstevel@tonic-gate /* Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a given
313*0Sstevel@tonic-gate  * class (invokes whatever per-class callbacks are applicable) */
314*0Sstevel@tonic-gate int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
315*0Sstevel@tonic-gate int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
316*0Sstevel@tonic-gate 		CRYPTO_EX_DATA *from);
317*0Sstevel@tonic-gate void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
318*0Sstevel@tonic-gate /* Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular index
319*0Sstevel@tonic-gate  * (relative to the class type involved) */
320*0Sstevel@tonic-gate int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);
321*0Sstevel@tonic-gate void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad,int idx);
322*0Sstevel@tonic-gate /* This function cleans up all "ex_data" state. It mustn't be called under
323*0Sstevel@tonic-gate  * potential race-conditions. */
324*0Sstevel@tonic-gate void CRYPTO_cleanup_all_ex_data(void);
325*0Sstevel@tonic-gate 
326*0Sstevel@tonic-gate int CRYPTO_get_new_lockid(char *name);
327*0Sstevel@tonic-gate 
328*0Sstevel@tonic-gate int CRYPTO_num_locks(void); /* return CRYPTO_NUM_LOCKS (shared libs!) */
329*0Sstevel@tonic-gate void CRYPTO_lock(int mode, int type,const char *file,int line);
330*0Sstevel@tonic-gate void CRYPTO_set_locking_callback(void (*func)(int mode,int type,
331*0Sstevel@tonic-gate 					      const char *file,int line));
332*0Sstevel@tonic-gate void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char *file,
333*0Sstevel@tonic-gate 		int line);
334*0Sstevel@tonic-gate void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type,
335*0Sstevel@tonic-gate 					      const char *file, int line));
336*0Sstevel@tonic-gate int (*CRYPTO_get_add_lock_callback(void))(int *num,int mount,int type,
337*0Sstevel@tonic-gate 					  const char *file,int line);
338*0Sstevel@tonic-gate void CRYPTO_set_id_callback(unsigned long (*func)(void));
339*0Sstevel@tonic-gate unsigned long (*CRYPTO_get_id_callback(void))(void);
340*0Sstevel@tonic-gate unsigned long CRYPTO_thread_id(void);
341*0Sstevel@tonic-gate const char *CRYPTO_get_lock_name(int type);
342*0Sstevel@tonic-gate int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file,
343*0Sstevel@tonic-gate 		    int line);
344*0Sstevel@tonic-gate 
345*0Sstevel@tonic-gate int CRYPTO_get_new_dynlockid(void);
346*0Sstevel@tonic-gate void CRYPTO_destroy_dynlockid(int i);
347*0Sstevel@tonic-gate struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i);
348*0Sstevel@tonic-gate void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*dyn_create_function)(const char *file, int line));
349*0Sstevel@tonic-gate void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line));
350*0Sstevel@tonic-gate void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)(struct CRYPTO_dynlock_value *l, const char *file, int line));
351*0Sstevel@tonic-gate struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))(const char *file,int line);
352*0Sstevel@tonic-gate void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, struct CRYPTO_dynlock_value *l, const char *file,int line);
353*0Sstevel@tonic-gate void (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l, const char *file,int line);
354*0Sstevel@tonic-gate 
355*0Sstevel@tonic-gate /* CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions --
356*0Sstevel@tonic-gate  * call the latter last if you need different functions */
357*0Sstevel@tonic-gate int CRYPTO_set_mem_functions(void *(*m)(size_t),void *(*r)(void *,size_t), void (*f)(void *));
358*0Sstevel@tonic-gate int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*free_func)(void *));
359*0Sstevel@tonic-gate int CRYPTO_set_mem_ex_functions(void *(*m)(size_t,const char *,int),
360*0Sstevel@tonic-gate                                 void *(*r)(void *,size_t,const char *,int),
361*0Sstevel@tonic-gate                                 void (*f)(void *));
362*0Sstevel@tonic-gate int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t,const char *,int),
363*0Sstevel@tonic-gate                                        void (*free_func)(void *));
364*0Sstevel@tonic-gate int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int),
365*0Sstevel@tonic-gate 				   void (*r)(void *,void *,int,const char *,int,int),
366*0Sstevel@tonic-gate 				   void (*f)(void *,int),
367*0Sstevel@tonic-gate 				   void (*so)(long),
368*0Sstevel@tonic-gate 				   long (*go)(void));
369*0Sstevel@tonic-gate void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), void (**f)(void *));
370*0Sstevel@tonic-gate void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *));
371*0Sstevel@tonic-gate void CRYPTO_get_mem_ex_functions(void *(**m)(size_t,const char *,int),
372*0Sstevel@tonic-gate                                  void *(**r)(void *, size_t,const char *,int),
373*0Sstevel@tonic-gate                                  void (**f)(void *));
374*0Sstevel@tonic-gate void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t,const char *,int),
375*0Sstevel@tonic-gate                                         void (**f)(void *));
376*0Sstevel@tonic-gate void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int),
377*0Sstevel@tonic-gate 				    void (**r)(void *,void *,int,const char *,int,int),
378*0Sstevel@tonic-gate 				    void (**f)(void *,int),
379*0Sstevel@tonic-gate 				    void (**so)(long),
380*0Sstevel@tonic-gate 				    long (**go)(void));
381*0Sstevel@tonic-gate 
382*0Sstevel@tonic-gate void *CRYPTO_malloc_locked(int num, const char *file, int line);
383*0Sstevel@tonic-gate void CRYPTO_free_locked(void *);
384*0Sstevel@tonic-gate void *CRYPTO_malloc(int num, const char *file, int line);
385*0Sstevel@tonic-gate void CRYPTO_free(void *);
386*0Sstevel@tonic-gate void *CRYPTO_realloc(void *addr,int num, const char *file, int line);
387*0Sstevel@tonic-gate void *CRYPTO_realloc_clean(void *addr,int old_num,int num,const char *file,
388*0Sstevel@tonic-gate 			   int line);
389*0Sstevel@tonic-gate void *CRYPTO_remalloc(void *addr,int num, const char *file, int line);
390*0Sstevel@tonic-gate 
391*0Sstevel@tonic-gate void OPENSSL_cleanse(void *ptr, size_t len);
392*0Sstevel@tonic-gate 
393*0Sstevel@tonic-gate void CRYPTO_set_mem_debug_options(long bits);
394*0Sstevel@tonic-gate long CRYPTO_get_mem_debug_options(void);
395*0Sstevel@tonic-gate 
396*0Sstevel@tonic-gate #define CRYPTO_push_info(info) \
397*0Sstevel@tonic-gate         CRYPTO_push_info_(info, __FILE__, __LINE__);
398*0Sstevel@tonic-gate int CRYPTO_push_info_(const char *info, const char *file, int line);
399*0Sstevel@tonic-gate int CRYPTO_pop_info(void);
400*0Sstevel@tonic-gate int CRYPTO_remove_all_info(void);
401*0Sstevel@tonic-gate 
402*0Sstevel@tonic-gate 
403*0Sstevel@tonic-gate /* Default debugging functions (enabled by CRYPTO_malloc_debug_init() macro;
404*0Sstevel@tonic-gate  * used as default in CRYPTO_MDEBUG compilations): */
405*0Sstevel@tonic-gate /* The last argument has the following significance:
406*0Sstevel@tonic-gate  *
407*0Sstevel@tonic-gate  * 0:	called before the actual memory allocation has taken place
408*0Sstevel@tonic-gate  * 1:	called after the actual memory allocation has taken place
409*0Sstevel@tonic-gate  */
410*0Sstevel@tonic-gate void CRYPTO_dbg_malloc(void *addr,int num,const char *file,int line,int before_p);
411*0Sstevel@tonic-gate void CRYPTO_dbg_realloc(void *addr1,void *addr2,int num,const char *file,int line,int before_p);
412*0Sstevel@tonic-gate void CRYPTO_dbg_free(void *addr,int before_p);
413*0Sstevel@tonic-gate /* Tell the debugging code about options.  By default, the following values
414*0Sstevel@tonic-gate  * apply:
415*0Sstevel@tonic-gate  *
416*0Sstevel@tonic-gate  * 0:                           Clear all options.
417*0Sstevel@tonic-gate  * V_CRYPTO_MDEBUG_TIME (1):    Set the "Show Time" option.
418*0Sstevel@tonic-gate  * V_CRYPTO_MDEBUG_THREAD (2):  Set the "Show Thread Number" option.
419*0Sstevel@tonic-gate  * V_CRYPTO_MDEBUG_ALL (3):     1 + 2
420*0Sstevel@tonic-gate  */
421*0Sstevel@tonic-gate void CRYPTO_dbg_set_options(long bits);
422*0Sstevel@tonic-gate long CRYPTO_dbg_get_options(void);
423*0Sstevel@tonic-gate 
424*0Sstevel@tonic-gate 
425*0Sstevel@tonic-gate #ifndef OPENSSL_NO_FP_API
426*0Sstevel@tonic-gate void CRYPTO_mem_leaks_fp(FILE *);
427*0Sstevel@tonic-gate #endif
428*0Sstevel@tonic-gate void CRYPTO_mem_leaks(struct bio_st *bio);
429*0Sstevel@tonic-gate /* unsigned long order, char *file, int line, int num_bytes, char *addr */
430*0Sstevel@tonic-gate typedef void *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *);
431*0Sstevel@tonic-gate void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb);
432*0Sstevel@tonic-gate 
433*0Sstevel@tonic-gate /* die if we have to */
434*0Sstevel@tonic-gate void OpenSSLDie(const char *file,int line,const char *assertion);
435*0Sstevel@tonic-gate #define OPENSSL_assert(e)	((e) ? (void)0 : OpenSSLDie(__FILE__, __LINE__, #e))
436*0Sstevel@tonic-gate 
437*0Sstevel@tonic-gate /* BEGIN ERROR CODES */
438*0Sstevel@tonic-gate /* The following lines are auto generated by the script mkerr.pl. Any changes
439*0Sstevel@tonic-gate  * made after this point may be overwritten when the script is next run.
440*0Sstevel@tonic-gate  */
441*0Sstevel@tonic-gate void ERR_load_CRYPTO_strings(void);
442*0Sstevel@tonic-gate 
443*0Sstevel@tonic-gate /* Error codes for the CRYPTO functions. */
444*0Sstevel@tonic-gate 
445*0Sstevel@tonic-gate /* Function codes. */
446*0Sstevel@tonic-gate #define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX		 100
447*0Sstevel@tonic-gate #define CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID		 103
448*0Sstevel@tonic-gate #define CRYPTO_F_CRYPTO_GET_NEW_LOCKID			 101
449*0Sstevel@tonic-gate #define CRYPTO_F_CRYPTO_SET_EX_DATA			 102
450*0Sstevel@tonic-gate #define CRYPTO_F_DEF_ADD_INDEX				 104
451*0Sstevel@tonic-gate #define CRYPTO_F_DEF_GET_CLASS				 105
452*0Sstevel@tonic-gate #define CRYPTO_F_INT_DUP_EX_DATA			 106
453*0Sstevel@tonic-gate #define CRYPTO_F_INT_FREE_EX_DATA			 107
454*0Sstevel@tonic-gate #define CRYPTO_F_INT_NEW_EX_DATA			 108
455*0Sstevel@tonic-gate 
456*0Sstevel@tonic-gate /* Reason codes. */
457*0Sstevel@tonic-gate #define CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK		 100
458*0Sstevel@tonic-gate 
459*0Sstevel@tonic-gate #ifdef  __cplusplus
460*0Sstevel@tonic-gate }
461*0Sstevel@tonic-gate #endif
462*0Sstevel@tonic-gate #endif
463