annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/openssl/crypto.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 /*
jpayne@69 2 * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
jpayne@69 3 * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved
jpayne@69 4 *
jpayne@69 5 * Licensed under the OpenSSL license (the "License"). You may not use
jpayne@69 6 * this file except in compliance with the License. You can obtain a copy
jpayne@69 7 * in the file LICENSE in the source distribution or at
jpayne@69 8 * https://www.openssl.org/source/license.html
jpayne@69 9 */
jpayne@69 10
jpayne@69 11 #ifndef HEADER_CRYPTO_H
jpayne@69 12 # define HEADER_CRYPTO_H
jpayne@69 13
jpayne@69 14 # include <stdlib.h>
jpayne@69 15 # include <time.h>
jpayne@69 16
jpayne@69 17 # include <openssl/e_os2.h>
jpayne@69 18
jpayne@69 19 # ifndef OPENSSL_NO_STDIO
jpayne@69 20 # include <stdio.h>
jpayne@69 21 # endif
jpayne@69 22
jpayne@69 23 # include <openssl/safestack.h>
jpayne@69 24 # include <openssl/opensslv.h>
jpayne@69 25 # include <openssl/ossl_typ.h>
jpayne@69 26 # include <openssl/opensslconf.h>
jpayne@69 27 # include <openssl/cryptoerr.h>
jpayne@69 28
jpayne@69 29 # ifdef CHARSET_EBCDIC
jpayne@69 30 # include <openssl/ebcdic.h>
jpayne@69 31 # endif
jpayne@69 32
jpayne@69 33 /*
jpayne@69 34 * Resolve problems on some operating systems with symbol names that clash
jpayne@69 35 * one way or another
jpayne@69 36 */
jpayne@69 37 # include <openssl/symhacks.h>
jpayne@69 38
jpayne@69 39 # if OPENSSL_API_COMPAT < 0x10100000L
jpayne@69 40 # include <openssl/opensslv.h>
jpayne@69 41 # endif
jpayne@69 42
jpayne@69 43 #ifdef __cplusplus
jpayne@69 44 extern "C" {
jpayne@69 45 #endif
jpayne@69 46
jpayne@69 47 # if OPENSSL_API_COMPAT < 0x10100000L
jpayne@69 48 # define SSLeay OpenSSL_version_num
jpayne@69 49 # define SSLeay_version OpenSSL_version
jpayne@69 50 # define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER
jpayne@69 51 # define SSLEAY_VERSION OPENSSL_VERSION
jpayne@69 52 # define SSLEAY_CFLAGS OPENSSL_CFLAGS
jpayne@69 53 # define SSLEAY_BUILT_ON OPENSSL_BUILT_ON
jpayne@69 54 # define SSLEAY_PLATFORM OPENSSL_PLATFORM
jpayne@69 55 # define SSLEAY_DIR OPENSSL_DIR
jpayne@69 56
jpayne@69 57 /*
jpayne@69 58 * Old type for allocating dynamic locks. No longer used. Use the new thread
jpayne@69 59 * API instead.
jpayne@69 60 */
jpayne@69 61 typedef struct {
jpayne@69 62 int dummy;
jpayne@69 63 } CRYPTO_dynlock;
jpayne@69 64
jpayne@69 65 # endif /* OPENSSL_API_COMPAT */
jpayne@69 66
jpayne@69 67 typedef void CRYPTO_RWLOCK;
jpayne@69 68
jpayne@69 69 CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void);
jpayne@69 70 int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock);
jpayne@69 71 int CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock);
jpayne@69 72 int CRYPTO_THREAD_unlock(CRYPTO_RWLOCK *lock);
jpayne@69 73 void CRYPTO_THREAD_lock_free(CRYPTO_RWLOCK *lock);
jpayne@69 74
jpayne@69 75 int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock);
jpayne@69 76
jpayne@69 77 /*
jpayne@69 78 * The following can be used to detect memory leaks in the library. If
jpayne@69 79 * used, it turns on malloc checking
jpayne@69 80 */
jpayne@69 81 # define CRYPTO_MEM_CHECK_OFF 0x0 /* Control only */
jpayne@69 82 # define CRYPTO_MEM_CHECK_ON 0x1 /* Control and mode bit */
jpayne@69 83 # define CRYPTO_MEM_CHECK_ENABLE 0x2 /* Control and mode bit */
jpayne@69 84 # define CRYPTO_MEM_CHECK_DISABLE 0x3 /* Control only */
jpayne@69 85
jpayne@69 86 struct crypto_ex_data_st {
jpayne@69 87 STACK_OF(void) *sk;
jpayne@69 88 };
jpayne@69 89 DEFINE_STACK_OF(void)
jpayne@69 90
jpayne@69 91 /*
jpayne@69 92 * Per class, we have a STACK of function pointers.
jpayne@69 93 */
jpayne@69 94 # define CRYPTO_EX_INDEX_SSL 0
jpayne@69 95 # define CRYPTO_EX_INDEX_SSL_CTX 1
jpayne@69 96 # define CRYPTO_EX_INDEX_SSL_SESSION 2
jpayne@69 97 # define CRYPTO_EX_INDEX_X509 3
jpayne@69 98 # define CRYPTO_EX_INDEX_X509_STORE 4
jpayne@69 99 # define CRYPTO_EX_INDEX_X509_STORE_CTX 5
jpayne@69 100 # define CRYPTO_EX_INDEX_DH 6
jpayne@69 101 # define CRYPTO_EX_INDEX_DSA 7
jpayne@69 102 # define CRYPTO_EX_INDEX_EC_KEY 8
jpayne@69 103 # define CRYPTO_EX_INDEX_RSA 9
jpayne@69 104 # define CRYPTO_EX_INDEX_ENGINE 10
jpayne@69 105 # define CRYPTO_EX_INDEX_UI 11
jpayne@69 106 # define CRYPTO_EX_INDEX_BIO 12
jpayne@69 107 # define CRYPTO_EX_INDEX_APP 13
jpayne@69 108 # define CRYPTO_EX_INDEX_UI_METHOD 14
jpayne@69 109 # define CRYPTO_EX_INDEX_DRBG 15
jpayne@69 110 # define CRYPTO_EX_INDEX__COUNT 16
jpayne@69 111
jpayne@69 112 /* No longer needed, so this is a no-op */
jpayne@69 113 #define OPENSSL_malloc_init() while(0) continue
jpayne@69 114
jpayne@69 115 int CRYPTO_mem_ctrl(int mode);
jpayne@69 116
jpayne@69 117 # define OPENSSL_malloc(num) \
jpayne@69 118 CRYPTO_malloc(num, OPENSSL_FILE, OPENSSL_LINE)
jpayne@69 119 # define OPENSSL_zalloc(num) \
jpayne@69 120 CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)
jpayne@69 121 # define OPENSSL_realloc(addr, num) \
jpayne@69 122 CRYPTO_realloc(addr, num, OPENSSL_FILE, OPENSSL_LINE)
jpayne@69 123 # define OPENSSL_clear_realloc(addr, old_num, num) \
jpayne@69 124 CRYPTO_clear_realloc(addr, old_num, num, OPENSSL_FILE, OPENSSL_LINE)
jpayne@69 125 # define OPENSSL_clear_free(addr, num) \
jpayne@69 126 CRYPTO_clear_free(addr, num, OPENSSL_FILE, OPENSSL_LINE)
jpayne@69 127 # define OPENSSL_free(addr) \
jpayne@69 128 CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE)
jpayne@69 129 # define OPENSSL_memdup(str, s) \
jpayne@69 130 CRYPTO_memdup((str), s, OPENSSL_FILE, OPENSSL_LINE)
jpayne@69 131 # define OPENSSL_strdup(str) \
jpayne@69 132 CRYPTO_strdup(str, OPENSSL_FILE, OPENSSL_LINE)
jpayne@69 133 # define OPENSSL_strndup(str, n) \
jpayne@69 134 CRYPTO_strndup(str, n, OPENSSL_FILE, OPENSSL_LINE)
jpayne@69 135 # define OPENSSL_secure_malloc(num) \
jpayne@69 136 CRYPTO_secure_malloc(num, OPENSSL_FILE, OPENSSL_LINE)
jpayne@69 137 # define OPENSSL_secure_zalloc(num) \
jpayne@69 138 CRYPTO_secure_zalloc(num, OPENSSL_FILE, OPENSSL_LINE)
jpayne@69 139 # define OPENSSL_secure_free(addr) \
jpayne@69 140 CRYPTO_secure_free(addr, OPENSSL_FILE, OPENSSL_LINE)
jpayne@69 141 # define OPENSSL_secure_clear_free(addr, num) \
jpayne@69 142 CRYPTO_secure_clear_free(addr, num, OPENSSL_FILE, OPENSSL_LINE)
jpayne@69 143 # define OPENSSL_secure_actual_size(ptr) \
jpayne@69 144 CRYPTO_secure_actual_size(ptr)
jpayne@69 145
jpayne@69 146 size_t OPENSSL_strlcpy(char *dst, const char *src, size_t siz);
jpayne@69 147 size_t OPENSSL_strlcat(char *dst, const char *src, size_t siz);
jpayne@69 148 size_t OPENSSL_strnlen(const char *str, size_t maxlen);
jpayne@69 149 char *OPENSSL_buf2hexstr(const unsigned char *buffer, long len);
jpayne@69 150 unsigned char *OPENSSL_hexstr2buf(const char *str, long *len);
jpayne@69 151 int OPENSSL_hexchar2int(unsigned char c);
jpayne@69 152
jpayne@69 153 # define OPENSSL_MALLOC_MAX_NELEMS(type) (((1U<<(sizeof(int)*8-1))-1)/sizeof(type))
jpayne@69 154
jpayne@69 155 unsigned long OpenSSL_version_num(void);
jpayne@69 156 const char *OpenSSL_version(int type);
jpayne@69 157 # define OPENSSL_VERSION 0
jpayne@69 158 # define OPENSSL_CFLAGS 1
jpayne@69 159 # define OPENSSL_BUILT_ON 2
jpayne@69 160 # define OPENSSL_PLATFORM 3
jpayne@69 161 # define OPENSSL_DIR 4
jpayne@69 162 # define OPENSSL_ENGINES_DIR 5
jpayne@69 163
jpayne@69 164 int OPENSSL_issetugid(void);
jpayne@69 165
jpayne@69 166 typedef void CRYPTO_EX_new (void *parent, void *ptr, CRYPTO_EX_DATA *ad,
jpayne@69 167 int idx, long argl, void *argp);
jpayne@69 168 typedef void CRYPTO_EX_free (void *parent, void *ptr, CRYPTO_EX_DATA *ad,
jpayne@69 169 int idx, long argl, void *argp);
jpayne@69 170 typedef int CRYPTO_EX_dup (CRYPTO_EX_DATA *to, const CRYPTO_EX_DATA *from,
jpayne@69 171 void *from_d, int idx, long argl, void *argp);
jpayne@69 172 __owur int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp,
jpayne@69 173 CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
jpayne@69 174 CRYPTO_EX_free *free_func);
jpayne@69 175 /* No longer use an index. */
jpayne@69 176 int CRYPTO_free_ex_index(int class_index, int idx);
jpayne@69 177
jpayne@69 178 /*
jpayne@69 179 * Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a
jpayne@69 180 * given class (invokes whatever per-class callbacks are applicable)
jpayne@69 181 */
jpayne@69 182 int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
jpayne@69 183 int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
jpayne@69 184 const CRYPTO_EX_DATA *from);
jpayne@69 185
jpayne@69 186 void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad);
jpayne@69 187
jpayne@69 188 /*
jpayne@69 189 * Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular
jpayne@69 190 * index (relative to the class type involved)
jpayne@69 191 */
jpayne@69 192 int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val);
jpayne@69 193 void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx);
jpayne@69 194
jpayne@69 195 # if OPENSSL_API_COMPAT < 0x10100000L
jpayne@69 196 /*
jpayne@69 197 * This function cleans up all "ex_data" state. It mustn't be called under
jpayne@69 198 * potential race-conditions.
jpayne@69 199 */
jpayne@69 200 # define CRYPTO_cleanup_all_ex_data() while(0) continue
jpayne@69 201
jpayne@69 202 /*
jpayne@69 203 * The old locking functions have been removed completely without compatibility
jpayne@69 204 * macros. This is because the old functions either could not properly report
jpayne@69 205 * errors, or the returned error values were not clearly documented.
jpayne@69 206 * Replacing the locking functions with no-ops would cause race condition
jpayne@69 207 * issues in the affected applications. It is far better for them to fail at
jpayne@69 208 * compile time.
jpayne@69 209 * On the other hand, the locking callbacks are no longer used. Consequently,
jpayne@69 210 * the callback management functions can be safely replaced with no-op macros.
jpayne@69 211 */
jpayne@69 212 # define CRYPTO_num_locks() (1)
jpayne@69 213 # define CRYPTO_set_locking_callback(func)
jpayne@69 214 # define CRYPTO_get_locking_callback() (NULL)
jpayne@69 215 # define CRYPTO_set_add_lock_callback(func)
jpayne@69 216 # define CRYPTO_get_add_lock_callback() (NULL)
jpayne@69 217
jpayne@69 218 /*
jpayne@69 219 * These defines where used in combination with the old locking callbacks,
jpayne@69 220 * they are not called anymore, but old code that's not called might still
jpayne@69 221 * use them.
jpayne@69 222 */
jpayne@69 223 # define CRYPTO_LOCK 1
jpayne@69 224 # define CRYPTO_UNLOCK 2
jpayne@69 225 # define CRYPTO_READ 4
jpayne@69 226 # define CRYPTO_WRITE 8
jpayne@69 227
jpayne@69 228 /* This structure is no longer used */
jpayne@69 229 typedef struct crypto_threadid_st {
jpayne@69 230 int dummy;
jpayne@69 231 } CRYPTO_THREADID;
jpayne@69 232 /* Only use CRYPTO_THREADID_set_[numeric|pointer]() within callbacks */
jpayne@69 233 # define CRYPTO_THREADID_set_numeric(id, val)
jpayne@69 234 # define CRYPTO_THREADID_set_pointer(id, ptr)
jpayne@69 235 # define CRYPTO_THREADID_set_callback(threadid_func) (0)
jpayne@69 236 # define CRYPTO_THREADID_get_callback() (NULL)
jpayne@69 237 # define CRYPTO_THREADID_current(id)
jpayne@69 238 # define CRYPTO_THREADID_cmp(a, b) (-1)
jpayne@69 239 # define CRYPTO_THREADID_cpy(dest, src)
jpayne@69 240 # define CRYPTO_THREADID_hash(id) (0UL)
jpayne@69 241
jpayne@69 242 # if OPENSSL_API_COMPAT < 0x10000000L
jpayne@69 243 # define CRYPTO_set_id_callback(func)
jpayne@69 244 # define CRYPTO_get_id_callback() (NULL)
jpayne@69 245 # define CRYPTO_thread_id() (0UL)
jpayne@69 246 # endif /* OPENSSL_API_COMPAT < 0x10000000L */
jpayne@69 247
jpayne@69 248 # define CRYPTO_set_dynlock_create_callback(dyn_create_function)
jpayne@69 249 # define CRYPTO_set_dynlock_lock_callback(dyn_lock_function)
jpayne@69 250 # define CRYPTO_set_dynlock_destroy_callback(dyn_destroy_function)
jpayne@69 251 # define CRYPTO_get_dynlock_create_callback() (NULL)
jpayne@69 252 # define CRYPTO_get_dynlock_lock_callback() (NULL)
jpayne@69 253 # define CRYPTO_get_dynlock_destroy_callback() (NULL)
jpayne@69 254 # endif /* OPENSSL_API_COMPAT < 0x10100000L */
jpayne@69 255
jpayne@69 256 int CRYPTO_set_mem_functions(
jpayne@69 257 void *(*m) (size_t, const char *, int),
jpayne@69 258 void *(*r) (void *, size_t, const char *, int),
jpayne@69 259 void (*f) (void *, const char *, int));
jpayne@69 260 int CRYPTO_set_mem_debug(int flag);
jpayne@69 261 void CRYPTO_get_mem_functions(
jpayne@69 262 void *(**m) (size_t, const char *, int),
jpayne@69 263 void *(**r) (void *, size_t, const char *, int),
jpayne@69 264 void (**f) (void *, const char *, int));
jpayne@69 265
jpayne@69 266 void *CRYPTO_malloc(size_t num, const char *file, int line);
jpayne@69 267 void *CRYPTO_zalloc(size_t num, const char *file, int line);
jpayne@69 268 void *CRYPTO_memdup(const void *str, size_t siz, const char *file, int line);
jpayne@69 269 char *CRYPTO_strdup(const char *str, const char *file, int line);
jpayne@69 270 char *CRYPTO_strndup(const char *str, size_t s, const char *file, int line);
jpayne@69 271 void CRYPTO_free(void *ptr, const char *file, int line);
jpayne@69 272 void CRYPTO_clear_free(void *ptr, size_t num, const char *file, int line);
jpayne@69 273 void *CRYPTO_realloc(void *addr, size_t num, const char *file, int line);
jpayne@69 274 void *CRYPTO_clear_realloc(void *addr, size_t old_num, size_t num,
jpayne@69 275 const char *file, int line);
jpayne@69 276
jpayne@69 277 int CRYPTO_secure_malloc_init(size_t sz, int minsize);
jpayne@69 278 int CRYPTO_secure_malloc_done(void);
jpayne@69 279 void *CRYPTO_secure_malloc(size_t num, const char *file, int line);
jpayne@69 280 void *CRYPTO_secure_zalloc(size_t num, const char *file, int line);
jpayne@69 281 void CRYPTO_secure_free(void *ptr, const char *file, int line);
jpayne@69 282 void CRYPTO_secure_clear_free(void *ptr, size_t num,
jpayne@69 283 const char *file, int line);
jpayne@69 284 int CRYPTO_secure_allocated(const void *ptr);
jpayne@69 285 int CRYPTO_secure_malloc_initialized(void);
jpayne@69 286 size_t CRYPTO_secure_actual_size(void *ptr);
jpayne@69 287 size_t CRYPTO_secure_used(void);
jpayne@69 288
jpayne@69 289 void OPENSSL_cleanse(void *ptr, size_t len);
jpayne@69 290
jpayne@69 291 # ifndef OPENSSL_NO_CRYPTO_MDEBUG
jpayne@69 292 # define OPENSSL_mem_debug_push(info) \
jpayne@69 293 CRYPTO_mem_debug_push(info, OPENSSL_FILE, OPENSSL_LINE)
jpayne@69 294 # define OPENSSL_mem_debug_pop() \
jpayne@69 295 CRYPTO_mem_debug_pop()
jpayne@69 296 int CRYPTO_mem_debug_push(const char *info, const char *file, int line);
jpayne@69 297 int CRYPTO_mem_debug_pop(void);
jpayne@69 298 void CRYPTO_get_alloc_counts(int *mcount, int *rcount, int *fcount);
jpayne@69 299
jpayne@69 300 /*-
jpayne@69 301 * Debugging functions (enabled by CRYPTO_set_mem_debug(1))
jpayne@69 302 * The flag argument has the following significance:
jpayne@69 303 * 0: called before the actual memory allocation has taken place
jpayne@69 304 * 1: called after the actual memory allocation has taken place
jpayne@69 305 */
jpayne@69 306 void CRYPTO_mem_debug_malloc(void *addr, size_t num, int flag,
jpayne@69 307 const char *file, int line);
jpayne@69 308 void CRYPTO_mem_debug_realloc(void *addr1, void *addr2, size_t num, int flag,
jpayne@69 309 const char *file, int line);
jpayne@69 310 void CRYPTO_mem_debug_free(void *addr, int flag,
jpayne@69 311 const char *file, int line);
jpayne@69 312
jpayne@69 313 int CRYPTO_mem_leaks_cb(int (*cb) (const char *str, size_t len, void *u),
jpayne@69 314 void *u);
jpayne@69 315 # ifndef OPENSSL_NO_STDIO
jpayne@69 316 int CRYPTO_mem_leaks_fp(FILE *);
jpayne@69 317 # endif
jpayne@69 318 int CRYPTO_mem_leaks(BIO *bio);
jpayne@69 319 # endif
jpayne@69 320
jpayne@69 321 /* die if we have to */
jpayne@69 322 ossl_noreturn void OPENSSL_die(const char *assertion, const char *file, int line);
jpayne@69 323 # if OPENSSL_API_COMPAT < 0x10100000L
jpayne@69 324 # define OpenSSLDie(f,l,a) OPENSSL_die((a),(f),(l))
jpayne@69 325 # endif
jpayne@69 326 # define OPENSSL_assert(e) \
jpayne@69 327 (void)((e) ? 0 : (OPENSSL_die("assertion failed: " #e, OPENSSL_FILE, OPENSSL_LINE), 1))
jpayne@69 328
jpayne@69 329 int OPENSSL_isservice(void);
jpayne@69 330
jpayne@69 331 int FIPS_mode(void);
jpayne@69 332 int FIPS_mode_set(int r);
jpayne@69 333
jpayne@69 334 void OPENSSL_init(void);
jpayne@69 335 # ifdef OPENSSL_SYS_UNIX
jpayne@69 336 void OPENSSL_fork_prepare(void);
jpayne@69 337 void OPENSSL_fork_parent(void);
jpayne@69 338 void OPENSSL_fork_child(void);
jpayne@69 339 # endif
jpayne@69 340
jpayne@69 341 struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result);
jpayne@69 342 int OPENSSL_gmtime_adj(struct tm *tm, int offset_day, long offset_sec);
jpayne@69 343 int OPENSSL_gmtime_diff(int *pday, int *psec,
jpayne@69 344 const struct tm *from, const struct tm *to);
jpayne@69 345
jpayne@69 346 /*
jpayne@69 347 * CRYPTO_memcmp returns zero iff the |len| bytes at |a| and |b| are equal.
jpayne@69 348 * It takes an amount of time dependent on |len|, but independent of the
jpayne@69 349 * contents of |a| and |b|. Unlike memcmp, it cannot be used to put elements
jpayne@69 350 * into a defined order as the return value when a != b is undefined, other
jpayne@69 351 * than to be non-zero.
jpayne@69 352 */
jpayne@69 353 int CRYPTO_memcmp(const void * in_a, const void * in_b, size_t len);
jpayne@69 354
jpayne@69 355 /* Standard initialisation options */
jpayne@69 356 # define OPENSSL_INIT_NO_LOAD_CRYPTO_STRINGS 0x00000001L
jpayne@69 357 # define OPENSSL_INIT_LOAD_CRYPTO_STRINGS 0x00000002L
jpayne@69 358 # define OPENSSL_INIT_ADD_ALL_CIPHERS 0x00000004L
jpayne@69 359 # define OPENSSL_INIT_ADD_ALL_DIGESTS 0x00000008L
jpayne@69 360 # define OPENSSL_INIT_NO_ADD_ALL_CIPHERS 0x00000010L
jpayne@69 361 # define OPENSSL_INIT_NO_ADD_ALL_DIGESTS 0x00000020L
jpayne@69 362 # define OPENSSL_INIT_LOAD_CONFIG 0x00000040L
jpayne@69 363 # define OPENSSL_INIT_NO_LOAD_CONFIG 0x00000080L
jpayne@69 364 # define OPENSSL_INIT_ASYNC 0x00000100L
jpayne@69 365 # define OPENSSL_INIT_ENGINE_RDRAND 0x00000200L
jpayne@69 366 # define OPENSSL_INIT_ENGINE_DYNAMIC 0x00000400L
jpayne@69 367 # define OPENSSL_INIT_ENGINE_OPENSSL 0x00000800L
jpayne@69 368 # define OPENSSL_INIT_ENGINE_CRYPTODEV 0x00001000L
jpayne@69 369 # define OPENSSL_INIT_ENGINE_CAPI 0x00002000L
jpayne@69 370 # define OPENSSL_INIT_ENGINE_PADLOCK 0x00004000L
jpayne@69 371 # define OPENSSL_INIT_ENGINE_AFALG 0x00008000L
jpayne@69 372 /* OPENSSL_INIT_ZLIB 0x00010000L */
jpayne@69 373 # define OPENSSL_INIT_ATFORK 0x00020000L
jpayne@69 374 /* OPENSSL_INIT_BASE_ONLY 0x00040000L */
jpayne@69 375 # define OPENSSL_INIT_NO_ATEXIT 0x00080000L
jpayne@69 376 /* OPENSSL_INIT flag range 0xfff00000 reserved for OPENSSL_init_ssl() */
jpayne@69 377 /* Max OPENSSL_INIT flag value is 0x80000000 */
jpayne@69 378
jpayne@69 379 /* openssl and dasync not counted as builtin */
jpayne@69 380 # define OPENSSL_INIT_ENGINE_ALL_BUILTIN \
jpayne@69 381 (OPENSSL_INIT_ENGINE_RDRAND | OPENSSL_INIT_ENGINE_DYNAMIC \
jpayne@69 382 | OPENSSL_INIT_ENGINE_CRYPTODEV | OPENSSL_INIT_ENGINE_CAPI | \
jpayne@69 383 OPENSSL_INIT_ENGINE_PADLOCK)
jpayne@69 384
jpayne@69 385
jpayne@69 386 /* Library initialisation functions */
jpayne@69 387 void OPENSSL_cleanup(void);
jpayne@69 388 int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
jpayne@69 389 int OPENSSL_atexit(void (*handler)(void));
jpayne@69 390 void OPENSSL_thread_stop(void);
jpayne@69 391
jpayne@69 392 /* Low-level control of initialization */
jpayne@69 393 OPENSSL_INIT_SETTINGS *OPENSSL_INIT_new(void);
jpayne@69 394 # ifndef OPENSSL_NO_STDIO
jpayne@69 395 int OPENSSL_INIT_set_config_filename(OPENSSL_INIT_SETTINGS *settings,
jpayne@69 396 const char *config_filename);
jpayne@69 397 void OPENSSL_INIT_set_config_file_flags(OPENSSL_INIT_SETTINGS *settings,
jpayne@69 398 unsigned long flags);
jpayne@69 399 int OPENSSL_INIT_set_config_appname(OPENSSL_INIT_SETTINGS *settings,
jpayne@69 400 const char *config_appname);
jpayne@69 401 # endif
jpayne@69 402 void OPENSSL_INIT_free(OPENSSL_INIT_SETTINGS *settings);
jpayne@69 403
jpayne@69 404 # if defined(OPENSSL_THREADS) && !defined(CRYPTO_TDEBUG)
jpayne@69 405 # if defined(_WIN32)
jpayne@69 406 # if defined(BASETYPES) || defined(_WINDEF_H)
jpayne@69 407 /* application has to include <windows.h> in order to use this */
jpayne@69 408 typedef DWORD CRYPTO_THREAD_LOCAL;
jpayne@69 409 typedef DWORD CRYPTO_THREAD_ID;
jpayne@69 410
jpayne@69 411 typedef LONG CRYPTO_ONCE;
jpayne@69 412 # define CRYPTO_ONCE_STATIC_INIT 0
jpayne@69 413 # endif
jpayne@69 414 # else
jpayne@69 415 # include <pthread.h>
jpayne@69 416 typedef pthread_once_t CRYPTO_ONCE;
jpayne@69 417 typedef pthread_key_t CRYPTO_THREAD_LOCAL;
jpayne@69 418 typedef pthread_t CRYPTO_THREAD_ID;
jpayne@69 419
jpayne@69 420 # define CRYPTO_ONCE_STATIC_INIT PTHREAD_ONCE_INIT
jpayne@69 421 # endif
jpayne@69 422 # endif
jpayne@69 423
jpayne@69 424 # if !defined(CRYPTO_ONCE_STATIC_INIT)
jpayne@69 425 typedef unsigned int CRYPTO_ONCE;
jpayne@69 426 typedef unsigned int CRYPTO_THREAD_LOCAL;
jpayne@69 427 typedef unsigned int CRYPTO_THREAD_ID;
jpayne@69 428 # define CRYPTO_ONCE_STATIC_INIT 0
jpayne@69 429 # endif
jpayne@69 430
jpayne@69 431 int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void));
jpayne@69 432
jpayne@69 433 int CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *));
jpayne@69 434 void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key);
jpayne@69 435 int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val);
jpayne@69 436 int CRYPTO_THREAD_cleanup_local(CRYPTO_THREAD_LOCAL *key);
jpayne@69 437
jpayne@69 438 CRYPTO_THREAD_ID CRYPTO_THREAD_get_current_id(void);
jpayne@69 439 int CRYPTO_THREAD_compare_id(CRYPTO_THREAD_ID a, CRYPTO_THREAD_ID b);
jpayne@69 440
jpayne@69 441
jpayne@69 442 # ifdef __cplusplus
jpayne@69 443 }
jpayne@69 444 # endif
jpayne@69 445 #endif