williamr@2: /* crypto/crypto.h */ williamr@2: /* ==================================================================== williamr@2: * Copyright (c) 1998-2003 The OpenSSL Project. All rights reserved. williamr@2: * williamr@2: * Redistribution and use in source and binary forms, with or without williamr@2: * modification, are permitted provided that the following conditions williamr@2: * are met: williamr@2: * williamr@2: * 1. Redistributions of source code must retain the above copyright williamr@2: * notice, this list of conditions and the following disclaimer. williamr@2: * williamr@2: * 2. Redistributions in binary form must reproduce the above copyright williamr@2: * notice, this list of conditions and the following disclaimer in williamr@2: * the documentation and/or other materials provided with the williamr@2: * distribution. williamr@2: * williamr@2: * 3. All advertising materials mentioning features or use of this williamr@2: * software must display the following acknowledgment: williamr@2: * "This product includes software developed by the OpenSSL Project williamr@2: * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" williamr@2: * williamr@2: * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to williamr@2: * endorse or promote products derived from this software without williamr@2: * prior written permission. For written permission, please contact williamr@2: * openssl-core@openssl.org. williamr@2: * williamr@2: * 5. Products derived from this software may not be called "OpenSSL" williamr@2: * nor may "OpenSSL" appear in their names without prior written williamr@2: * permission of the OpenSSL Project. williamr@2: * williamr@2: * 6. Redistributions of any form whatsoever must retain the following williamr@2: * acknowledgment: williamr@2: * "This product includes software developed by the OpenSSL Project williamr@2: * for use in the OpenSSL Toolkit (http://www.openssl.org/)" williamr@2: * williamr@2: * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY williamr@2: * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE williamr@2: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR williamr@2: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR williamr@2: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, williamr@2: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT williamr@2: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; williamr@2: * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) williamr@2: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, williamr@2: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) williamr@2: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED williamr@2: * OF THE POSSIBILITY OF SUCH DAMAGE. williamr@2: * ==================================================================== williamr@2: * williamr@2: * This product includes cryptographic software written by Eric Young williamr@2: * (eay@cryptsoft.com). This product includes software written by Tim williamr@2: * Hudson (tjh@cryptsoft.com). williamr@2: * williamr@2: */ williamr@2: /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) williamr@2: * All rights reserved. williamr@2: * williamr@2: * This package is an SSL implementation written williamr@2: * by Eric Young (eay@cryptsoft.com). williamr@2: * The implementation was written so as to conform with Netscapes SSL. williamr@2: * williamr@2: * This library is free for commercial and non-commercial use as long as williamr@2: * the following conditions are aheared to. The following conditions williamr@2: * apply to all code found in this distribution, be it the RC4, RSA, williamr@2: * lhash, DES, etc., code; not just the SSL code. The SSL documentation williamr@2: * included with this distribution is covered by the same copyright terms williamr@2: * except that the holder is Tim Hudson (tjh@cryptsoft.com). williamr@2: * williamr@2: * Copyright remains Eric Young's, and as such any Copyright notices in williamr@2: * the code are not to be removed. williamr@2: * If this package is used in a product, Eric Young should be given attribution williamr@2: * as the author of the parts of the library used. williamr@2: * This can be in the form of a textual message at program startup or williamr@2: * in documentation (online or textual) provided with the package. williamr@2: * williamr@2: * Redistribution and use in source and binary forms, with or without williamr@2: * modification, are permitted provided that the following conditions williamr@2: * are met: williamr@2: * 1. Redistributions of source code must retain the copyright williamr@2: * notice, this list of conditions and the following disclaimer. williamr@2: * 2. Redistributions in binary form must reproduce the above copyright williamr@2: * notice, this list of conditions and the following disclaimer in the williamr@2: * documentation and/or other materials provided with the distribution. williamr@2: * 3. All advertising materials mentioning features or use of this software williamr@2: * must display the following acknowledgement: williamr@2: * "This product includes cryptographic software written by williamr@2: * Eric Young (eay@cryptsoft.com)" williamr@2: * The word 'cryptographic' can be left out if the rouines from the library williamr@2: * being used are not cryptographic related :-). williamr@2: * 4. If you include any Windows specific code (or a derivative thereof) from williamr@2: * the apps directory (application code) you must include an acknowledgement: williamr@2: * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" williamr@2: * williamr@2: * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND williamr@2: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE williamr@2: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE williamr@2: * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE williamr@2: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL williamr@2: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS williamr@2: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) williamr@2: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT williamr@2: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY williamr@2: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF williamr@2: * SUCH DAMAGE. williamr@2: * williamr@2: * The licence and distribution terms for any publically available version or williamr@2: * derivative of this code cannot be changed. i.e. this code cannot simply be williamr@2: * copied and put under another distribution licence williamr@2: * [including the GNU Public Licence.] williamr@2: */ williamr@2: /* ==================================================================== williamr@2: * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. williamr@2: * ECDH support in OpenSSL originally developed by williamr@2: * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. williamr@2: */ williamr@2: /* williamr@2: © Portions copyright (c) 2006 Nokia Corporation. All rights reserved. williamr@2: */ williamr@2: williamr@2: #ifndef HEADER_CRYPTO_H williamr@2: #define HEADER_CRYPTO_H williamr@2: #if (defined(__SYMBIAN32__) && !defined(SYMBIAN)) williamr@2: #define SYMBIAN williamr@2: #endif williamr@2: williamr@2: #ifdef SYMBIAN williamr@2: #include williamr@2: #endif williamr@2: #include williamr@2: williamr@2: #include williamr@2: williamr@2: #ifndef OPENSSL_NO_FP_API williamr@2: #include williamr@2: #endif williamr@2: williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: williamr@2: #ifdef CHARSET_EBCDIC williamr@2: #include williamr@2: #endif williamr@2: williamr@2: /* Resolve problems on some operating systems with symbol names that clash williamr@2: one way or another */ williamr@2: #include williamr@2: williamr@2: #ifdef __cplusplus williamr@2: extern "C" { williamr@2: #endif williamr@2: williamr@2: /* Backward compatibility to SSLeay */ williamr@2: /* This is more to be used to check the correct DLL is being used williamr@2: * in the MS world. */ williamr@2: #define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER williamr@2: #define SSLEAY_VERSION 0 williamr@2: /* #define SSLEAY_OPTIONS 1 no longer supported */ williamr@2: #define SSLEAY_CFLAGS 2 williamr@2: #define SSLEAY_BUILT_ON 3 williamr@2: #define SSLEAY_PLATFORM 4 williamr@2: #define SSLEAY_DIR 5 williamr@2: williamr@2: /* Already declared in ossl_typ.h */ williamr@2: #if 0 williamr@2: typedef struct crypto_ex_data_st CRYPTO_EX_DATA; williamr@2: /* Called when a new object is created */ williamr@2: typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad, williamr@2: int idx, long argl, void *argp); williamr@2: /* Called when an object is free()ed */ williamr@2: typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad, williamr@2: int idx, long argl, void *argp); williamr@2: /* Called when we need to dup an object */ williamr@2: typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d, williamr@2: int idx, long argl, void *argp); williamr@2: #endif williamr@2: williamr@2: /* A generic structure to pass assorted data in a expandable way */ williamr@2: typedef struct openssl_item_st williamr@2: { williamr@2: int code; williamr@2: void *value; /* Not used for flag attributes */ williamr@2: size_t value_size; /* Max size of value for output, length for input */ williamr@2: size_t *value_length; /* Returned length of value for output */ williamr@2: } OPENSSL_ITEM; williamr@2: williamr@2: williamr@2: /* When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock williamr@2: * names in cryptlib.c williamr@2: */ williamr@2: williamr@2: #define CRYPTO_LOCK_ERR 1 williamr@2: #define CRYPTO_LOCK_EX_DATA 2 williamr@2: #define CRYPTO_LOCK_X509 3 williamr@2: #define CRYPTO_LOCK_X509_INFO 4 williamr@2: #define CRYPTO_LOCK_X509_PKEY 5 williamr@2: #define CRYPTO_LOCK_X509_CRL 6 williamr@2: #define CRYPTO_LOCK_X509_REQ 7 williamr@2: #define CRYPTO_LOCK_DSA 8 williamr@2: #define CRYPTO_LOCK_RSA 9 williamr@2: #define CRYPTO_LOCK_EVP_PKEY 10 williamr@2: #define CRYPTO_LOCK_X509_STORE 11 williamr@2: #define CRYPTO_LOCK_SSL_CTX 12 williamr@2: #define CRYPTO_LOCK_SSL_CERT 13 williamr@2: #define CRYPTO_LOCK_SSL_SESSION 14 williamr@2: #define CRYPTO_LOCK_SSL_SESS_CERT 15 williamr@2: #define CRYPTO_LOCK_SSL 16 williamr@2: #define CRYPTO_LOCK_SSL_METHOD 17 williamr@2: #define CRYPTO_LOCK_RAND 18 williamr@2: #define CRYPTO_LOCK_RAND2 19 williamr@2: #define CRYPTO_LOCK_MALLOC 20 williamr@2: #define CRYPTO_LOCK_BIO 21 williamr@2: #define CRYPTO_LOCK_GETHOSTBYNAME 22 williamr@2: #define CRYPTO_LOCK_GETSERVBYNAME 23 williamr@2: #define CRYPTO_LOCK_READDIR 24 williamr@2: #define CRYPTO_LOCK_RSA_BLINDING 25 williamr@2: #define CRYPTO_LOCK_DH 26 williamr@2: #define CRYPTO_LOCK_MALLOC2 27 williamr@2: #define CRYPTO_LOCK_DSO 28 williamr@2: #define CRYPTO_LOCK_DYNLOCK 29 williamr@2: #define CRYPTO_LOCK_ENGINE 30 williamr@2: #define CRYPTO_LOCK_UI 31 williamr@2: #define CRYPTO_LOCK_ECDSA 32 williamr@2: #define CRYPTO_LOCK_EC 33 williamr@2: #define CRYPTO_LOCK_ECDH 34 williamr@2: #define CRYPTO_LOCK_BN 35 williamr@2: #define CRYPTO_LOCK_EC_PRE_COMP 36 williamr@2: #define CRYPTO_LOCK_STORE 37 williamr@2: #define CRYPTO_LOCK_COMP 38 williamr@2: #define CRYPTO_NUM_LOCKS 39 williamr@2: williamr@2: #define CRYPTO_LOCK 1 williamr@2: #define CRYPTO_UNLOCK 2 williamr@2: #define CRYPTO_READ 4 williamr@2: #define CRYPTO_WRITE 8 williamr@2: williamr@2: #ifndef OPENSSL_NO_LOCKING williamr@2: #ifndef CRYPTO_w_lock williamr@2: #define CRYPTO_w_lock(type) \ williamr@2: CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__) williamr@2: #define CRYPTO_w_unlock(type) \ williamr@2: CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__) williamr@2: #define CRYPTO_r_lock(type) \ williamr@2: CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__) williamr@2: #define CRYPTO_r_unlock(type) \ williamr@2: CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__) williamr@2: #define CRYPTO_add(addr,amount,type) \ williamr@2: CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__) williamr@2: #endif williamr@2: #else williamr@2: #define CRYPTO_w_lock(a) williamr@2: #define CRYPTO_w_unlock(a) williamr@2: #define CRYPTO_r_lock(a) williamr@2: #define CRYPTO_r_unlock(a) williamr@2: #define CRYPTO_add(a,b,c) ((*(a))+=(b)) williamr@2: #endif williamr@2: williamr@2: /* Some applications as well as some parts of OpenSSL need to allocate williamr@2: and deallocate locks in a dynamic fashion. The following typedef williamr@2: makes this possible in a type-safe manner. */ williamr@2: /* struct CRYPTO_dynlock_value has to be defined by the application. */ williamr@2: typedef struct williamr@2: { williamr@2: int references; williamr@2: struct CRYPTO_dynlock_value *data; williamr@2: } CRYPTO_dynlock; williamr@2: williamr@2: williamr@2: /* The following can be used to detect memory leaks in the SSLeay library. williamr@2: * It used, it turns on malloc checking */ williamr@2: williamr@2: #define CRYPTO_MEM_CHECK_OFF 0x0 /* an enume */ williamr@2: #define CRYPTO_MEM_CHECK_ON 0x1 /* a bit */ williamr@2: #define CRYPTO_MEM_CHECK_ENABLE 0x2 /* a bit */ williamr@2: #define CRYPTO_MEM_CHECK_DISABLE 0x3 /* an enume */ williamr@2: williamr@2: /* The following are bit values to turn on or off options connected to the williamr@2: * malloc checking functionality */ williamr@2: williamr@2: /* Adds time to the memory checking information */ williamr@2: #define V_CRYPTO_MDEBUG_TIME 0x1 /* a bit */ williamr@2: /* Adds thread number to the memory checking information */ williamr@2: #define V_CRYPTO_MDEBUG_THREAD 0x2 /* a bit */ williamr@2: williamr@2: #define V_CRYPTO_MDEBUG_ALL (V_CRYPTO_MDEBUG_TIME | V_CRYPTO_MDEBUG_THREAD) williamr@2: williamr@2: williamr@2: /* predec of the BIO type */ williamr@2: typedef struct bio_st BIO_dummy; williamr@2: williamr@2: struct crypto_ex_data_st williamr@2: { williamr@2: STACK *sk; williamr@2: int dummy; /* gcc is screwing up this data structure :-( */ williamr@2: }; williamr@2: williamr@2: /* This stuff is basically class callback functions williamr@2: * The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more */ williamr@2: williamr@2: typedef struct crypto_ex_data_func_st williamr@2: { williamr@2: long argl; /* Arbitary long */ williamr@2: void *argp; /* Arbitary void * */ williamr@2: CRYPTO_EX_new *new_func; williamr@2: CRYPTO_EX_free *free_func; williamr@2: CRYPTO_EX_dup *dup_func; williamr@2: } CRYPTO_EX_DATA_FUNCS; williamr@2: williamr@2: DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS) williamr@2: williamr@2: /* Per class, we have a STACK of CRYPTO_EX_DATA_FUNCS for each CRYPTO_EX_DATA williamr@2: * entry. williamr@2: */ williamr@2: williamr@2: #define CRYPTO_EX_INDEX_BIO 0 williamr@2: #define CRYPTO_EX_INDEX_SSL 1 williamr@2: #define CRYPTO_EX_INDEX_SSL_CTX 2 williamr@2: #define CRYPTO_EX_INDEX_SSL_SESSION 3 williamr@2: #define CRYPTO_EX_INDEX_X509_STORE 4 williamr@2: #define CRYPTO_EX_INDEX_X509_STORE_CTX 5 williamr@2: #define CRYPTO_EX_INDEX_RSA 6 williamr@2: #define CRYPTO_EX_INDEX_DSA 7 williamr@2: #define CRYPTO_EX_INDEX_DH 8 williamr@2: #define CRYPTO_EX_INDEX_ENGINE 9 williamr@2: #define CRYPTO_EX_INDEX_X509 10 williamr@2: #define CRYPTO_EX_INDEX_UI 11 williamr@2: #define CRYPTO_EX_INDEX_ECDSA 12 williamr@2: #define CRYPTO_EX_INDEX_ECDH 13 williamr@2: #define CRYPTO_EX_INDEX_COMP 14 williamr@2: #define CRYPTO_EX_INDEX_STORE 15 williamr@2: williamr@2: /* Dynamically assigned indexes start from this value (don't use directly, use williamr@2: * via CRYPTO_ex_data_new_class). */ williamr@2: #define CRYPTO_EX_INDEX_USER 100 williamr@2: williamr@2: williamr@2: /* This is the default callbacks, but we can have others as well: williamr@2: * this is needed in Win32 where the application malloc and the williamr@2: * library malloc may not be the same. williamr@2: */ williamr@2: #define CRYPTO_malloc_init() CRYPTO_set_mem_functions(\ williamr@2: malloc, realloc, free) williamr@2: williamr@2: #if defined CRYPTO_MDEBUG_ALL || defined CRYPTO_MDEBUG_TIME || defined CRYPTO_MDEBUG_THREAD williamr@2: # ifndef CRYPTO_MDEBUG /* avoid duplicate #define */ williamr@2: # define CRYPTO_MDEBUG williamr@2: # endif williamr@2: #endif williamr@2: williamr@2: /* Set standard debugging functions (not done by default williamr@2: * unless CRYPTO_MDEBUG is defined) */ williamr@2: #define CRYPTO_malloc_debug_init() do {\ williamr@2: CRYPTO_set_mem_debug_functions(\ williamr@2: CRYPTO_dbg_malloc,\ williamr@2: CRYPTO_dbg_realloc,\ williamr@2: CRYPTO_dbg_free,\ williamr@2: CRYPTO_dbg_set_options,\ williamr@2: CRYPTO_dbg_get_options);\ williamr@2: } while(0) williamr@2: williamr@2: IMPORT_C int CRYPTO_mem_ctrl(int mode); williamr@2: IMPORT_C int CRYPTO_is_mem_check_on(void); williamr@2: williamr@2: /* for applications */ williamr@2: #define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON) williamr@2: #define MemCheck_stop() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF) williamr@2: williamr@2: /* for library-internal use */ williamr@2: #define MemCheck_on() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE) williamr@2: #define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE) williamr@2: #define is_MemCheck_on() CRYPTO_is_mem_check_on() williamr@2: williamr@2: #define OPENSSL_malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__) williamr@2: #define OPENSSL_realloc(addr,num) \ williamr@2: CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__) williamr@2: #define OPENSSL_realloc_clean(addr,old_num,num) \ williamr@2: CRYPTO_realloc_clean(addr,old_num,num,__FILE__,__LINE__) williamr@2: #define OPENSSL_remalloc(addr,num) \ williamr@2: CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__) williamr@2: #define OPENSSL_freeFunc CRYPTO_free williamr@2: #define OPENSSL_free(addr) CRYPTO_free(addr) williamr@2: williamr@2: #define OPENSSL_malloc_locked(num) \ williamr@2: CRYPTO_malloc_locked((int)num,__FILE__,__LINE__) williamr@2: #define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr) williamr@2: williamr@2: williamr@2: IMPORT_C const char *SSLeay_version(int type); williamr@2: IMPORT_C unsigned long SSLeay(void); williamr@2: williamr@2: IMPORT_C int OPENSSL_issetugid(void); williamr@2: williamr@2: /* An opaque type representing an implementation of "ex_data" support */ williamr@2: typedef struct st_CRYPTO_EX_DATA_IMPL CRYPTO_EX_DATA_IMPL; williamr@2: /* Return an opaque pointer to the current "ex_data" implementation */ williamr@2: IMPORT_C const CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void); williamr@2: /* Sets the "ex_data" implementation to be used (if it's not too late) */ williamr@2: IMPORT_C int CRYPTO_set_ex_data_implementation(CRYPTO_EX_DATA_IMPL *i); williamr@2: /* Get a new "ex_data" class, and return the corresponding "class_index" */ williamr@2: IMPORT_C int CRYPTO_ex_data_new_class(void); williamr@2: /* Within a given class, get/register a new index */ williamr@2: IMPORT_C int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp, williamr@2: CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, williamr@2: CRYPTO_EX_free *free_func); williamr@2: /* Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a given williamr@2: * class (invokes whatever per-class callbacks are applicable) */ williamr@2: IMPORT_C int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); williamr@2: IMPORT_C int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, williamr@2: CRYPTO_EX_DATA *from); williamr@2: IMPORT_C void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); williamr@2: /* Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular index williamr@2: * (relative to the class type involved) */ williamr@2: IMPORT_C int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val); williamr@2: IMPORT_C void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad,int idx); williamr@2: /* This function cleans up all "ex_data" state. It mustn't be called under williamr@2: * potential race-conditions. */ williamr@2: IMPORT_C void CRYPTO_cleanup_all_ex_data(void); williamr@2: williamr@2: IMPORT_C int CRYPTO_get_new_lockid(char *name); williamr@2: williamr@2: IMPORT_C int CRYPTO_num_locks(void); /* return CRYPTO_NUM_LOCKS (shared libs!) */ williamr@2: IMPORT_C void CRYPTO_lock(int mode, int type,const char *file,int line); williamr@2: IMPORT_C void CRYPTO_set_locking_callback(void (*func)(int mode,int type, williamr@2: const char *file,int line)); williamr@2: IMPORT_C void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char *file, williamr@2: int line); williamr@2: IMPORT_C void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type, williamr@2: const char *file, int line)); williamr@2: IMPORT_C int (*CRYPTO_get_add_lock_callback(void))(int *num,int mount,int type, williamr@2: const char *file,int line); williamr@2: IMPORT_C void CRYPTO_set_id_callback(unsigned long (*func)(void)); williamr@2: IMPORT_C unsigned long (*CRYPTO_get_id_callback(void))(void); williamr@2: IMPORT_C unsigned long CRYPTO_thread_id(void); williamr@2: IMPORT_C const char *CRYPTO_get_lock_name(int type); williamr@2: IMPORT_C int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file, williamr@2: int line); williamr@2: williamr@2: IMPORT_C int CRYPTO_get_new_dynlockid(void); williamr@2: IMPORT_C void CRYPTO_destroy_dynlockid(int i); williamr@2: IMPORT_C struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i); williamr@2: IMPORT_C void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*dyn_create_function)(const char *file, int line)); williamr@2: IMPORT_C void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line)); williamr@2: IMPORT_C void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)(struct CRYPTO_dynlock_value *l, const char *file, int line)); williamr@2: IMPORT_C struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))(const char *file,int line); williamr@2: IMPORT_C void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, struct CRYPTO_dynlock_value *l, const char *file,int line); williamr@2: IMPORT_C void (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l, const char *file,int line); williamr@2: williamr@2: /* CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions -- williamr@2: * call the latter last if you need different functions */ williamr@2: IMPORT_C int CRYPTO_set_mem_functions(void *(*m)(size_t),void *(*r)(void *,size_t), void (*f)(void *)); williamr@2: IMPORT_C int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*free_func)(void *)); williamr@2: IMPORT_C int CRYPTO_set_mem_ex_functions(void *(*m)(size_t,const char *,int), williamr@2: void *(*r)(void *,size_t,const char *,int), williamr@2: void (*f)(void *)); williamr@2: IMPORT_C int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t,const char *,int), williamr@2: void (*free_func)(void *)); williamr@2: IMPORT_C int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int), williamr@2: void (*r)(void *,void *,int,const char *,int,int), williamr@2: void (*f)(void *,int), williamr@2: void (*so)(long), williamr@2: long (*go)(void)); williamr@2: IMPORT_C void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), void (**f)(void *)); williamr@2: IMPORT_C void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *)); williamr@2: IMPORT_C void CRYPTO_get_mem_ex_functions(void *(**m)(size_t,const char *,int), williamr@2: void *(**r)(void *, size_t,const char *,int), williamr@2: void (**f)(void *)); williamr@2: IMPORT_C void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t,const char *,int), williamr@2: void (**f)(void *)); williamr@2: IMPORT_C void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int), williamr@2: void (**r)(void *,void *,int,const char *,int,int), williamr@2: void (**f)(void *,int), williamr@2: void (**so)(long), williamr@2: long (**go)(void)); williamr@2: williamr@2: IMPORT_C void *CRYPTO_malloc_locked(int num, const char *file, int line); williamr@2: IMPORT_C void CRYPTO_free_locked(void *); williamr@2: IMPORT_C void *CRYPTO_malloc(int num, const char *file, int line); williamr@2: IMPORT_C void CRYPTO_free(void *); williamr@2: IMPORT_C void *CRYPTO_realloc(void *addr,int num, const char *file, int line); williamr@2: IMPORT_C void *CRYPTO_realloc_clean(void *addr,int old_num,int num,const char *file, williamr@2: int line); williamr@2: IMPORT_C void *CRYPTO_remalloc(void *addr,int num, const char *file, int line); williamr@2: williamr@2: IMPORT_C void OPENSSL_cleanse(void *ptr, size_t len); williamr@2: williamr@2: IMPORT_C void CRYPTO_set_mem_debug_options(long bits); williamr@2: long CRYPTO_get_mem_debug_options(void); williamr@2: williamr@2: #define CRYPTO_push_info(info) \ williamr@2: CRYPTO_push_info_(info, __FILE__, __LINE__); williamr@2: IMPORT_C int CRYPTO_push_info_(const char *info, const char *file, int line); williamr@2: IMPORT_C int CRYPTO_pop_info(void); williamr@2: IMPORT_C int CRYPTO_remove_all_info(void); williamr@2: williamr@2: williamr@2: /* Default debugging functions (enabled by CRYPTO_malloc_debug_init() macro; williamr@2: * used as default in CRYPTO_MDEBUG compilations): */ williamr@2: /* The last argument has the following significance: williamr@2: * williamr@2: * 0: called before the actual memory allocation has taken place williamr@2: * 1: called after the actual memory allocation has taken place williamr@2: */ williamr@2: IMPORT_C void CRYPTO_dbg_malloc(void *addr,int num,const char *file,int line,int before_p); williamr@2: IMPORT_C void CRYPTO_dbg_realloc(void *addr1,void *addr2,int num,const char *file,int line,int before_p); williamr@2: IMPORT_C void CRYPTO_dbg_free(void *addr,int before_p); williamr@2: /* Tell the debugging code about options. By default, the following values williamr@2: * apply: williamr@2: * williamr@2: * 0: Clear all options. williamr@2: * V_CRYPTO_MDEBUG_TIME (1): Set the "Show Time" option. williamr@2: * V_CRYPTO_MDEBUG_THREAD (2): Set the "Show Thread Number" option. williamr@2: * V_CRYPTO_MDEBUG_ALL (3): 1 + 2 williamr@2: */ williamr@2: IMPORT_C void CRYPTO_dbg_set_options(long bits); williamr@2: IMPORT_C long CRYPTO_dbg_get_options(void); williamr@2: williamr@2: williamr@2: #ifndef OPENSSL_NO_FP_API williamr@2: IMPORT_C void CRYPTO_mem_leaks_fp(FILE *); williamr@2: #endif williamr@2: IMPORT_C void CRYPTO_mem_leaks(struct bio_st *bio); williamr@2: /* unsigned long order, char *file, int line, int num_bytes, char *addr */ williamr@2: typedef void *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *); williamr@2: IMPORT_C void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb); williamr@2: williamr@2: /* die if we have to */ williamr@2: IMPORT_C void OpenSSLDie(const char *file,int line,const char *assertion); williamr@2: #define OPENSSL_assert(e) (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1)) williamr@2: williamr@2: unsigned long *OPENSSL_ia32cap_loc(void); williamr@2: #define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc())) williamr@2: williamr@2: /* BEGIN ERROR CODES */ williamr@2: /* The following lines are auto generated by the script mkerr.pl. Any changes williamr@2: * made after this point may be overwritten when the script is next run. williamr@2: */ williamr@2: IMPORT_C void ERR_load_crypto_strings(void); williamr@2: williamr@2: /* Error codes for the CRYPTO functions. */ williamr@2: williamr@2: /* Function codes. */ williamr@2: #define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 100 williamr@2: #define CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID 103 williamr@2: #define CRYPTO_F_CRYPTO_GET_NEW_LOCKID 101 williamr@2: #define CRYPTO_F_CRYPTO_SET_EX_DATA 102 williamr@2: #define CRYPTO_F_DEF_ADD_INDEX 104 williamr@2: #define CRYPTO_F_DEF_GET_CLASS 105 williamr@2: #define CRYPTO_F_INT_DUP_EX_DATA 106 williamr@2: #define CRYPTO_F_INT_FREE_EX_DATA 107 williamr@2: #define CRYPTO_F_INT_NEW_EX_DATA 108 williamr@2: williamr@2: /* Reason codes. */ williamr@2: #define CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK 100 williamr@2: williamr@2: #ifdef __cplusplus williamr@2: } williamr@2: #endif williamr@2: #endif