summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/crypto.h
diff options
context:
space:
mode:
authorjsing <>2014-04-15 13:42:55 +0000
committerjsing <>2014-04-15 13:42:55 +0000
commit69a8d2dcc19aed0d1116ba2ecd81cce5ae736c94 (patch)
treef085d85cb06e6b6e1a1b1d52cced54d9f7d7e5f2 /src/lib/libcrypto/crypto.h
parentc7fdfc89ee30180bf262c4b146c1b6e1030083d6 (diff)
downloadopenbsd-69a8d2dcc19aed0d1116ba2ecd81cce5ae736c94.tar.gz
openbsd-69a8d2dcc19aed0d1116ba2ecd81cce5ae736c94.tar.bz2
openbsd-69a8d2dcc19aed0d1116ba2ecd81cce5ae736c94.zip
First pass at applying KNF to the OpenSSL code, which almost makes it
readable. This pass is whitespace only and can readily be verified using tr and md5.
Diffstat (limited to 'src/lib/libcrypto/crypto.h')
-rw-r--r--src/lib/libcrypto/crypto.h126
1 files changed, 59 insertions, 67 deletions
diff --git a/src/lib/libcrypto/crypto.h b/src/lib/libcrypto/crypto.h
index 76bc5958c0..baeba25b99 100644
--- a/src/lib/libcrypto/crypto.h
+++ b/src/lib/libcrypto/crypto.h
@@ -154,23 +154,22 @@ extern "C" {
154typedef struct crypto_ex_data_st CRYPTO_EX_DATA; 154typedef struct crypto_ex_data_st CRYPTO_EX_DATA;
155/* Called when a new object is created */ 155/* Called when a new object is created */
156typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad, 156typedef int CRYPTO_EX_new(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
157 int idx, long argl, void *argp); 157 int idx, long argl, void *argp);
158/* Called when an object is free()ed */ 158/* Called when an object is free()ed */
159typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad, 159typedef void CRYPTO_EX_free(void *parent, void *ptr, CRYPTO_EX_DATA *ad,
160 int idx, long argl, void *argp); 160 int idx, long argl, void *argp);
161/* Called when we need to dup an object */ 161/* Called when we need to dup an object */
162typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from, void *from_d, 162typedef int CRYPTO_EX_dup(CRYPTO_EX_DATA *to, CRYPTO_EX_DATA *from,
163 int idx, long argl, void *argp); 163 void *from_d, int idx, long argl, void *argp);
164#endif 164#endif
165 165
166/* A generic structure to pass assorted data in a expandable way */ 166/* A generic structure to pass assorted data in a expandable way */
167typedef struct openssl_item_st 167typedef struct openssl_item_st {
168 {
169 int code; 168 int code;
170 void *value; /* Not used for flag attributes */ 169 void *value; /* Not used for flag attributes */
171 size_t value_size; /* Max size of value for output, length for input */ 170 size_t value_size; /* Max size of value for output, length for input */
172 size_t *value_length; /* Returned length of value for output */ 171 size_t *value_length; /* Returned length of value for output */
173 } OPENSSL_ITEM; 172} OPENSSL_ITEM;
174 173
175 174
176/* When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock 175/* When changing the CRYPTO_LOCK_* list, be sure to maintin the text lock
@@ -249,11 +248,10 @@ typedef struct openssl_item_st
249 and deallocate locks in a dynamic fashion. The following typedef 248 and deallocate locks in a dynamic fashion. The following typedef
250 makes this possible in a type-safe manner. */ 249 makes this possible in a type-safe manner. */
251/* struct CRYPTO_dynlock_value has to be defined by the application. */ 250/* struct CRYPTO_dynlock_value has to be defined by the application. */
252typedef struct 251typedef struct {
253 {
254 int references; 252 int references;
255 struct CRYPTO_dynlock_value *data; 253 struct CRYPTO_dynlock_value *data;
256 } CRYPTO_dynlock; 254} CRYPTO_dynlock;
257 255
258 256
259/* The following can be used to detect memory leaks in the SSLeay library. 257/* The following can be used to detect memory leaks in the SSLeay library.
@@ -278,24 +276,22 @@ typedef struct
278/* predec of the BIO type */ 276/* predec of the BIO type */
279typedef struct bio_st BIO_dummy; 277typedef struct bio_st BIO_dummy;
280 278
281struct crypto_ex_data_st 279struct crypto_ex_data_st {
282 {
283 STACK_OF(void) *sk; 280 STACK_OF(void) *sk;
284 int dummy; /* gcc is screwing up this data structure :-( */ 281 int dummy; /* gcc is screwing up this data structure :-( */
285 }; 282};
286DECLARE_STACK_OF(void) 283DECLARE_STACK_OF(void)
287 284
288/* This stuff is basically class callback functions 285/* This stuff is basically class callback functions
289 * The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more */ 286 * The current classes are SSL_CTX, SSL, SSL_SESSION, and a few more */
290 287
291typedef struct crypto_ex_data_func_st 288typedef struct crypto_ex_data_func_st {
292 {
293 long argl; /* Arbitary long */ 289 long argl; /* Arbitary long */
294 void *argp; /* Arbitary void * */ 290 void *argp; /* Arbitary void * */
295 CRYPTO_EX_new *new_func; 291 CRYPTO_EX_new *new_func;
296 CRYPTO_EX_free *free_func; 292 CRYPTO_EX_free *free_func;
297 CRYPTO_EX_dup *dup_func; 293 CRYPTO_EX_dup *dup_func;
298 } CRYPTO_EX_DATA_FUNCS; 294} CRYPTO_EX_DATA_FUNCS;
299 295
300DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS) 296DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS)
301 297
@@ -392,18 +388,18 @@ int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i);
392int CRYPTO_ex_data_new_class(void); 388int CRYPTO_ex_data_new_class(void);
393/* Within a given class, get/register a new index */ 389/* Within a given class, get/register a new index */
394int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp, 390int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,
395 CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, 391 CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
396 CRYPTO_EX_free *free_func); 392 CRYPTO_EX_free *free_func);
397/* Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a given 393/* Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a given
398 * class (invokes whatever per-class callbacks are applicable) */ 394 * class (invokes whatever per-class callbacks are applicable) */
399int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); 395int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
400int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, 396int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
401 CRYPTO_EX_DATA *from); 397 CRYPTO_EX_DATA *from);
402void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); 398void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
403/* Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular index 399/* Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular index
404 * (relative to the class type involved) */ 400 * (relative to the class type involved) */
405int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val); 401int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);
406void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad,int idx); 402void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx);
407/* This function cleans up all "ex_data" state. It mustn't be called under 403/* This function cleans up all "ex_data" state. It mustn't be called under
408 * potential race-conditions. */ 404 * potential race-conditions. */
409void CRYPTO_cleanup_all_ex_data(void); 405void CRYPTO_cleanup_all_ex_data(void);
@@ -411,22 +407,21 @@ void CRYPTO_cleanup_all_ex_data(void);
411int CRYPTO_get_new_lockid(char *name); 407int CRYPTO_get_new_lockid(char *name);
412 408
413int CRYPTO_num_locks(void); /* return CRYPTO_NUM_LOCKS (shared libs!) */ 409int CRYPTO_num_locks(void); /* return CRYPTO_NUM_LOCKS (shared libs!) */
414void CRYPTO_lock(int mode, int type,const char *file,int line); 410void CRYPTO_lock(int mode, int type, const char *file, int line);
415void CRYPTO_set_locking_callback(void (*func)(int mode,int type, 411void CRYPTO_set_locking_callback(void (*func)(int mode, int type,
416 const char *file,int line)); 412 const char *file, int line));
417void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char *file, 413void (*CRYPTO_get_locking_callback(void))(int mode, int type,
418 int line); 414 const char *file, int line);
419void CRYPTO_set_add_lock_callback(int (*func)(int *num,int mount,int type, 415void CRYPTO_set_add_lock_callback(int (*func)(int *num, int mount, int type,
420 const char *file, int line)); 416 const char *file, int line));
421int (*CRYPTO_get_add_lock_callback(void))(int *num,int mount,int type, 417int (*CRYPTO_get_add_lock_callback(void))(int *num, int mount, int type,
422 const char *file,int line); 418 const char *file, int line);
423 419
424/* Don't use this structure directly. */ 420/* Don't use this structure directly. */
425typedef struct crypto_threadid_st 421typedef struct crypto_threadid_st {
426 {
427 void *ptr; 422 void *ptr;
428 unsigned long val; 423 unsigned long val;
429 } CRYPTO_THREADID; 424} CRYPTO_THREADID;
430/* Only use CRYPTO_THREADID_set_[numeric|pointer]() within callbacks */ 425/* Only use CRYPTO_THREADID_set_[numeric|pointer]() within callbacks */
431void CRYPTO_THREADID_set_numeric(CRYPTO_THREADID *id, unsigned long val); 426void CRYPTO_THREADID_set_numeric(CRYPTO_THREADID *id, unsigned long val);
432void CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr); 427void CRYPTO_THREADID_set_pointer(CRYPTO_THREADID *id, void *ptr);
@@ -443,8 +438,8 @@ unsigned long CRYPTO_thread_id(void);
443#endif 438#endif
444 439
445const char *CRYPTO_get_lock_name(int type); 440const char *CRYPTO_get_lock_name(int type);
446int CRYPTO_add_lock(int *pointer,int amount,int type, const char *file, 441int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
447 int line); 442 int line);
448 443
449int CRYPTO_get_new_dynlockid(void); 444int CRYPTO_get_new_dynlockid(void);
450void CRYPTO_destroy_dynlockid(int i); 445void CRYPTO_destroy_dynlockid(int i);
@@ -452,46 +447,43 @@ struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i);
452void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*dyn_create_function)(const char *file, int line)); 447void CRYPTO_set_dynlock_create_callback(struct CRYPTO_dynlock_value *(*dyn_create_function)(const char *file, int line));
453void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line)); 448void CRYPTO_set_dynlock_lock_callback(void (*dyn_lock_function)(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line));
454void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)(struct CRYPTO_dynlock_value *l, const char *file, int line)); 449void CRYPTO_set_dynlock_destroy_callback(void (*dyn_destroy_function)(struct CRYPTO_dynlock_value *l, const char *file, int line));
455struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))(const char *file,int line); 450struct CRYPTO_dynlock_value *(*CRYPTO_get_dynlock_create_callback(void))(const char *file, int line);
456void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, struct CRYPTO_dynlock_value *l, const char *file,int line); 451void (*CRYPTO_get_dynlock_lock_callback(void))(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line);
457void (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l, const char *file,int line); 452void (*CRYPTO_get_dynlock_destroy_callback(void))(struct CRYPTO_dynlock_value *l, const char *file, int line);
458 453
459/* CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions -- 454/* CRYPTO_set_mem_functions includes CRYPTO_set_locked_mem_functions --
460 * call the latter last if you need different functions */ 455 * call the latter last if you need different functions */
461int CRYPTO_set_mem_functions(void *(*m)(size_t),void *(*r)(void *,size_t), void (*f)(void *)); 456int CRYPTO_set_mem_functions(void *(*m)(size_t), void *(*r)(void *, size_t), void (*f)(void *));
462int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*free_func)(void *)); 457int CRYPTO_set_locked_mem_functions(void *(*m)(size_t), void (*free_func)(void *));
463int CRYPTO_set_mem_ex_functions(void *(*m)(size_t,const char *,int), 458int CRYPTO_set_mem_ex_functions(void *(*m)(size_t, const char *, int),
464 void *(*r)(void *,size_t,const char *,int), 459 void *(*r)(void *, size_t, const char *, int), void (*f)(void *));
465 void (*f)(void *)); 460int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t, const char *, int),
466int CRYPTO_set_locked_mem_ex_functions(void *(*m)(size_t,const char *,int), 461 void (*free_func)(void *));
467 void (*free_func)(void *)); 462int CRYPTO_set_mem_debug_functions(
468int CRYPTO_set_mem_debug_functions(void (*m)(void *,int,const char *,int,int), 463 void (*m)(void *, int, const char *, int, int),
469 void (*r)(void *,void *,int,const char *,int,int), 464 void (*r)(void *, void *, int, const char *, int, int),
470 void (*f)(void *,int), 465 void (*f)(void *, int), void (*so)(long), long (*go)(void));
471 void (*so)(long), 466void CRYPTO_get_mem_functions(void *(**m)(size_t), void *(**r)(void *, size_t),
472 long (*go)(void)); 467 void (**f)(void *));
473void CRYPTO_get_mem_functions(void *(**m)(size_t),void *(**r)(void *, size_t), void (**f)(void *));
474void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *)); 468void CRYPTO_get_locked_mem_functions(void *(**m)(size_t), void (**f)(void *));
475void CRYPTO_get_mem_ex_functions(void *(**m)(size_t,const char *,int), 469void CRYPTO_get_mem_ex_functions(void *(**m)(size_t, const char *, int),
476 void *(**r)(void *, size_t,const char *,int), 470 void *(**r)(void *, size_t, const char *, int), void (**f)(void *));
477 void (**f)(void *)); 471void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t, const char *, int),
478void CRYPTO_get_locked_mem_ex_functions(void *(**m)(size_t,const char *,int), 472 void (**f)(void *));
479 void (**f)(void *)); 473void CRYPTO_get_mem_debug_functions(
480void CRYPTO_get_mem_debug_functions(void (**m)(void *,int,const char *,int,int), 474 void (**m)(void *, int, const char *, int, int),
481 void (**r)(void *,void *,int,const char *,int,int), 475 void (**r)(void *, void *, int, const char *, int, int),
482 void (**f)(void *,int), 476 void (**f)(void *, int), void (**so)(long), long (**go)(void));
483 void (**so)(long),
484 long (**go)(void));
485 477
486void *CRYPTO_malloc_locked(int num, const char *file, int line); 478void *CRYPTO_malloc_locked(int num, const char *file, int line);
487void CRYPTO_free_locked(void *ptr); 479void CRYPTO_free_locked(void *ptr);
488void *CRYPTO_malloc(int num, const char *file, int line); 480void *CRYPTO_malloc(int num, const char *file, int line);
489char *CRYPTO_strdup(const char *str, const char *file, int line); 481char *CRYPTO_strdup(const char *str, const char *file, int line);
490void CRYPTO_free(void *ptr); 482void CRYPTO_free(void *ptr);
491void *CRYPTO_realloc(void *addr,int num, const char *file, int line); 483void *CRYPTO_realloc(void *addr, int num, const char *file, int line);
492void *CRYPTO_realloc_clean(void *addr,int old_num,int num,const char *file, 484void *CRYPTO_realloc_clean(void *addr, int old_num, int num,
493 int line); 485 const char *file, int line);
494void *CRYPTO_remalloc(void *addr,int num, const char *file, int line); 486void *CRYPTO_remalloc(void *addr, int num, const char *file, int line);
495 487
496void OPENSSL_cleanse(void *ptr, size_t len); 488void OPENSSL_cleanse(void *ptr, size_t len);
497 489
@@ -512,9 +504,9 @@ int CRYPTO_remove_all_info(void);
512 * 0: called before the actual memory allocation has taken place 504 * 0: called before the actual memory allocation has taken place
513 * 1: called after the actual memory allocation has taken place 505 * 1: called after the actual memory allocation has taken place
514 */ 506 */
515void CRYPTO_dbg_malloc(void *addr,int num,const char *file,int line,int before_p); 507void CRYPTO_dbg_malloc(void *addr, int num, const char *file, int line, int before_p);
516void CRYPTO_dbg_realloc(void *addr1,void *addr2,int num,const char *file,int line,int before_p); 508void CRYPTO_dbg_realloc(void *addr1, void *addr2, int num, const char *file, int line, int before_p);
517void CRYPTO_dbg_free(void *addr,int before_p); 509void CRYPTO_dbg_free(void *addr, int before_p);
518/* Tell the debugging code about options. By default, the following values 510/* Tell the debugging code about options. By default, the following values
519 * apply: 511 * apply:
520 * 512 *
@@ -536,7 +528,7 @@ typedef void *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *);
536void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb); 528void CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb);
537 529
538/* die if we have to */ 530/* die if we have to */
539void OpenSSLDie(const char *file,int line,const char *assertion); 531void OpenSSLDie(const char *file, int line, const char *assertion);
540#define OPENSSL_assert(e) (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1)) 532#define OPENSSL_assert(e) (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1))
541 533
542unsigned long *OPENSSL_ia32cap_loc(void); 534unsigned long *OPENSSL_ia32cap_loc(void);