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