1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117: #ifndef HEADER_CRYPTO_H
118: #define HEADER_CRYPTO_H
119:
120: #include <stdlib.h>
121:
122: #include <openssl/e_os2.h>
123:
124: #ifndef OPENSSL_NO_FP_API
125: #include <stdio.h>
126: #endif
127:
128: #include <openssl/stack.h>
129: #include <openssl/safestack.h>
130: #include <openssl/opensslv.h>
131: #include <openssl/ossl_typ.h>
132:
133: #ifdef CHARSET_EBCDIC
134: #include <openssl/ebcdic.h>
135: #endif
136:
137:
138:
139: #include <openssl/symhacks.h>
140:
141: #ifdef __cplusplus
142: extern "C" {
143: #endif
144:
145:
146:
147:
148: #define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER
149: #define SSLEAY_VERSION 0
150:
151: #define SSLEAY_CFLAGS 2
152: #define SSLEAY_BUILT_ON 3
153: #define SSLEAY_PLATFORM 4
154: #define SSLEAY_DIR 5
155:
156:
157: #if 0
158: typedef struct crypto_ex_data_st CRYPTO_EX_DATA;
159:
160: typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
161: int idx, long argl, void *argp);
162:
163: typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
164: int idx, long argl, void *argp);
165:
166: typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d,
167: int idx, long argl, void *argp);
168: #endif
169:
170:
171: typedef struct openssl_item_st
172: {
173: int code;
174: void *value;
175: size_t value_size;
176: size_t *value_length;
177: } OPENSSL_ITEM;
178:
179:
180:
181:
182:
183:
184: #define CRYPTO_LOCK_ERR 1
185: #define CRYPTO_LOCK_EX_DATA 2
186: #define CRYPTO_LOCK_X509 3
187: #define CRYPTO_LOCK_X509_INFO 4
188: #define CRYPTO_LOCK_X509_PKEY 5
189: #define CRYPTO_LOCK_X509_CRL 6
190: #define CRYPTO_LOCK_X509_REQ 7
191: #define CRYPTO_LOCK_DSA 8
192: #define CRYPTO_LOCK_RSA 9
193: #define CRYPTO_LOCK_EVP_PKEY 10
194: #define CRYPTO_LOCK_X509_STORE 11
195: #define CRYPTO_LOCK_SSL_CTX 12
196: #define CRYPTO_LOCK_SSL_CERT 13
197: #define CRYPTO_LOCK_SSL_SESSION 14
198: #define CRYPTO_LOCK_SSL_SESS_CERT 15
199: #define CRYPTO_LOCK_SSL 16
200: #define CRYPTO_LOCK_SSL_METHOD 17
201: #define CRYPTO_LOCK_RAND 18
202: #define CRYPTO_LOCK_RAND2 19
203: #define CRYPTO_LOCK_MALLOC 20
204: #define CRYPTO_LOCK_BIO 21
205: #define CRYPTO_LOCK_GETHOSTBYNAME 22
206: #define CRYPTO_LOCK_GETSERVBYNAME 23
207: #define CRYPTO_LOCK_READDIR 24
208: #define CRYPTO_LOCK_RSA_BLINDING 25
209: #define CRYPTO_LOCK_DH 26
210: #define CRYPTO_LOCK_MALLOC2 27
211: #define CRYPTO_LOCK_DSO 28
212: #define CRYPTO_LOCK_DYNLOCK 29
213: #define CRYPTO_LOCK_ENGINE 30
214: #define CRYPTO_LOCK_UI 31
215: #define CRYPTO_LOCK_ECDSA 32
216: #define CRYPTO_LOCK_EC 33
217: #define CRYPTO_LOCK_ECDH 34
218: #define CRYPTO_LOCK_BN 35
219: #define CRYPTO_LOCK_EC_PRE_COMP 36
220: #define CRYPTO_LOCK_STORE 37
221: #define CRYPTO_LOCK_COMP 38
222: #define CRYPTO_NUM_LOCKS 39
223:
224: #define CRYPTO_LOCK 1
225: #define CRYPTO_UNLOCK 2
226: #define CRYPTO_READ 4
227: #define CRYPTO_WRITE 8
228:
229: #ifndef OPENSSL_NO_LOCKING
230: #ifndef CRYPTO_w_lock
231: #define CRYPTO_w_lock(type) \
232: CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
233: #define CRYPTO_w_unlock(type) \
234: CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
235: #define CRYPTO_r_lock(type) \
236: CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__)
237: #define CRYPTO_r_unlock(type) \
238: CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__)
239: #define CRYPTO_add(addr,amount,type) \
240: CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__)
241: #endif
242: #else
243: #define CRYPTO_w_lock(a)
244: #define CRYPTO_w_unlock(a)
245: #define CRYPTO_r_lock(a)
246: #define CRYPTO_r_unlock(a)
247: #define CRYPTO_add(a,b,c) ((*(a))+=(b))
248: #endif
249:
250:
251:
252:
253:
254: typedef struct
255: {
256: int references;
257: struct CRYPTO_dynlock_value *data;
258: } CRYPTO_dynlock;
259:
260:
261:
262:
263:
264: #define CRYPTO_MEM_CHECK_OFF 0x0
265: #define CRYPTO_MEM_CHECK_ON 0x1
266: #define CRYPTO_MEM_CHECK_ENABLE 0x2
267: #define CRYPTO_MEM_CHECK_DISABLE 0x3
268:
269:
270:
271:
272:
273: #define V_CRYPTO_MDEBUG_TIME 0x1
274:
275: #define V_CRYPTO_MDEBUG_THREAD 0x2
276:
277: #define V_CRYPTO_MDEBUG_ALL (V_CRYPTO_MDEBUG_TIME | V_CRYPTO_MDEBUG_THREAD)
278:
279:
280:
281: typedef struct bio_st BIO_dummy;
282:
283: struct crypto_ex_data_st
284: {
285: STACK *sk;
286: int dummy;
287: };
288:
289:
290:
291:
292: typedef struct crypto_ex_data_func_st
293: {
294: long argl;
295: void *argp;
296: CRYPTO_EX_new *new_func;
297: CRYPTO_EX_free *free_func;
298: CRYPTO_EX_dup *dup_func;
299: } CRYPTO_EX_DATA_FUNCS;
300:
301: DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS)
302:
303:
304:
305:
306:
307: #define CRYPTO_EX_INDEX_BIO 0
308: #define CRYPTO_EX_INDEX_SSL 1
309: #define CRYPTO_EX_INDEX_SSL_CTX 2
310: #define CRYPTO_EX_INDEX_SSL_SESSION 3
311: #define CRYPTO_EX_INDEX_X509_STORE 4
312: #define CRYPTO_EX_INDEX_X509_STORE_CTX 5
313: #define CRYPTO_EX_INDEX_RSA 6
314: #define CRYPTO_EX_INDEX_DSA 7
315: #define CRYPTO_EX_INDEX_DH 8
316: #define CRYPTO_EX_INDEX_ENGINE 9
317: #define CRYPTO_EX_INDEX_X509 10
318: #define CRYPTO_EX_INDEX_UI 11
319: #define CRYPTO_EX_INDEX_ECDSA 12
320: #define CRYPTO_EX_INDEX_ECDH 13
321: #define CRYPTO_EX_INDEX_COMP 14
322: #define CRYPTO_EX_INDEX_STORE 15
323:
324:
325:
326: #define CRYPTO_EX_INDEX_USER 100
327:
328:
329:
330:
331:
332:
333: #define CRYPTO_malloc_init() CRYPTO_set_mem_functions(\
334: malloc, realloc, free)
335:
336: #if defined CRYPTO_MDEBUG_ALL || defined CRYPTO_MDEBUG_TIME || defined CRYPTO_MDEBUG_THREAD
337: # ifndef CRYPTO_MDEBUG
338: # define CRYPTO_MDEBUG
339: # endif
340: #endif
341:
342:
343:
344: #define CRYPTO_malloc_debug_init() do {\
345: CRYPTO_set_mem_debug_functions(\
346: CRYPTO_dbg_malloc,\
347: CRYPTO_dbg_realloc,\
348: CRYPTO_dbg_free,\
349: CRYPTO_dbg_set_options,\
350: CRYPTO_dbg_get_options);\
351: } while(0)
352:
353: int CRYPTO_mem_ctrl(int mode);
354: int CRYPTO_is_mem_check_on(void);
355:
356:
357: #define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON)
358: #define MemCheck_stop() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF)
359:
360:
361: #define MemCheck_on() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE)
362: #define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE)
363: #define is_MemCheck_on() CRYPTO_is_mem_check_on()
364:
365: #define OPENSSL_malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__)
366: #define OPENSSL_realloc(addr,num) \
367: CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__)
368: #define OPENSSL_realloc_clean(addr,old_num,num) \
369: CRYPTO_realloc_clean(addr,old_num,num,__FILE__,__LINE__)
370: #define OPENSSL_remalloc(addr,num) \
371: CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__)
372: #define OPENSSL_freeFunc CRYPTO_free
373: #define OPENSSL_free(addr) CRYPTO_free(addr)
374:
375: #define OPENSSL_malloc_locked(num) \
376: CRYPTO_malloc_locked((int)num,__FILE__,__LINE__)
377: #define OPENSSL_free_locked(addr) CRYPTO_free_locked(addr)
378:
379:
380: const char *SSLeay_version(int type);
381: unsigned long SSLeay(void);
382:
383: int OPENSSL_issetugid(void);
384:
385:
386: typedef struct st_CRYPTO_EX_DATA_IMPL CRYPTO_EX_DATA_IMPL;
387:
388: const CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void);
389:
390: int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i);
391:
392: int CRYPTO_ex_data_new_class(void);
393:
394: int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,
395: CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
396: CRYPTO_EX_free *free_func);
397:
398:
399: int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
400: int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
401: CRYPTO_EX_DATA *from);
402: void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
403:
404:
405: int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);
406: void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad,int idx);
407:
408:
409: void CRYPTO_cleanup_all_ex_data(void);
410:
411: int CRYPTO_get_new_lockid(char *name);
412:
413: int CRYPTO_num_locks(void);
414: void CRYPTO_lock(int mode, int type,const char *file,int line);
415: void CRYPTO_set_locking_callback(void (*func)(int mode,int type,
416: const char *file,int line));
417: void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char *file,
418: int line);
419: void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type,
420: const char *file, int line));
421: int (*CRYPTO_get_add_lock_callback(void))(int *num,int mount,int type,
422: const char *file,int line);
423: void CRYPTO_set_id_callback(unsigned long (*func)(void));
424: unsigned long (*CRYPTO_get_id_callback(void))(void);
425: unsigned long CRYPTO_thread_id(void);
426: const char *CRYPTO_get_lock_name(int type);
427: int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file,
428: int line);
429:
430: int CRYPTO_get_new_dynlockid(void);
431: void CRYPTO_destroy_dynlockid(int i);
432: struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i);
433: void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*dyn_create_function)(const char *file, int line));
434: void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line));
435: void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)(struct CRYPTO_dynlock_value *l, const char *file, int line));
436: struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))(const char *file,int line);
437: void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, struct CRYPTO_dynlock_value *l, const char *file,int line);
438: void (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l, const char *file,int line);
439:
440:
441:
442: int CRYPTO_set_mem_functions(void *(*m)(size_t),void *(*r)(void *,size_t), void (*f)(void *));
443: int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*free_func)(void *));
444: int CRYPTO_set_mem_ex_functions(void *(*m)(size_t,const char *,int),
445: void *(*r)(void *,size_t,const char *,int),
446: void (*f)(void *));
447: int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t,const char *,int),
448: void (*free_func)(void *));
449: int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int),
450: void (*r)(void *,void *,int,const char *,int,int),
451: void (*f)(void *,int),
452: void (*so)(long),
453: long (*go)(void));
454: void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), void (**f)(void *));
455: void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *));
456: void CRYPTO_get_mem_ex_functions(void *(**m)(size_t,const char *,int),
457: void *(**r)(void *, size_t,const char *,int),
458: void (**f)(void *));
459: void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t,const char *,int),
460: void (**f)(void *));
461: void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int),
462: void (**r)(void *,void *,int,const char *,int,int),
463: void (**f)(void *,int),
464: void (**so)(long),
465: long (**go)(void));
466:
467: void *CRYPTO_malloc_locked(int num, const char *file, int line);
468: void CRYPTO_free_locked(void *);
469: void *CRYPTO_malloc(int num, const char *file, int line);
470: void CRYPTO_free(void *);
471: void *CRYPTO_realloc(void *addr,int num, const char *file, int line);
472: void *CRYPTO_realloc_clean(void *addr,int old_num,int num,const char *file,
473: int line);
474: void *CRYPTO_remalloc(void *addr,int num, const char *file, int line);
475:
476: void OPENSSL_cleanse(void *ptr, size_t len);
477:
478: void CRYPTO_set_mem_debug_options(long bits);
479: long CRYPTO_get_mem_debug_options(void);
480:
481: #define CRYPTO_push_info(info) \
482: CR