LTKCPP-- LLRP Toolkit C Plus Plus Library
|
00001 /* crypto/crypto.h */ 00002 /* ==================================================================== 00003 * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions 00007 * are met: 00008 * 00009 * 1. Redistributions of source code must retain the above copyright 00010 * notice, this list of conditions and the following disclaimer. 00011 * 00012 * 2. Redistributions in binary form must reproduce the above copyright 00013 * notice, this list of conditions and the following disclaimer in 00014 * the documentation and/or other materials provided with the 00015 * distribution. 00016 * 00017 * 3. All advertising materials mentioning features or use of this 00018 * software must display the following acknowledgment: 00019 * "This product includes software developed by the OpenSSL Project 00020 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 00021 * 00022 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 00023 * endorse or promote products derived from this software without 00024 * prior written permission. For written permission, please contact 00025 * openssl-core@openssl.org. 00026 * 00027 * 5. Products derived from this software may not be called "OpenSSL" 00028 * nor may "OpenSSL" appear in their names without prior written 00029 * permission of the OpenSSL Project. 00030 * 00031 * 6. Redistributions of any form whatsoever must retain the following 00032 * acknowledgment: 00033 * "This product includes software developed by the OpenSSL Project 00034 * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 00035 * 00036 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 00037 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00038 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00039 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 00040 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00041 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 00042 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00043 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00044 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 00045 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00046 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 00047 * OF THE POSSIBILITY OF SUCH DAMAGE. 00048 * ==================================================================== 00049 * 00050 * This product includes cryptographic software written by Eric Young 00051 * (eay@cryptsoft.com). This product includes software written by Tim 00052 * Hudson (tjh@cryptsoft.com). 00053 * 00054 */ 00055 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 00056 * All rights reserved. 00057 * 00058 * This package is an SSL implementation written 00059 * by Eric Young (eay@cryptsoft.com). 00060 * The implementation was written so as to conform with Netscapes SSL. 00061 * 00062 * This library is free for commercial and non-commercial use as long as 00063 * the following conditions are aheared to. The following conditions 00064 * apply to all code found in this distribution, be it the RC4, RSA, 00065 * lhash, DES, etc., code; not just the SSL code. The SSL documentation 00066 * included with this distribution is covered by the same copyright terms 00067 * except that the holder is Tim Hudson (tjh@cryptsoft.com). 00068 * 00069 * Copyright remains Eric Young's, and as such any Copyright notices in 00070 * the code are not to be removed. 00071 * If this package is used in a product, Eric Young should be given attribution 00072 * as the author of the parts of the library used. 00073 * This can be in the form of a textual message at program startup or 00074 * in documentation (online or textual) provided with the package. 00075 * 00076 * Redistribution and use in source and binary forms, with or without 00077 * modification, are permitted provided that the following conditions 00078 * are met: 00079 * 1. Redistributions of source code must retain the copyright 00080 * notice, this list of conditions and the following disclaimer. 00081 * 2. Redistributions in binary form must reproduce the above copyright 00082 * notice, this list of conditions and the following disclaimer in the 00083 * documentation and/or other materials provided with the distribution. 00084 * 3. All advertising materials mentioning features or use of this software 00085 * must display the following acknowledgement: 00086 * "This product includes cryptographic software written by 00087 * Eric Young (eay@cryptsoft.com)" 00088 * The word 'cryptographic' can be left out if the rouines from the library 00089 * being used are not cryptographic related :-). 00090 * 4. If you include any Windows specific code (or a derivative thereof) from 00091 * the apps directory (application code) you must include an acknowledgement: 00092 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 00093 * 00094 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 00095 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00096 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00097 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 00098 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00099 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00100 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00101 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00102 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00103 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00104 * SUCH DAMAGE. 00105 * 00106 * The licence and distribution terms for any publically available version or 00107 * derivative of this code cannot be changed. i.e. this code cannot simply be 00108 * copied and put under another distribution licence 00109 * [including the GNU Public Licence.] 00110 */ 00111 /* ==================================================================== 00112 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. 00113 * ECDH support in OpenSSL originally developed by 00114 * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. 00115 */ 00116 00117 #ifndef HEADER_CRYPTO_H 00118 # define HEADER_CRYPTO_H 00119 00120 # include <stdlib.h> 00121 00122 # include <openssl/e_os2.h> 00123 00124 # ifndef OPENSSL_NO_FP_API 00125 # include <stdio.h> 00126 # endif 00127 00128 # include <openssl/stack.h> 00129 # include <openssl/safestack.h> 00130 # include <openssl/opensslv.h> 00131 # include <openssl/ossl_typ.h> 00132 00133 # ifdef CHARSET_EBCDIC 00134 # include <openssl/ebcdic.h> 00135 # endif 00136 00137 /* 00138 * Resolve problems on some operating systems with symbol names that clash 00139 * one way or another 00140 */ 00141 # include <openssl/symhacks.h> 00142 00143 #ifdef __cplusplus 00144 extern "C" { 00145 #endif 00146 00147 /* Backward compatibility to SSLeay */ 00148 /* 00149 * This is more to be used to check the correct DLL is being used in the MS 00150 * world. 00151 */ 00152 # define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER 00153 # define SSLEAY_VERSION 0 00154 /* #define SSLEAY_OPTIONS 1 no longer supported */ 00155 # define SSLEAY_CFLAGS 2 00156 # define SSLEAY_BUILT_ON 3 00157 # define SSLEAY_PLATFORM 4 00158 # define SSLEAY_DIR 5 00159 00160 /* Already declared in ossl_typ.h */ 00161 # if 0 00162 typedef struct crypto_ex_data_st CRYPTO_EX_DATA; 00163 /* Called when a new object is created */ 00164 typedef int CRYPTO_EX_new (void *parent, void *ptr, CRYPTO_EX_DATA *ad, 00165 int idx, long argl, void *argp); 00166 /* Called when an object is free()ed */ 00167 typedef void CRYPTO_EX_free (void *parent, void *ptr, CRYPTO_EX_DATA *ad, 00168 int idx, long argl, void *argp); 00169 /* Called when we need to dup an object */ 00170 typedef int CRYPTO_EX_dup (CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, 00171 void *from_d, int idx, long argl, void *argp); 00172 # endif 00173 00174 /* A generic structure to pass assorted data in a expandable way */ 00175 typedef struct openssl_item_st { 00176 int code; 00177 void *value; /* Not used for flag attributes */ 00178 size_t value_size; /* Max size of value for output, length for 00179 * input */ 00180 size_t *value_length; /* Returned length of value for output */ 00181 } OPENSSL_ITEM; 00182 00183 /* 00184 * When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock 00185 * names in cryptlib.c 00186 */ 00187 00188 # define CRYPTO_LOCK_ERR 1 00189 # define CRYPTO_LOCK_EX_DATA 2 00190 # define CRYPTO_LOCK_X509 3 00191 # define CRYPTO_LOCK_X509_INFO 4 00192 # define CRYPTO_LOCK_X509_PKEY 5 00193 # define CRYPTO_LOCK_X509_CRL 6 00194 # define CRYPTO_LOCK_X509_REQ 7 00195 # define CRYPTO_LOCK_DSA 8 00196 # define CRYPTO_LOCK_RSA 9 00197 # define CRYPTO_LOCK_EVP_PKEY 10 00198 # define CRYPTO_LOCK_X509_STORE 11 00199 # define CRYPTO_LOCK_SSL_CTX 12 00200 # define CRYPTO_LOCK_SSL_CERT 13 00201 # define CRYPTO_LOCK_SSL_SESSION 14 00202 # define CRYPTO_LOCK_SSL_SESS_CERT 15 00203 # define CRYPTO_LOCK_SSL 16 00204 # define CRYPTO_LOCK_SSL_METHOD 17 00205 # define CRYPTO_LOCK_RAND 18 00206 # define CRYPTO_LOCK_RAND2 19 00207 # define CRYPTO_LOCK_MALLOC 20 00208 # define CRYPTO_LOCK_BIO 21 00209 # define CRYPTO_LOCK_GETHOSTBYNAME 22 00210 # define CRYPTO_LOCK_GETSERVBYNAME 23 00211 # define CRYPTO_LOCK_READDIR 24 00212 # define CRYPTO_LOCK_RSA_BLINDING 25 00213 # define CRYPTO_LOCK_DH 26 00214 # define CRYPTO_LOCK_MALLOC2 27 00215 # define CRYPTO_LOCK_DSO 28 00216 # define CRYPTO_LOCK_DYNLOCK 29 00217 # define CRYPTO_LOCK_ENGINE 30 00218 # define CRYPTO_LOCK_UI 31 00219 # define CRYPTO_LOCK_ECDSA 32 00220 # define CRYPTO_LOCK_EC 33 00221 # define CRYPTO_LOCK_ECDH 34 00222 # define CRYPTO_LOCK_BN 35 00223 # define CRYPTO_LOCK_EC_PRE_COMP 36 00224 # define CRYPTO_LOCK_STORE 37 00225 # define CRYPTO_LOCK_COMP 38 00226 # define CRYPTO_LOCK_FIPS 39 00227 # define CRYPTO_LOCK_FIPS2 40 00228 # define CRYPTO_NUM_LOCKS 41 00229 00230 # define CRYPTO_LOCK 1 00231 # define CRYPTO_UNLOCK 2 00232 # define CRYPTO_READ 4 00233 # define CRYPTO_WRITE 8 00234 00235 # ifndef OPENSSL_NO_LOCKING 00236 # ifndef CRYPTO_w_lock 00237 # define CRYPTO_w_lock(type) \ 00238 CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__) 00239 # define CRYPTO_w_unlock(type) \ 00240 CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__) 00241 # define CRYPTO_r_lock(type) \ 00242 CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__) 00243 # define CRYPTO_r_unlock(type) \ 00244 CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__) 00245 # define CRYPTO_add(addr,amount,type) \ 00246 CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__) 00247 # endif 00248 # else 00249 # define CRYPTO_w_lock(a) 00250 # define CRYPTO_w_unlock(a) 00251 # define CRYPTO_r_lock(a) 00252 # define CRYPTO_r_unlock(a) 00253 # define CRYPTO_add(a,b,c) ((*(a))+=(b)) 00254 # endif 00255 00256 /* 00257 * Some applications as well as some parts of OpenSSL need to allocate and 00258 * deallocate locks in a dynamic fashion. The following typedef makes this 00259 * possible in a type-safe manner. 00260 */ 00261 /* struct CRYPTO_dynlock_value has to be defined by the application. */ 00262 typedef struct { 00263 int references; 00264 struct CRYPTO_dynlock_value *data; 00265 } CRYPTO_dynlock; 00266 00267 /* 00268 * The following can be used to detect memory leaks in the SSLeay library. It 00269 * used, it turns on malloc checking 00270 */ 00271 00272 # define CRYPTO_MEM_CHECK_OFF 0x0/* an enume */ 00273 # define CRYPTO_MEM_CHECK_ON 0x1/* a bit */ 00274 # define CRYPTO_MEM_CHECK_ENABLE 0x2/* a bit */ 00275 # define CRYPTO_MEM_CHECK_DISABLE 0x3/* an enume */ 00276 00277 /* 00278 * The following are bit values to turn on or off options connected to the 00279 * malloc checking functionality 00280 */ 00281 00282 /* Adds time to the memory checking information */ 00283 # define V_CRYPTO_MDEBUG_TIME 0x1/* a bit */ 00284 /* Adds thread number to the memory checking information */ 00285 # define V_CRYPTO_MDEBUG_THREAD 0x2/* a bit */ 00286 00287 # define V_CRYPTO_MDEBUG_ALL (V_CRYPTO_MDEBUG_TIME | V_CRYPTO_MDEBUG_THREAD) 00288 00289 /* predec of the BIO type */ 00290 typedef struct bio_st BIO_dummy; 00291 00292 struct crypto_ex_data_st { 00293 STACK_OF(void) *sk; 00294 /* gcc is screwing up this data structure :-( */ 00295 int dummy; 00296 }; 00297 DECLARE_STACK_OF(void) 00298 00299 /* 00300 * This stuff is basically class callback functions The current classes are 00301 * SSL_CTX, SSL, SSL_SESSION, and a few more 00302 */ 00303 00304 typedef struct crypto_ex_data_func_st { 00305 long argl; /* Arbitary long */ 00306 void *argp; /* Arbitary void * */ 00307 CRYPTO_EX_new *new_func; 00308 CRYPTO_EX_free *free_func; 00309 CRYPTO_EX_dup *dup_func; 00310 } CRYPTO_EX_DATA_FUNCS; 00311 00312 DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS) 00313 00314 /* 00315 * Per class, we have a STACK of CRYPTO_EX_DATA_FUNCS for each CRYPTO_EX_DATA 00316 * entry. 00317 */ 00318 00319 # define CRYPTO_EX_INDEX_BIO 0 00320 # define CRYPTO_EX_INDEX_SSL 1 00321 # define CRYPTO_EX_INDEX_SSL_CTX 2 00322 # define CRYPTO_EX_INDEX_SSL_SESSION 3 00323 # define CRYPTO_EX_INDEX_X509_STORE 4 00324 # define CRYPTO_EX_INDEX_X509_STORE_CTX 5 00325 # define CRYPTO_EX_INDEX_RSA 6 00326 # define CRYPTO_EX_INDEX_DSA 7 00327 # define CRYPTO_EX_INDEX_DH 8 00328 # define CRYPTO_EX_INDEX_ENGINE 9 00329 # define CRYPTO_EX_INDEX_X509 10 00330 # define CRYPTO_EX_INDEX_UI 11 00331 # define CRYPTO_EX_INDEX_ECDSA 12 00332 # define CRYPTO_EX_INDEX_ECDH 13 00333 # define CRYPTO_EX_INDEX_COMP 14 00334 # define CRYPTO_EX_INDEX_STORE 15 00335 00336 /* 00337 * Dynamically assigned indexes start from this value (don't use directly, 00338 * use via CRYPTO_ex_data_new_class). 00339 */ 00340 # define CRYPTO_EX_INDEX_USER 100 00341 00342 /* 00343 * This is the default callbacks, but we can have others as well: this is 00344 * needed in Win32 where the application malloc and the library malloc may 00345 * not be the same. 00346 */ 00347 # define CRYPTO_malloc_init() CRYPTO_set_mem_functions(\ 00348 malloc, realloc, free) 00349 00350 # if defined CRYPTO_MDEBUG_ALL || defined CRYPTO_MDEBUG_TIME || defined CRYPTO_MDEBUG_THREAD 00351 # ifndef CRYPTO_MDEBUG /* avoid duplicate #define */ 00352 # define CRYPTO_MDEBUG 00353 # endif 00354 # endif 00355 00356 /* 00357 * Set standard debugging functions (not done by default unless CRYPTO_MDEBUG 00358 * is defined) 00359 */ 00360 # define CRYPTO_malloc_debug_init() do {\ 00361 CRYPTO_set_mem_debug_functions(\ 00362 CRYPTO_dbg_malloc,\ 00363 CRYPTO_dbg_realloc,\ 00364 CRYPTO_dbg_free,\ 00365 CRYPTO_dbg_set_options,\ 00366 CRYPTO_dbg_get_options);\ 00367 } while(0) 00368 00369 int CRYPTO_mem_ctrl(int mode); 00370 int CRYPTO_is_mem_check_on(void); 00371 00372 /* for applications */ 00373 # define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON) 00374 # define MemCheck_stop() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF) 00375 00376 /* for library-internal use */ 00377 # define MemCheck_on() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE) 00378 # define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE) 00379 # define is_MemCheck_on() CRYPTO_is_mem_check_on() 00380 00381 # define OPENSSL_malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__) 00382 # define OPENSSL_strdup(str) CRYPTO_strdup((str),__FILE__,__LINE__) 00383 # define OPENSSL_realloc(addr,num) \ 00384 CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__) 00385 # define OPENSSL_realloc_clean(addr,old_num,num) \ 00386 CRYPTO_realloc_clean(addr,old_num,num,__FILE__,__LINE__) 00387 # define OPENSSL_remalloc(addr,num) \ 00388 CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__) 00389 # define OPENSSL_freeFunc CRYPTO_free 00390 # define OPENSSL_free(addr) CRYPTO_free(addr) 00391 00392 # define OPENSSL_malloc_locked(num) \ 00393 CRYPTO_malloc_locked((int)num,__FILE__,__LINE__) 00394 # define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr) 00395 00396 const char *SSLeay_version(int type); 00397 unsigned long SSLeay(void); 00398 00399 int OPENSSL_issetugid(void); 00400 00401 /* An opaque type representing an implementation of "ex_data" support */ 00402 typedef struct st_CRYPTO_EX_DATA_IMPL CRYPTO_EX_DATA_IMPL; 00403 /* Return an opaque pointer to the current "ex_data" implementation */ 00404 const CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void); 00405 /* Sets the "ex_data" implementation to be used (if it's not too late) */ 00406 int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i); 00407 /* Get a new "ex_data" class, and return the corresponding "class_index" */ 00408 int CRYPTO_ex_data_new_class(void); 00409 /* Within a given class, get/register a new index */ 00410 int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp, 00411 CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, 00412 CRYPTO_EX_free *free_func); 00413 /* 00414 * Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a 00415 * given class (invokes whatever per-class callbacks are applicable) 00416 */ 00417 int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); 00418 int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, 00419 CRYPTO_EX_DATA *from); 00420 void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); 00421 /* 00422 * Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular 00423 * index (relative to the class type involved) 00424 */ 00425 int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val); 00426 void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx); 00427 /* 00428 * This function cleans up all "ex_data" state. It mustn't be called under 00429 * potential race-conditions. 00430 */ 00431 void CRYPTO_cleanup_all_ex_data(void); 00432 00433 int CRYPTO_get_new_lockid(char *name); 00434 00435 int CRYPTO_num_locks(void); /* return CRYPTO_NUM_LOCKS (shared libs!) */ 00436 void CRYPTO_lock(int mode, int type, const char *file, int line); 00437 void CRYPTO_set_locking_callback(void (*func) (int mode, int type, 00438 const char *file, int line)); 00439 void (*CRYPTO_get_locking_callback(void)) (int mode, int type, 00440 const char *file, int line); 00441 void CRYPTO_set_add_lock_callback(int (*func) 00442 (int *num, int mount, int type, 00443 const char *file, int line)); 00444 int (*CRYPTO_get_add_lock_callback(void)) (int *num, int mount, int type, 00445 const char *file, int line); 00446 00447 /* Don't use this structure directly. */ 00448 typedef struct crypto_threadid_st { 00449 void *ptr; 00450 unsigned long val; 00451 } CRYPTO_THREADID; 00452 /* Only use CRYPTO_THREADID_set_[numeric|pointer]() within callbacks */ 00453 void CRYPTO_THREADID_set_numeric(CRYPTO_THREADID *id, unsigned long val); 00454 void CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr); 00455 int CRYPTO_THREADID_set_callback(void (*threadid_func) (CRYPTO_THREADID *)); 00456 void (*CRYPTO_THREADID_get_callback(void)) (CRYPTO_THREADID *); 00457 void CRYPTO_THREADID_current(CRYPTO_THREADID *id); 00458 int CRYPTO_THREADID_cmp(const CRYPTO_THREADID *a, const CRYPTO_THREADID *b); 00459 void CRYPTO_THREADID_cpy(CRYPTO_THREADID *dest, const CRYPTO_THREADID *src); 00460 unsigned long CRYPTO_THREADID_hash(const CRYPTO_THREADID *id); 00461 # ifndef OPENSSL_NO_DEPRECATED 00462 void CRYPTO_set_id_callback(unsigned long (*func) (void)); 00463 unsigned long (*CRYPTO_get_id_callback(void)) (void); 00464 unsigned long CRYPTO_thread_id(void); 00465 # endif 00466 00467 const char *CRYPTO_get_lock_name(int type); 00468 int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file, 00469 int line); 00470 00471 int CRYPTO_get_new_dynlockid(void); 00472 void CRYPTO_destroy_dynlockid(int i); 00473 struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i); 00474 void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value 00475 *(*dyn_create_function) (const char 00476 *file, 00477 int line)); 00478 void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function) 00479 (int mode, 00480 struct CRYPTO_dynlock_value *l, 00481 const char *file, int line)); 00482 void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function) 00483 (struct CRYPTO_dynlock_value *l, 00484 const char *file, int line)); 00485 struct CRYPTO_dynlock_value 00486 *(*CRYPTO_get_dynlock_create_callback(void)) (const char *file, int line); 00487 void (*CRYPTO_get_dynlock_lock_callback(void)) (int mode, 00488 struct CRYPTO_dynlock_value 00489 *l, const char *file, 00490 int line); 00491 void (*CRYPTO_get_dynlock_destroy_callback(void)) (struct CRYPTO_dynlock_value 00492 *l, const char *file, 00493 int line); 00494 00495 /* 00496 * CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions -- call 00497 * the latter last if you need different functions 00498 */ 00499 int CRYPTO_set_mem_functions(void *(*m) (size_t), void *(*r) (void *, size_t), 00500 void (*f) (void *)); 00501 int CRYPTO_set_locked_mem_functions(void *(*m) (size_t), 00502 void (*free_func) (void *)); 00503 int CRYPTO_set_mem_ex_functions(void *(*m) (size_t, const char *, int), 00504 void *(*r) (void *, size_t, const char *, 00505 int), void (*f) (void *)); 00506 int CRYPTO_set_locked_mem_ex_functions(void *(*m) (size_t, const char *, int), 00507 void (*free_func) (void *)); 00508 int CRYPTO_set_mem_debug_functions(void (*m) 00509 (void *, int, const char *, int, int), 00510 void (*r) (void *, void *, int, 00511 const char *, int, int), 00512 void (*f) (void *, int), void (*so) (long), 00513 long (*go) (void)); 00514 void CRYPTO_get_mem_functions(void *(**m) (size_t), 00515 void *(**r) (void *, size_t), 00516 void (**f) (void *)); 00517 void CRYPTO_get_locked_mem_functions(void *(**m) (size_t), 00518 void (**f) (void *)); 00519 void CRYPTO_get_mem_ex_functions(void *(**m) (size_t, const char *, int), 00520 void *(**r) (void *, size_t, const char *, 00521 int), void (**f) (void *)); 00522 void CRYPTO_get_locked_mem_ex_functions(void 00523 *(**m) (size_t, const char *, int), 00524 void (**f) (void *)); 00525 void CRYPTO_get_mem_debug_functions(void (**m) 00526 (void *, int, const char *, int, int), 00527 void (**r) (void *, void *, int, 00528 const char *, int, int), 00529 void (**f) (void *, int), 00530 void (**so) (long), long (**go) (void)); 00531 00532 void *CRYPTO_malloc_locked(int num, const char *file, int line); 00533 void CRYPTO_free_locked(void *ptr); 00534 void *CRYPTO_malloc(int num, const char *file, int line); 00535 char *CRYPTO_strdup(const char *str, const char *file, int line); 00536 void CRYPTO_free(void *ptr); 00537 void *CRYPTO_realloc(void *addr, int num, const char *file, int line); 00538 void *CRYPTO_realloc_clean(void *addr, int old_num, int num, const char *file, 00539 int line); 00540 void *CRYPTO_remalloc(void *addr, int num, const char *file, int line); 00541 00542 void OPENSSL_cleanse(void *ptr, size_t len); 00543 00544 void CRYPTO_set_mem_debug_options(long bits); 00545 long CRYPTO_get_mem_debug_options(void); 00546 00547 # define CRYPTO_push_info(info) \ 00548 CRYPTO_push_info_(info, __FILE__, __LINE__); 00549 int CRYPTO_push_info_(const char *info, const char *file, int line); 00550 int CRYPTO_pop_info(void); 00551 int CRYPTO_remove_all_info(void); 00552 00553 /* 00554 * Default debugging functions (enabled by CRYPTO_malloc_debug_init() macro; 00555 * used as default in CRYPTO_MDEBUG compilations): 00556 */ 00557 /*- 00558 * The last argument has the following significance: 00559 * 00560 * 0: called before the actual memory allocation has taken place 00561 * 1: called after the actual memory allocation has taken place 00562 */ 00563 void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line, 00564 int before_p); 00565 void CRYPTO_dbg_realloc(void *addr1, void *addr2, int num, const char *file, 00566 int line, int before_p); 00567 void CRYPTO_dbg_free(void *addr, int before_p); 00568 /*- 00569 * Tell the debugging code about options. By default, the following values 00570 * apply: 00571 * 00572 * 0: Clear all options. 00573 * V_CRYPTO_MDEBUG_TIME (1): Set the "Show Time" option. 00574 * V_CRYPTO_MDEBUG_THREAD (2): Set the "Show Thread Number" option. 00575 * V_CRYPTO_MDEBUG_ALL (3): 1 + 2 00576 */ 00577 void CRYPTO_dbg_set_options(long bits); 00578 long CRYPTO_dbg_get_options(void); 00579 00580 # ifndef OPENSSL_NO_FP_API 00581 void CRYPTO_mem_leaks_fp(FILE *); 00582 # endif 00583 void CRYPTO_mem_leaks(struct bio_st *bio); 00584 /* unsigned long order, char *file, int line, int num_bytes, char *addr */ 00585 typedef void *CRYPTO_MEM_LEAK_CB (unsigned long, const char *, int, int, 00586 void *); 00587 void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb); 00588 00589 /* die if we have to */ 00590 void OpenSSLDie(const char *file, int line, const char *assertion); 00591 # define OPENSSL_assert(e) (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1)) 00592 00593 unsigned long *OPENSSL_ia32cap_loc(void); 00594 # define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc())) 00595 int OPENSSL_isservice(void); 00596 00597 int FIPS_mode(void); 00598 int FIPS_mode_set(int r); 00599 00600 void OPENSSL_init(void); 00601 00602 # define fips_md_init(alg) fips_md_init_ctx(alg, alg) 00603 00604 # ifdef OPENSSL_FIPS 00605 # define fips_md_init_ctx(alg, cx) \ 00606 int alg##_Init(cx##_CTX *c) \ 00607 { \ 00608 if (FIPS_mode()) OpenSSLDie(__FILE__, __LINE__, \ 00609 "Low level API call to digest " #alg " forbidden in FIPS mode!"); \ 00610 return private_##alg##_Init(c); \ 00611 } \ 00612 int private_##alg##_Init(cx##_CTX *c) 00613 00614 # define fips_cipher_abort(alg) \ 00615 if (FIPS_mode()) OpenSSLDie(__FILE__, __LINE__, \ 00616 "Low level API call to cipher " #alg " forbidden in FIPS mode!") 00617 00618 # else 00619 # define fips_md_init_ctx(alg, cx) \ 00620 int alg##_Init(cx##_CTX *c) 00621 # define fips_cipher_abort(alg) while(0) 00622 # endif 00623 00624 /* 00625 * CRYPTO_memcmp returns zero iff the |len| bytes at |a| and |b| are equal. 00626 * It takes an amount of time dependent on |len|, but independent of the 00627 * contents of |a| and |b|. Unlike memcmp, it cannot be used to put elements 00628 * into a defined order as the return value when a != b is undefined, other 00629 * than to be non-zero. 00630 */ 00631 int CRYPTO_memcmp(const void *a, const void *b, size_t len); 00632 00633 /* BEGIN ERROR CODES */ 00634 /* 00635 * The following lines are auto generated by the script mkerr.pl. Any changes 00636 * made after this point may be overwritten when the script is next run. 00637 */ 00638 void ERR_load_CRYPTO_strings(void); 00639 00640 /* Error codes for the CRYPTO functions. */ 00641 00642 /* Function codes. */ 00643 # define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 100 00644 # define CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID 103 00645 # define CRYPTO_F_CRYPTO_GET_NEW_LOCKID 101 00646 # define CRYPTO_F_CRYPTO_SET_EX_DATA 102 00647 # define CRYPTO_F_DEF_ADD_INDEX 104 00648 # define CRYPTO_F_DEF_GET_CLASS 105 00649 # define CRYPTO_F_FIPS_MODE_SET 109 00650 # define CRYPTO_F_INT_DUP_EX_DATA 106 00651 # define CRYPTO_F_INT_FREE_EX_DATA 107 00652 # define CRYPTO_F_INT_NEW_EX_DATA 108 00653 00654 /* Reason codes. */ 00655 # define CRYPTO_R_FIPS_MODE_NOT_SUPPORTED 101 00656 # define CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK 100 00657 00658 #ifdef __cplusplus 00659 } 00660 #endif 00661 #endif