00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
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
00139 #include <openssl/symhacks.h>
00140
00141 #ifdef __cplusplus
00142 extern "C" {
00143 #endif
00144
00145
00146
00147
00148 #define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER
00149 #define SSLEAY_VERSION 0
00150
00151 #define SSLEAY_CFLAGS 2
00152 #define SSLEAY_BUILT_ON 3
00153 #define SSLEAY_PLATFORM 4
00154 #define SSLEAY_DIR 5
00155
00156
00157 #if 0
00158 typedef struct crypto_ex_data_st CRYPTO_EX_DATA;
00159
00160 typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
00161 int idx, long argl, void *argp);
00162
00163 typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
00164 int idx, long argl, void *argp);
00165
00166 typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d,
00167 int idx, long argl, void *argp);
00168 #endif
00169
00170
00171 typedef struct openssl_item_st
00172 {
00173 int code;
00174 void *value;
00175 size_t value_size;
00176 size_t *value_length;
00177 } OPENSSL_ITEM;
00178
00179
00180
00181
00182
00183
00184 #define CRYPTO_LOCK_ERR 1
00185 #define CRYPTO_LOCK_EX_DATA 2
00186 #define CRYPTO_LOCK_X509 3
00187 #define CRYPTO_LOCK_X509_INFO 4
00188 #define CRYPTO_LOCK_X509_PKEY 5
00189 #define CRYPTO_LOCK_X509_CRL 6
00190 #define CRYPTO_LOCK_X509_REQ 7
00191 #define CRYPTO_LOCK_DSA 8
00192 #define CRYPTO_LOCK_RSA 9
00193 #define CRYPTO_LOCK_EVP_PKEY 10
00194 #define CRYPTO_LOCK_X509_STORE 11
00195 #define CRYPTO_LOCK_SSL_CTX 12
00196 #define CRYPTO_LOCK_SSL_CERT 13
00197 #define CRYPTO_LOCK_SSL_SESSION 14
00198 #define CRYPTO_LOCK_SSL_SESS_CERT 15
00199 #define CRYPTO_LOCK_SSL 16
00200 #define CRYPTO_LOCK_SSL_METHOD 17
00201 #define CRYPTO_LOCK_RAND 18
00202 #define CRYPTO_LOCK_RAND2 19
00203 #define CRYPTO_LOCK_MALLOC 20
00204 #define CRYPTO_LOCK_BIO 21
00205 #define CRYPTO_LOCK_GETHOSTBYNAME 22
00206 #define CRYPTO_LOCK_GETSERVBYNAME 23
00207 #define CRYPTO_LOCK_READDIR 24
00208 #define CRYPTO_LOCK_RSA_BLINDING 25
00209 #define CRYPTO_LOCK_DH 26
00210 #define CRYPTO_LOCK_MALLOC2 27
00211 #define CRYPTO_LOCK_DSO 28
00212 #define CRYPTO_LOCK_DYNLOCK 29
00213 #define CRYPTO_LOCK_ENGINE 30
00214 #define CRYPTO_LOCK_UI 31
00215 #define CRYPTO_LOCK_ECDSA 32
00216 #define CRYPTO_LOCK_EC 33
00217 #define CRYPTO_LOCK_ECDH 34
00218 #define CRYPTO_LOCK_BN 35
00219 #define CRYPTO_LOCK_EC_PRE_COMP 36
00220 #define CRYPTO_LOCK_STORE 37
00221 #define CRYPTO_LOCK_COMP 38
00222 #define CRYPTO_NUM_LOCKS 39
00223
00224 #define CRYPTO_LOCK 1
00225 #define CRYPTO_UNLOCK 2
00226 #define CRYPTO_READ 4
00227 #define CRYPTO_WRITE 8
00228
00229 #ifndef OPENSSL_NO_LOCKING
00230 #ifndef CRYPTO_w_lock
00231 #define CRYPTO_w_lock(type) \
00232 CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
00233 #define CRYPTO_w_unlock(type) \
00234 CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
00235 #define CRYPTO_r_lock(type) \
00236 CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__)
00237 #define CRYPTO_r_unlock(type) \
00238 CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__)
00239 #define CRYPTO_add(addr,amount,type) \
00240 CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__)
00241 #endif
00242 #else
00243 #define CRYPTO_w_lock(a)
00244 #define CRYPTO_w_unlock(a)
00245 #define CRYPTO_r_lock(a)
00246 #define CRYPTO_r_unlock(a)
00247 #define CRYPTO_add(a,b,c) ((*(a))+=(b))
00248 #endif
00249
00250
00251
00252
00253
00254 typedef struct
00255 {
00256 int references;
00257 struct CRYPTO_dynlock_value *data;
00258 } CRYPTO_dynlock;
00259
00260
00261
00262
00263
00264 #define CRYPTO_MEM_CHECK_OFF 0x0
00265 #define CRYPTO_MEM_CHECK_ON 0x1
00266 #define CRYPTO_MEM_CHECK_ENABLE 0x2
00267 #define CRYPTO_MEM_CHECK_DISABLE 0x3
00268
00269
00270
00271
00272
00273 #define V_CRYPTO_MDEBUG_TIME 0x1
00274
00275 #define V_CRYPTO_MDEBUG_THREAD 0x2
00276
00277 #define V_CRYPTO_MDEBUG_ALL (V_CRYPTO_MDEBUG_TIME | V_CRYPTO_MDEBUG_THREAD)
00278
00279
00280
00281 typedef struct bio_st BIO_dummy;
00282
00283 struct crypto_ex_data_st
00284 {
00285 STACK *sk;
00286 int dummy;
00287 };
00288
00289
00290
00291
00292 typedef struct crypto_ex_data_func_st
00293 {
00294 long argl;
00295 void *argp;
00296 CRYPTO_EX_new *new_func;
00297 CRYPTO_EX_free *free_func;
00298 CRYPTO_EX_dup *dup_func;
00299 } CRYPTO_EX_DATA_FUNCS;
00300
00301 DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS)
00302
00303
00304
00305
00306
00307 #define CRYPTO_EX_INDEX_BIO 0
00308 #define CRYPTO_EX_INDEX_SSL 1
00309 #define CRYPTO_EX_INDEX_SSL_CTX 2
00310 #define CRYPTO_EX_INDEX_SSL_SESSION 3
00311 #define CRYPTO_EX_INDEX_X509_STORE 4
00312 #define CRYPTO_EX_INDEX_X509_STORE_CTX 5
00313 #define CRYPTO_EX_INDEX_RSA 6
00314 #define CRYPTO_EX_INDEX_DSA 7
00315 #define CRYPTO_EX_INDEX_DH 8
00316 #define CRYPTO_EX_INDEX_ENGINE 9
00317 #define CRYPTO_EX_INDEX_X509 10
00318 #define CRYPTO_EX_INDEX_UI 11
00319 #define CRYPTO_EX_INDEX_ECDSA 12
00320 #define CRYPTO_EX_INDEX_ECDH 13
00321 #define CRYPTO_EX_INDEX_COMP 14
00322 #define CRYPTO_EX_INDEX_STORE 15
00323
00324
00325
00326 #define CRYPTO_EX_INDEX_USER 100
00327
00328
00329
00330
00331
00332
00333 #define CRYPTO_malloc_init() CRYPTO_set_mem_functions(\
00334 malloc, realloc, free)
00335
00336 #if defined CRYPTO_MDEBUG_ALL || defined CRYPTO_MDEBUG_TIME || defined CRYPTO_MDEBUG_THREAD
00337 # ifndef CRYPTO_MDEBUG
00338 # define CRYPTO_MDEBUG
00339 # endif
00340 #endif
00341
00342
00343
00344 #define CRYPTO_malloc_debug_init() do {\
00345 CRYPTO_set_mem_debug_functions(\
00346 CRYPTO_dbg_malloc,\
00347 CRYPTO_dbg_realloc,\
00348 CRYPTO_dbg_free,\
00349 CRYPTO_dbg_set_options,\
00350 CRYPTO_dbg_get_options);\
00351 } while(0)
00352
00353 int CRYPTO_mem_ctrl(int mode);
00354 int CRYPTO_is_mem_check_on(void);
00355
00356
00357 #define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON)
00358 #define MemCheck_stop() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF)
00359
00360
00361 #define MemCheck_on() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE)
00362 #define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE)
00363 #define is_MemCheck_on() CRYPTO_is_mem_check_on()
00364
00365 #define OPENSSL_malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__)
00366 #define OPENSSL_realloc(addr,num) \
00367 CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__)
00368 #define OPENSSL_realloc_clean(addr,old_num,num) \
00369 CRYPTO_realloc_clean(addr,old_num,num,__FILE__,__LINE__)
00370 #define OPENSSL_remalloc(addr,num) \
00371 CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__)
00372 #define OPENSSL_freeFunc CRYPTO_free
00373 #define OPENSSL_free(addr) CRYPTO_free(addr)
00374
00375 #define OPENSSL_malloc_locked(num) \
00376 CRYPTO_malloc_locked((int)num,__FILE__,__LINE__)
00377 #define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr)
00378
00379
00380 const char *SSLeay_version(int type);
00381 unsigned long SSLeay(void);
00382
00383 int OPENSSL_issetugid(void);
00384
00385
00386 typedef struct st_CRYPTO_EX_DATA_IMPL CRYPTO_EX_DATA_IMPL;
00387
00388 const CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void);
00389
00390 int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i);
00391
00392 int CRYPTO_ex_data_new_class(void);
00393
00394 int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,
00395 CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
00396 CRYPTO_EX_free *free_func);
00397
00398
00399 int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
00400 int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
00401 CRYPTO_EX_DATA *from);
00402 void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
00403
00404
00405 int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);
00406 void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad,int idx);
00407
00408
00409 void CRYPTO_cleanup_all_ex_data(void);
00410
00411 int CRYPTO_get_new_lockid(char *name);
00412
00413 int CRYPTO_num_locks(void);
00414 void CRYPTO_lock(int mode, int type,const char *file,int line);
00415 void CRYPTO_set_locking_callback(void (*func)(int mode,int type,
00416 const char *file,int line));
00417 void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char *file,
00418 int line);
00419 void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type,
00420 const char *file, int line));
00421 int (*CRYPTO_get_add_lock_callback(void))(int *num,int mount,int type,
00422 const char *file,int line);
00423 void CRYPTO_set_id_callback(unsigned long (*func)(void));
00424 unsigned long (*CRYPTO_get_id_callback(void))(void);
00425 unsigned long CRYPTO_thread_id(void);
00426 const char *CRYPTO_get_lock_name(int type);
00427 int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file,
00428 int line);
00429
00430 int CRYPTO_get_new_dynlockid(void);
00431 void CRYPTO_destroy_dynlockid(int i);
00432 struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i);
00433 void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*dyn_create_function)(const char *file, int line));
00434 void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line));
00435 void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)(struct CRYPTO_dynlock_value *l, const char *file, int line));
00436 struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))(const char *file,int line);
00437 void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, struct CRYPTO_dynlock_value *l, const char *file,int line);
00438 void (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l, const char *file,int line);
00439
00440
00441
00442 int CRYPTO_set_mem_functions(void *(*m)(size_t),void *(*r)(void *,size_t), void (*f)(void *));
00443 int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*free_func)(void *));
00444 int CRYPTO_set_mem_ex_functions(void *(*m)(size_t,const char *,int),
00445 void *(*r)(void *,size_t,const char *,int),
00446 void (*f)(void *));
00447 int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t,const char *,int),
00448 void (*free_func)(void *));
00449 int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int),
00450 void (*r)(void *,void *,int,const char *,int,int),
00451 void (*f)(void *,int),
00452 void (*so)(long),
00453 long (*go)(void));
00454 void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), void (**f)(void *));
00455 void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *));
00456 void CRYPTO_get_mem_ex_functions(void *(**m)(size_t,const char *,int),
00457 void *(**r)(void *, size_t,const char *,int),
00458 void (**f)(void *));
00459 void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t,const char *,int),
00460 void (**f)(void *));
00461 void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int),
00462 void (**r)(void *,void *,int,const char *,int,int),
00463 void (**f)(void *,int),
00464 void (**so)(long),
00465 long (**go)(void));
00466
00467 void *CRYPTO_malloc_locked(int num, const char *file, int line);
00468 void CRYPTO_free_locked(void *);
00469 void *CRYPTO_malloc(int num, const char *file, int line);
00470 void CRYPTO_free(void *);
00471 void *CRYPTO_realloc(void *addr,int num, const char *file, int line);
00472 void *CRYPTO_realloc_clean(void *addr,int old_num,int num,const char *file,
00473 int line);
00474 void *CRYPTO_remalloc(void *addr,int num, const char *file, int line);
00475
00476 void OPENSSL_cleanse(void *ptr, size_t len);
00477
00478 void CRYPTO_set_mem_debug_options(long bits);
00479 long CRYPTO_get_mem_debug_options(void);
00480
00481 #define CRYPTO_push_info(info) \
00482 CRYPTO_push_info_(info, __FILE__, __LINE__);
00483 int CRYPTO_push_info_(const char *info, const char *file, int line);
00484 int CRYPTO_pop_info(void);
00485 int CRYPTO_remove_all_info(void);
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495 void CRYPTO_dbg_malloc(void *addr,int num,const char *file,int line,int before_p);
00496 void CRYPTO_dbg_realloc(void *addr1,void *addr2,int num,const char *file,int line,int before_p);
00497 void CRYPTO_dbg_free(void *addr,int before_p);
00498
00499
00500
00501
00502
00503
00504
00505
00506 void CRYPTO_dbg_set_options(long bits);
00507 long CRYPTO_dbg_get_options(void);
00508
00509
00510 #ifndef OPENSSL_NO_FP_API
00511 void CRYPTO_mem_leaks_fp(FILE *);
00512 #endif
00513 void CRYPTO_mem_leaks(struct bio_st *bio);
00514
00515 typedef void *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *);
00516 void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb);
00517
00518
00519 void OpenSSLDie(const char *file,int line,const char *assertion);
00520 #define OPENSSL_assert(e) (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1))
00521
00522 unsigned long *OPENSSL_ia32cap_loc(void);
00523 #define OPENSSL_ia32cap (*(OPENSSL_ia32cap_loc()))
00524
00525
00526
00527
00528
00529 void ERR_load_CRYPTO_strings(void);
00530
00531
00532
00533
00534 #define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 100
00535 #define CRYPTO_F_CRYPTO_GET_NEW_DYNLOCKID 103
00536 #define CRYPTO_F_CRYPTO_GET_NEW_LOCKID 101
00537 #define CRYPTO_F_CRYPTO_SET_EX_DATA 102
00538 #define CRYPTO_F_DEF_ADD_INDEX 104
00539 #define CRYPTO_F_DEF_GET_CLASS 105
00540 #define CRYPTO_F_INT_DUP_EX_DATA 106
00541 #define CRYPTO_F_INT_FREE_EX_DATA 107
00542 #define CRYPTO_F_INT_NEW_EX_DATA 108
00543
00544
00545 #define CRYPTO_R_NO_DYNLOCK_CREATE_CALLBACK 100
00546
00547 #ifdef __cplusplus
00548 }
00549 #endif
00550 #endif