summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/crypto.h
diff options
context:
space:
mode:
authorbeck <>2000-03-19 11:13:58 +0000
committerbeck <>2000-03-19 11:13:58 +0000
commit796d609550df3a33fc11468741c5d2f6d3df4c11 (patch)
tree6c6d539061caa20372dad0ac4ddb1dfae2fbe7fe /src/lib/libcrypto/crypto.h
parent5be3114c1fd7e0dfea1e38d3abb4cbba75244419 (diff)
downloadopenbsd-796d609550df3a33fc11468741c5d2f6d3df4c11.tar.gz
openbsd-796d609550df3a33fc11468741c5d2f6d3df4c11.tar.bz2
openbsd-796d609550df3a33fc11468741c5d2f6d3df4c11.zip
OpenSSL 0.9.5 merge
*warning* this bumps shared lib minors for libssl and libcrypto from 2.1 to 2.2 if you are using the ssl26 packages for ssh and other things to work you will need to get new ones (see ~beck/libsslsnap/<arch>) on cvs or ~beck/src-patent.tar.gz on cvs
Diffstat (limited to 'src/lib/libcrypto/crypto.h')
-rw-r--r--src/lib/libcrypto/crypto.h204
1 files changed, 121 insertions, 83 deletions
diff --git a/src/lib/libcrypto/crypto.h b/src/lib/libcrypto/crypto.h
index 8ad8c25e5a..41c937966e 100644
--- a/src/lib/libcrypto/crypto.h
+++ b/src/lib/libcrypto/crypto.h
@@ -63,17 +63,25 @@
63extern "C" { 63extern "C" {
64#endif 64#endif
65 65
66#include <stdlib.h>
67
66#ifndef NO_FP_API 68#ifndef NO_FP_API
67#include <stdio.h> 69#include <stdio.h>
68#endif 70#endif
69 71
70#include <openssl/stack.h> 72#include <openssl/stack.h>
73#include <openssl/safestack.h>
71#include <openssl/opensslv.h> 74#include <openssl/opensslv.h>
72 75
73#ifdef CHARSET_EBCDIC 76#ifdef CHARSET_EBCDIC
74#include <openssl/ebcdic.h> 77#include <openssl/ebcdic.h>
75#endif 78#endif
76 79
80#if defined(VMS) || defined(__VMS)
81#include "vms_idhacks.h"
82#endif
83
84
77/* Backward compatibility to SSLeay */ 85/* Backward compatibility to SSLeay */
78/* This is more to be used to check the correct DLL is being used 86/* This is more to be used to check the correct DLL is being used
79 * in the MS world. */ 87 * in the MS world. */
@@ -111,7 +119,9 @@ extern "C" {
111#define CRYPTO_LOCK_GETSERVBYNAME 21 119#define CRYPTO_LOCK_GETSERVBYNAME 21
112#define CRYPTO_LOCK_READDIR 22 120#define CRYPTO_LOCK_READDIR 22
113#define CRYPTO_LOCK_RSA_BLINDING 23 121#define CRYPTO_LOCK_RSA_BLINDING 23
114#define CRYPTO_NUM_LOCKS 24 122#define CRYPTO_LOCK_DH 24
123#define CRYPTO_LOCK_MALLOC2 25
124#define CRYPTO_NUM_LOCKS 26
115 125
116#define CRYPTO_LOCK 1 126#define CRYPTO_LOCK 1
117#define CRYPTO_UNLOCK 2 127#define CRYPTO_UNLOCK 2
@@ -147,14 +157,16 @@ extern "C" {
147#define CRYPTO_MEM_CHECK_ENABLE 0x2 /* a bit */ 157#define CRYPTO_MEM_CHECK_ENABLE 0x2 /* a bit */
148#define CRYPTO_MEM_CHECK_DISABLE 0x3 /* an enume */ 158#define CRYPTO_MEM_CHECK_DISABLE 0x3 /* an enume */
149 159
150/* 160/* The following are bit values to turn on or off options connected to the
151typedef struct crypto_mem_st 161 * malloc checking functionality */
152 { 162
153 char *(*malloc_func)(); 163/* Adds time to the memory checking information */
154 char *(*realloc_func)(); 164#define V_CRYPTO_MDEBUG_TIME 0x1 /* a bit */
155 void (*free_func)(); 165/* Adds thread number to the memory checking information */
156 } CRYPTO_MEM_FUNC; 166#define V_CRYPTO_MDEBUG_THREAD 0x2 /* a bit */
157*/ 167
168#define V_CRYPTO_MDEBUG_ALL (V_CRYPTO_MDEBUG_TIME | V_CRYPTO_MDEBUG_THREAD)
169
158 170
159/* predec of the BIO type */ 171/* predec of the BIO type */
160typedef struct bio_st BIO_dummy; 172typedef struct bio_st BIO_dummy;
@@ -165,24 +177,30 @@ typedef struct crypto_ex_data_st
165 int dummy; /* gcc is screwing up this data structure :-( */ 177 int dummy; /* gcc is screwing up this data structure :-( */
166 } CRYPTO_EX_DATA; 178 } CRYPTO_EX_DATA;
167 179
180/* Called when a new object is created */
181typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
182 int idx, long argl, void *argp);
183/* Called when an object is free()ed */
184typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
185 int idx, long argl, void *argp);
186/* Called when we need to dup an object */
187typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d,
188 int idx, long argl, void *argp);
189
168/* This stuff is basically class callback functions 190/* This stuff is basically class callback functions
169 * The current classes are SSL_CTX, SSL, SSL_SESION, and a few more */ 191 * The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more */
192
170typedef struct crypto_ex_data_func_st 193typedef struct crypto_ex_data_func_st
171 { 194 {
172 long argl; /* Arbitary long */ 195 long argl; /* Arbitary long */
173 char *argp; /* Arbitary char * */ 196 void *argp; /* Arbitary void * */
174 /* Called when a new object is created */ 197 CRYPTO_EX_new *new_func;
175 int (*new_func)(/*char *obj, 198 CRYPTO_EX_free *free_func;
176 char *item,int index,long argl,char *argp*/); 199 CRYPTO_EX_dup *dup_func;
177 /* Called when this object is free()ed */
178 void (*free_func)(/*char *obj,
179 char *item,int index,long argl,char *argp*/);
180
181 /* Called when we need to dup this one */
182 int (*dup_func)(/*char *obj_to,char *obj_from,
183 char **new,int index,long argl,char *argp*/);
184 } CRYPTO_EX_DATA_FUNCS; 200 } CRYPTO_EX_DATA_FUNCS;
185 201
202DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS)
203
186/* Per class, we have a STACK of CRYPTO_EX_DATA_FUNCS for each CRYPTO_EX_DATA 204/* Per class, we have a STACK of CRYPTO_EX_DATA_FUNCS for each CRYPTO_EX_DATA
187 * entry. 205 * entry.
188 */ 206 */
@@ -194,63 +212,54 @@ typedef struct crypto_ex_data_func_st
194#define CRYPTO_EX_INDEX_X509_STORE 4 212#define CRYPTO_EX_INDEX_X509_STORE 4
195#define CRYPTO_EX_INDEX_X509_STORE_CTX 5 213#define CRYPTO_EX_INDEX_X509_STORE_CTX 5
196 214
197/* Use this for win32 DLL's */
198#define CRYPTO_malloc_init() CRYPTO_set_mem_functions(\
199 (char *(*)())malloc,\
200 (char *(*)())realloc,\
201 (void (*)())free)
202 215
203#ifdef CRYPTO_MDEBUG_ALL 216/* This is the default callbacks, but we can have others as well:
204# ifndef CRYPTO_MDEBUG_TIME 217 * this is needed in Win32 where the application malloc and the
205# define CRYPTO_MDEBUG_TIME 218 * library malloc may not be the same.
206# endif 219 */
207# ifndef CRYPTO_MDEBUG_THREAD 220#define CRYPTO_malloc_init() CRYPTO_set_mem_functions(\
208# define CRYPTO_MDEBUG_THREAD 221 malloc, realloc, free)
209# endif
210#endif
211 222
212#if defined CRYPTO_MDEBUG_TIME || defined CRYPTO_MDEBUG_THREAD 223#if defined CRYPTO_MDEBUG_ALL || defined CRYPTO_MDEBUG_TIME || defined CRYPTO_MDEBUG_THREAD
213# ifndef CRYPTO_MDEBUG /* avoid duplicate #define */ 224# ifndef CRYPTO_MDEBUG /* avoid duplicate #define */
214# define CRYPTO_MDEBUG 225# define CRYPTO_MDEBUG
215# endif 226# endif
216#endif 227#endif
217 228
218#ifdef CRYPTO_MDEBUG 229/* Set standard debugging functions (not done by default
230 * unless CRYPTO_MDEBUG is defined) */
231#define CRYPTO_malloc_debug_init() do {\
232 CRYPTO_set_mem_debug_functions(\
233 (void (*)())CRYPTO_dbg_malloc,\
234 (void (*)())CRYPTO_dbg_realloc,\
235 (void (*)())CRYPTO_dbg_free,\
236 (void (*)())CRYPTO_dbg_set_options,\
237 (long (*)())CRYPTO_dbg_get_options);\
238 } while(0)
239
240int CRYPTO_mem_ctrl(int mode);
241int CRYPTO_is_mem_check_on(void);
242
243/* for applications */
219#define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON) 244#define MemCheck_start() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON)
220#define MemCheck_stop() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF) 245#define MemCheck_stop() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_OFF)
246
247/* for library-internal use */
221#define MemCheck_on() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE) 248#define MemCheck_on() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE)
222#define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE) 249#define MemCheck_off() CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE)
223#define Malloc(num) CRYPTO_dbg_malloc((int)num,__FILE__,__LINE__) 250#define is_MemCheck_on() CRYPTO_is_mem_check_on()
251
252#define Malloc(num) CRYPTO_malloc((int)num,__FILE__,__LINE__)
224#define Realloc(addr,num) \ 253#define Realloc(addr,num) \
225 CRYPTO_dbg_realloc((char *)addr,(int)num,__FILE__,__LINE__) 254 CRYPTO_realloc((char *)addr,(int)num,__FILE__,__LINE__)
226#define Remalloc(addr,num) \ 255#define Remalloc(addr,num) \
227 CRYPTO_dbg_remalloc((char **)addr,(int)num,__FILE__,__LINE__) 256 CRYPTO_remalloc((char **)addr,(int)num,__FILE__,__LINE__)
228#define FreeFunc CRYPTO_dbg_free
229#define Free(addr) CRYPTO_dbg_free(addr)
230#define Malloc_locked(num) CRYPTO_malloc_locked((int)num)
231#define Free_locked(addr) CRYPTO_free_locked(addr)
232#else
233#define MemCheck_start()
234#define MemCheck_stop()
235#define MemCheck_on()
236#define MemCheck_off()
237#define Remalloc CRYPTO_remalloc
238#if defined(WIN32) || defined(MFUNC)
239#define Malloc CRYPTO_malloc
240#define Realloc(a,n) CRYPTO_realloc(a,(n))
241#define FreeFunc CRYPTO_free 257#define FreeFunc CRYPTO_free
242#define Free(addr) CRYPTO_free(addr) 258#define Free(addr) CRYPTO_free(addr)
243#define Malloc_locked CRYPTO_malloc_locked 259
260#define Malloc_locked(num) CRYPTO_malloc_locked((int)num,__FILE__,__LINE__)
244#define Free_locked(addr) CRYPTO_free_locked(addr) 261#define Free_locked(addr) CRYPTO_free_locked(addr)
245#else 262
246#define Malloc malloc
247#define Realloc realloc
248#define FreeFunc free
249#define Free(addr) free(addr)
250#define Malloc_locked malloc
251#define Free_locked(addr) free(addr)
252#endif /* WIN32 || MFUNC */
253#endif /* MDEBUG */
254 263
255/* Case insensiteve linking causes problems.... */ 264/* Case insensiteve linking causes problems.... */
256#if defined(WIN16) || defined(VMS) 265#if defined(WIN16) || defined(VMS)
@@ -261,15 +270,15 @@ typedef struct crypto_ex_data_func_st
261const char *SSLeay_version(int type); 270const char *SSLeay_version(int type);
262unsigned long SSLeay(void); 271unsigned long SSLeay(void);
263 272
264int CRYPTO_get_ex_new_index(int idx,STACK **sk,long argl,char *argp, 273int CRYPTO_get_ex_new_index(int idx, STACK_OF(CRYPTO_EX_DATA_FUNCS) **skp, long argl, void *argp,
265 int (*new_func)(),int (*dup_func)(),void (*free_func)()); 274 CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
266int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad,int idx,char *val); 275int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);
267char *CRYPTO_get_ex_data(CRYPTO_EX_DATA *ad,int idx); 276void *CRYPTO_get_ex_data(CRYPTO_EX_DATA *ad,int idx);
268int CRYPTO_dup_ex_data(STACK *meth,CRYPTO_EX_DATA *from,CRYPTO_EX_DATA *to); 277int CRYPTO_dup_ex_data(STACK_OF(CRYPTO_EX_DATA_FUNCS) *meth, CRYPTO_EX_DATA *to,
269void CRYPTO_free_ex_data(STACK *meth,char *obj,CRYPTO_EX_DATA *ad); 278 CRYPTO_EX_DATA *from);
270void CRYPTO_new_ex_data(STACK *meth, char *obj, CRYPTO_EX_DATA *ad); 279void CRYPTO_free_ex_data(STACK_OF(CRYPTO_EX_DATA_FUNCS) *meth, void *obj, CRYPTO_EX_DATA *ad);
280void CRYPTO_new_ex_data(STACK_OF(CRYPTO_EX_DATA_FUNCS) *meth, void *obj, CRYPTO_EX_DATA *ad);
271 281
272int CRYPTO_mem_ctrl(int mode);
273int CRYPTO_get_new_lockid(char *name); 282int CRYPTO_get_new_lockid(char *name);
274 283
275int CRYPTO_num_locks(void); /* return CRYPTO_NUM_LOCKS (shared libs!) */ 284int CRYPTO_num_locks(void); /* return CRYPTO_NUM_LOCKS (shared libs!) */
@@ -289,22 +298,51 @@ const char *CRYPTO_get_lock_name(int type);
289int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file, 298int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file,
290 int line); 299 int line);
291 300
292void CRYPTO_set_mem_functions(char *(*m)(),char *(*r)(), void (*free_func)()); 301/* CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions --
293void CRYPTO_get_mem_functions(char *(**m)(),char *(**r)(), void (**f)()); 302 * call the latter last if you need different functions */
294void CRYPTO_set_locked_mem_functions(char *(*m)(), void (*free_func)()); 303int CRYPTO_set_mem_functions(void *(*m)(size_t),void *(*r)(void *,size_t), void (*f)(void *));
295void CRYPTO_get_locked_mem_functions(char *(**m)(), void (**f)()); 304int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*free_func)(void *));
305int CRYPTO_set_mem_debug_functions(void (*m)(),void (*r)(),void (*f)(),void (*so)(),long (*go)());
306void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), void (**f)(void *));
307void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *));
308void CRYPTO_get_mem_debug_functions(void (**m)(),void (**r)(),void (**f)(),void (**so)(),long (**go)());
296 309
297void *CRYPTO_malloc_locked(int num); 310void *CRYPTO_malloc_locked(int num, const char *file, int line);
298void CRYPTO_free_locked(void *); 311void CRYPTO_free_locked(void *);
299void *CRYPTO_malloc(int num); 312void *CRYPTO_malloc(int num, const char *file, int line);
300void CRYPTO_free(void *); 313void CRYPTO_free(void *);
301void *CRYPTO_realloc(void *addr,int num); 314void *CRYPTO_realloc(void *addr,int num, const char *file, int line);
302void *CRYPTO_remalloc(void *addr,int num); 315void *CRYPTO_remalloc(void *addr,int num, const char *file, int line);
316
317void CRYPTO_set_mem_debug_options(long bits);
318long CRYPTO_get_mem_debug_options(void);
319
320#define CRYPTO_push_info(info) \
321 CRYPTO_push_info_(info, __FILE__, __LINE__);
322int CRYPTO_push_info_(const char *info, const char *file, int line);
323int CRYPTO_pop_info(void);
324int CRYPTO_remove_all_info(void);
325
326/* The last argument has the following significance:
327 *
328 * 0: called before the actual memory allocation has taken place
329 * 1: called after the actual memory allocation has taken place
330 */
331void CRYPTO_dbg_malloc(void *addr,int num,const char *file,int line,int before_p);
332void CRYPTO_dbg_realloc(void *addr1,void *addr2,int num,const char *file,int line,int before_p);
333void CRYPTO_dbg_free(void *addr,int before_p);
334
335/* Tell the debugging code about options. By default, the following values
336 * apply:
337 *
338 * 0: Clear all options.
339 * 1: Set the "Show Time" option.
340 * 2: Set the "Show Thread Number" option.
341 * 3: 1 + 2
342 */
343void CRYPTO_dbg_set_options(long bits);
344long CRYPTO_dbg_get_options(void);
303 345
304void *CRYPTO_dbg_malloc(int num,const char *file,int line);
305void *CRYPTO_dbg_realloc(void *addr,int num,const char *file,int line);
306void CRYPTO_dbg_free(void *);
307void *CRYPTO_dbg_remalloc(void *addr,int num,const char *file,int line);
308#ifndef NO_FP_API 346#ifndef NO_FP_API
309void CRYPTO_mem_leaks_fp(FILE *); 347void CRYPTO_mem_leaks_fp(FILE *);
310#endif 348#endif
@@ -312,7 +350,7 @@ void CRYPTO_mem_leaks(struct bio_st *bio);
312/* unsigned long order, char *file, int line, int num_bytes, char *addr */ 350/* unsigned long order, char *file, int line, int num_bytes, char *addr */
313void CRYPTO_mem_leaks_cb(void (*cb)()); 351void CRYPTO_mem_leaks_cb(void (*cb)());
314 352
315void ERR_load_CRYPTO_strings(void ); 353void ERR_load_CRYPTO_strings(void);
316 354
317/* BEGIN ERROR CODES */ 355/* BEGIN ERROR CODES */
318/* The following lines are auto generated by the script mkerr.pl. Any changes 356/* The following lines are auto generated by the script mkerr.pl. Any changes