]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/crypto.h
Import of old SSLeay release: SSLeay 0.8.1b
[thirdparty/openssl.git] / crypto / crypto.h
CommitLineData
d02b48c6
RE
1/* crypto/crypto.h */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef HEADER_CRYPTO_H
60#define HEADER_CRYPTO_H
61
62#ifdef __cplusplus
63extern "C" {
64#endif
65
66/* This is more to be used to check the correct DLL is being used
67 * in the MS world. */
68#define SSLEAY_VERSION_NUMBER 0x0800 /* Version 0.5.1c would be 0513 */
69
70#define SSLEAY_VERSION 0
71/* #define SSLEAY_OPTIONS 1 no longer supported */
72#define SSLEAY_CFLAGS 2
73#define SSLEAY_BUILT_ON 3
74
75/* When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock
76 * names in cryptlib.c
77 */
78
79#define CRYPTO_LOCK_ERR 1
80#define CRYPTO_LOCK_ERR_HASH 2
81#define CRYPTO_LOCK_X509 3
82#define CRYPTO_LOCK_X509_INFO 4
83#define CRYPTO_LOCK_X509_PKEY 5
84#define CRYPTO_LOCK_X509_CRL 6
85#define CRYPTO_LOCK_X509_REQ 7
86#define CRYPTO_LOCK_DSA 8
87#define CRYPTO_LOCK_RSA 9
88#define CRYPTO_LOCK_EVP_PKEY 10
89#define CRYPTO_LOCK_X509_STORE 11
90#define CRYPTO_LOCK_SSL_CTX 12
91#define CRYPTO_LOCK_SSL_CERT 13
92#define CRYPTO_LOCK_SSL_SESSION 14
93#define CRYPTO_LOCK_SSL 15
94#define CRYPTO_LOCK_RAND 16
95#define CRYPTO_LOCK_MALLOC 17
96#define CRYPTO_LOCK_BIO 18
97#define CRYPTO_LOCK_BIO_GETHOSTBYNAME 19
98#define CRYPTO_NUM_LOCKS 20
99
100#define CRYPTO_LOCK 1
101#define CRYPTO_UNLOCK 2
102#define CRYPTO_READ 4
103#define CRYPTO_WRITE 8
104
105/* The following stuff is not being used, it was not finished for
106 * SSLeay 0.6.0 */
107#ifndef CRYPTO_w_lock
108#define CRYPTO_w_lock(type) \
109 CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
110#define CRYPTO_w_unlock(type) \
111 CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,__FILE__,__LINE__)
112#define CRYPTO_r_lock(type) \
113 CRYPTO_lock(CRYPTO_LOCK|CRYPTO_READ,type,__FILE__,__LINE__)
114#define CRYPTO_r_unlock(type) \
115 CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_READ,type,__FILE__,__LINE__)
116#define CRYPTO_add(addr,amount,type) \
117 CRYPTO_add_lock(addr,amount,type,__FILE__,__LINE__)
118
119#endif
120
121/* The following can be used to detect memory leaks in the SSLeay library.
122 * It used, it turns on malloc checking */
123
124#define CRYPTO_MEM_CHECK_OFF 0x0
125#define CRYPTO_MEM_CHECK_ON 0x1
126
127/*
128typedef struct crypto_mem_st
129 {
130 char *(*malloc_func)();
131 char *(*realloc_func)();
132 void (*free_func)();
133 } CRYPTO_MEM_FUNC;
134*/
135
136
137/* Use this for win32 DLL's */
138#define CRYPTO_malloc_init() CRYPTO_set_mem_functions(\
139 (char *(*)())malloc,\
140 (char *(*)())realloc,\
141 (void (*)())free)
142
143#ifdef CRYPTO_MDEBUG
144#define Malloc(num) CRYPTO_dbg_malloc((int)num,__FILE__,__LINE__)
145#define Realloc(addr,num) \
146 CRYPTO_dbg_realloc((char *)addr,(int)num,__FILE__,__LINE__)
147#define Remalloc(addr,num) \
148 CRYPTO_dbg_remalloc((char **)addr,(int)num,__FILE__,__LINE__)
149#define FreeFunc CRYPTO_dbg_free
150#define Free(addr) CRYPTO_dbg_free((char *)(addr))
151#else
152#define Remalloc CRYPTO_remalloc
153#if defined(WIN32) || defined(MFUNC)
154#define Malloc CRYPTO_malloc
155#define Realloc(a,n) CRYPTO_realloc((char *)(a),(n))
156#define FreeFunc CRYPTO_free
157#define Free(addr) CRYPTO_free((char *)(addr))
158#else
159#define Malloc malloc
160#define Realloc realloc
161#define FreeFunc free
162#define Free(addr) free((char *)(addr))
163#endif /* WIN32 || MFUNC */
164#endif /* MDEBUG */
165
166#ifndef NOPROTO
167
168char *SSLeay_version(int type);
169unsigned long SSLeay(void);
170
171int CRYPTO_mem_ctrl(int mode);
172void CRYPTO_lock(int mode, int type,char *file,int line);
173void CRYPTO_set_locking_callback(void (*func)(int mode,int type,char *file,
174 int line));
175void (*CRYPTO_get_locking_callback(void))(int mode,int type,char *file,
176 int line);
177void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,
178 int type,char *file, int line));
179int (*CRYPTO_get_add_lock_callback(void))(int *num,int mount,
180 int type,char *file,int line);
181void CRYPTO_set_id_callback(unsigned long (*func)(void));
182unsigned long (*CRYPTO_get_id_callback(void))(void);
183unsigned long CRYPTO_thread_id(void);
184char *CRYPTO_get_lock_name(int type);
185int CRYPTO_add_lock(int *pointer,int amount,int type, char *file,int line);
186
187void CRYPTO_set_mem_functions(char *(*m)(),char *(*r)(), void (*free_func)());
188void CRYPTO_get_mem_functions(char *(**m)(),char *(**r)(), void (**f)());
189
190char *CRYPTO_malloc(int num);
191char *CRYPTO_realloc(char *addr,int num);
192void CRYPTO_free(char *);
193char *CRYPTO_remalloc(char *addr,int num);
194
195char *CRYPTO_dbg_malloc(int num,char *file,int line);
196char *CRYPTO_dbg_realloc(char *addr,int num,char *file,int line);
197void CRYPTO_dbg_free(char *);
198char *CRYPTO_dbg_remalloc(char *addr,int num,char *file,int line);
199#ifndef WIN16
200void CRYPTO_mem_leaks_fp(FILE *);
201#endif
202#ifdef HEADER_BIO_H
203void CRYPTO_mem_leaks(BIO *);
204#endif
205/* unsigned long order, char *file, int line, int num_bytes, char *addr */
206void CRYPTO_mem_leaks_cb(void (*cb)());
207
208#else
209
210int CRYPTO_mem_ctrl();
211char *SSLeay_version();
212unsigned long SSLeay();
213
214void CRYPTO_lock();
215void CRYPTO_set_locking_callback();
216void (*CRYPTO_get_locking_callback())();
217void CRYPTO_set_add_lock_callback();
218int (*CRYPTO_get_add_lock_callback())();
219void CRYPTO_set_id_callback();
220unsigned long (*CRYPTO_get_id_callback())();
221unsigned long CRYPTO_thread_id();
222char *CRYPTO_get_lock_name();
223int CRYPTO_add_lock();
224
225void CRYPTO_set_mem_functions();
226void CRYPTO_get_mem_functions();
227char *CRYPTO_malloc();
228char *CRYPTO_realloc();
229void CRYPTO_free();
230char *CRYPTO_remalloc();
231char *CRYPTO_dbg_remalloc();
232char *CRYPTO_dbg_malloc();
233char *CRYPTO_dbg_realloc();
234void CRYPTO_dbg_free();
235#ifndef WIN16
236void CRYPTO_mem_leaks_fp();
237#endif
238void CRYPTO_mem_leaks();
239void CRYPTO_mem_leaks_cb();
240
241#endif
242
243#ifdef __cplusplus
244}
245#endif
246
247#endif