| 1 | /* |
| 2 | * WARNING: do not edit! |
| 3 | * Generated by Makefile from include/openssl/crypto.h.in |
| 4 | * |
| 5 | * Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved. |
| 6 | * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved |
| 7 | * |
| 8 | * Licensed under the Apache License 2.0 (the "License"). You may not use |
| 9 | * this file except in compliance with the License. You can obtain a copy |
| 10 | * in the file LICENSE in the source distribution or at |
| 11 | * https://www.openssl.org/source/license.html |
| 12 | */ |
| 13 | |
| 14 | |
| 15 | |
| 16 | #ifndef OPENSSL_CRYPTO_H |
| 17 | # define OPENSSL_CRYPTO_H |
| 18 | # pragma once |
| 19 | |
| 20 | # include <openssl/macros.h> |
| 21 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
| 22 | # define |
| 23 | # endif |
| 24 | |
| 25 | # include <stdlib.h> |
| 26 | # include <time.h> |
| 27 | |
| 28 | # include <openssl/e_os2.h> |
| 29 | |
| 30 | # ifndef OPENSSL_NO_STDIO |
| 31 | # include <stdio.h> |
| 32 | # endif |
| 33 | |
| 34 | # include <openssl/safestack.h> |
| 35 | # include <openssl/opensslv.h> |
| 36 | # include <openssl/types.h> |
| 37 | # include <openssl/opensslconf.h> |
| 38 | # include <openssl/cryptoerr.h> |
| 39 | # include <openssl/core.h> |
| 40 | |
| 41 | # ifdef CHARSET_EBCDIC |
| 42 | # include <openssl/ebcdic.h> |
| 43 | # endif |
| 44 | |
| 45 | /* |
| 46 | * Resolve problems on some operating systems with symbol names that clash |
| 47 | * one way or another |
| 48 | */ |
| 49 | # include <openssl/symhacks.h> |
| 50 | |
| 51 | # ifndef OPENSSL_NO_DEPRECATED_1_1_0 |
| 52 | # include <openssl/opensslv.h> |
| 53 | # endif |
| 54 | |
| 55 | #ifdef __cplusplus |
| 56 | extern "C" { |
| 57 | #endif |
| 58 | |
| 59 | # ifndef OPENSSL_NO_DEPRECATED_1_1_0 |
| 60 | # define SSLeay OpenSSL_version_num |
| 61 | # define SSLeay_version OpenSSL_version |
| 62 | # define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER |
| 63 | # define SSLEAY_VERSION OPENSSL_VERSION |
| 64 | # define SSLEAY_CFLAGS OPENSSL_CFLAGS |
| 65 | # define SSLEAY_BUILT_ON OPENSSL_BUILT_ON |
| 66 | # define SSLEAY_PLATFORM OPENSSL_PLATFORM |
| 67 | # define SSLEAY_DIR OPENSSL_DIR |
| 68 | |
| 69 | /* |
| 70 | * Old type for allocating dynamic locks. No longer used. Use the new thread |
| 71 | * API instead. |
| 72 | */ |
| 73 | typedef struct { |
| 74 | int dummy; |
| 75 | } CRYPTO_dynlock; |
| 76 | |
| 77 | # endif /* OPENSSL_NO_DEPRECATED_1_1_0 */ |
| 78 | |
| 79 | typedef void CRYPTO_RWLOCK; |
| 80 | |
| 81 | CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void); |
| 82 | __owur int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock); |
| 83 | __owur int CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock); |
| 84 | int CRYPTO_THREAD_unlock(CRYPTO_RWLOCK *lock); |
| 85 | void CRYPTO_THREAD_lock_free(CRYPTO_RWLOCK *lock); |
| 86 | |
| 87 | int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock); |
| 88 | int CRYPTO_atomic_add64(uint64_t *val, uint64_t op, uint64_t *ret, |
| 89 | CRYPTO_RWLOCK *lock); |
| 90 | int CRYPTO_atomic_and(uint64_t *val, uint64_t op, uint64_t *ret, |
| 91 | CRYPTO_RWLOCK *lock); |
| 92 | int CRYPTO_atomic_or(uint64_t *val, uint64_t op, uint64_t *ret, |
| 93 | CRYPTO_RWLOCK *lock); |
| 94 | int CRYPTO_atomic_load(uint64_t *val, uint64_t *ret, CRYPTO_RWLOCK *lock); |
| 95 | int CRYPTO_atomic_load_int(int *val, int *ret, CRYPTO_RWLOCK *lock); |
| 96 | int CRYPTO_atomic_store(uint64_t *dst, uint64_t val, CRYPTO_RWLOCK *lock); |
| 97 | |
| 98 | /* No longer needed, so this is a no-op */ |
| 99 | #define OPENSSL_malloc_init() while(0) continue |
| 100 | |
| 101 | # define OPENSSL_malloc(num) \ |
| 102 | CRYPTO_malloc(num, OPENSSL_FILE, OPENSSL_LINE) |
| 103 | # define OPENSSL_zalloc(num) \ |
| 104 | CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE) |
| 105 | # define OPENSSL_malloc_array(num, size) \ |
| 106 | CRYPTO_malloc_array(num, size, OPENSSL_FILE, OPENSSL_LINE) |
| 107 | # define OPENSSL_calloc(num, size) \ |
| 108 | CRYPTO_calloc(num, size, OPENSSL_FILE, OPENSSL_LINE) |
| 109 | # define OPENSSL_aligned_alloc(num, alignment, freeptr) \ |
| 110 | CRYPTO_aligned_alloc(num, alignment, freeptr, \ |
| 111 | OPENSSL_FILE, OPENSSL_LINE) |
| 112 | # define OPENSSL_aligned_alloc_array(num, size, alignment, freeptr) \ |
| 113 | CRYPTO_aligned_alloc_array(num, size, alignment, freeptr, \ |
| 114 | OPENSSL_FILE, OPENSSL_LINE) |
| 115 | # define OPENSSL_realloc(addr, num) \ |
| 116 | CRYPTO_realloc(addr, num, OPENSSL_FILE, OPENSSL_LINE) |
| 117 | # define OPENSSL_clear_realloc(addr, old_num, num) \ |
| 118 | CRYPTO_clear_realloc(addr, old_num, num, OPENSSL_FILE, OPENSSL_LINE) |
| 119 | # define OPENSSL_realloc_array(addr, num, size) \ |
| 120 | CRYPTO_realloc_array(addr, num, size, OPENSSL_FILE, OPENSSL_LINE) |
| 121 | # define OPENSSL_clear_realloc_array(addr, old_num, num, size) \ |
| 122 | CRYPTO_clear_realloc_array(addr, old_num, num, size, \ |
| 123 | OPENSSL_FILE, OPENSSL_LINE) |
| 124 | # define OPENSSL_clear_free(addr, num) \ |
| 125 | CRYPTO_clear_free(addr, num, OPENSSL_FILE, OPENSSL_LINE) |
| 126 | # define OPENSSL_free(addr) \ |
| 127 | CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE) |
| 128 | # define OPENSSL_memdup(str, s) \ |
| 129 | CRYPTO_memdup((str), s, OPENSSL_FILE, OPENSSL_LINE) |
| 130 | # define OPENSSL_strdup(str) \ |
| 131 | CRYPTO_strdup(str, OPENSSL_FILE, OPENSSL_LINE) |
| 132 | # define OPENSSL_strndup(str, n) \ |
| 133 | CRYPTO_strndup(str, n, OPENSSL_FILE, OPENSSL_LINE) |
| 134 | # define OPENSSL_secure_malloc(num) \ |
| 135 | CRYPTO_secure_malloc(num, OPENSSL_FILE, OPENSSL_LINE) |
| 136 | # define OPENSSL_secure_zalloc(num) \ |
| 137 | CRYPTO_secure_zalloc(num, OPENSSL_FILE, OPENSSL_LINE) |
| 138 | # define OPENSSL_secure_malloc_array(num, size) \ |
| 139 | CRYPTO_secure_malloc_array(num, size, OPENSSL_FILE, OPENSSL_LINE) |
| 140 | # define OPENSSL_secure_calloc(num, size) \ |
| 141 | CRYPTO_secure_calloc(num, size, OPENSSL_FILE, OPENSSL_LINE) |
| 142 | # define OPENSSL_secure_free(addr) \ |
| 143 | CRYPTO_secure_free(addr, OPENSSL_FILE, OPENSSL_LINE) |
| 144 | # define OPENSSL_secure_clear_free(addr, num) \ |
| 145 | CRYPTO_secure_clear_free(addr, num, OPENSSL_FILE, OPENSSL_LINE) |
| 146 | # define OPENSSL_secure_actual_size(ptr) \ |
| 147 | CRYPTO_secure_actual_size(ptr) |
| 148 | |
| 149 | size_t OPENSSL_strlcpy(char *dst, const char *src, size_t siz); |
| 150 | size_t OPENSSL_strlcat(char *dst, const char *src, size_t siz); |
| 151 | size_t OPENSSL_strnlen(const char *str, size_t maxlen); |
| 152 | int OPENSSL_strtoul(const char *str, char **endptr, int base, unsigned long *num); |
| 153 | int OPENSSL_buf2hexstr_ex(char *str, size_t str_n, size_t *strlength, |
| 154 | const unsigned char *buf, size_t buflen, |
| 155 | const char sep); |
| 156 | char *OPENSSL_buf2hexstr(const unsigned char *buf, long buflen); |
| 157 | int OPENSSL_hexstr2buf_ex(unsigned char *buf, size_t buf_n, size_t *buflen, |
| 158 | const char *str, const char sep); |
| 159 | unsigned char *OPENSSL_hexstr2buf(const char *str, long *buflen); |
| 160 | int OPENSSL_hexchar2int(unsigned char c); |
| 161 | int OPENSSL_strcasecmp(const char *s1, const char *s2); |
| 162 | int OPENSSL_strncasecmp(const char *s1, const char *s2, size_t n); |
| 163 | |
| 164 | # define OPENSSL_MALLOC_MAX_NELEMS(type) (((1U<<(sizeof(int)*8-1))-1)/sizeof(type)) |
| 165 | |
| 166 | /* |
| 167 | * These functions return the values of OPENSSL_VERSION_MAJOR, |
| 168 | * OPENSSL_VERSION_MINOR, OPENSSL_VERSION_PATCH, OPENSSL_VERSION_PRE_RELEASE |
| 169 | * and OPENSSL_VERSION_BUILD_METADATA, respectively. |
| 170 | */ |
| 171 | unsigned int OPENSSL_version_major(void); |
| 172 | unsigned int OPENSSL_version_minor(void); |
| 173 | unsigned int OPENSSL_version_patch(void); |
| 174 | const char *OPENSSL_version_pre_release(void); |
| 175 | const char *OPENSSL_version_build_metadata(void); |
| 176 | |
| 177 | unsigned long OpenSSL_version_num(void); |
| 178 | const char *OpenSSL_version(int type); |
| 179 | # define OPENSSL_VERSION 0 |
| 180 | # define OPENSSL_CFLAGS 1 |
| 181 | # define OPENSSL_BUILT_ON 2 |
| 182 | # define OPENSSL_PLATFORM 3 |
| 183 | # define OPENSSL_DIR 4 |
| 184 | # define OPENSSL_ENGINES_DIR 5 |
| 185 | # define OPENSSL_VERSION_STRING 6 |
| 186 | # define OPENSSL_FULL_VERSION_STRING 7 |
| 187 | # define OPENSSL_MODULES_DIR 8 |
| 188 | # define OPENSSL_CPU_INFO 9 |
| 189 | # define OPENSSL_WINCTX 10 |
| 190 | |
| 191 | const char *OPENSSL_info(int type); |
| 192 | /* |
| 193 | * The series starts at 1001 to avoid confusion with the OpenSSL_version |
| 194 | * types. |
| 195 | */ |
| 196 | # define OPENSSL_INFO_CONFIG_DIR 1001 |
| 197 | # define OPENSSL_INFO_ENGINES_DIR 1002 |
| 198 | # define OPENSSL_INFO_MODULES_DIR 1003 |
| 199 | # define OPENSSL_INFO_DSO_EXTENSION 1004 |
| 200 | # define OPENSSL_INFO_DIR_FILENAME_SEPARATOR 1005 |
| 201 | # define OPENSSL_INFO_LIST_SEPARATOR 1006 |
| 202 | # define OPENSSL_INFO_SEED_SOURCE 1007 |
| 203 | # define OPENSSL_INFO_CPU_SETTINGS 1008 |
| 204 | # define OPENSSL_INFO_WINDOWS_CONTEXT 1009 |
| 205 | |
| 206 | int OPENSSL_issetugid(void); |
| 207 | |
| 208 | struct crypto_ex_data_st { |
| 209 | OSSL_LIB_CTX *ctx; |
| 210 | STACK_OF(void) *sk; |
| 211 | }; |
| 212 | |
| 213 | SKM_DEFINE_STACK_OF_INTERNAL(void, void, void) |
| 214 | #define sk_void_num(sk) OPENSSL_sk_num(ossl_check_const_void_sk_type(sk)) |
| 215 | #define sk_void_value(sk, idx) ((void *)OPENSSL_sk_value(ossl_check_const_void_sk_type(sk), (idx))) |
| 216 | #define sk_void_new(cmp) ((STACK_OF(void) *)OPENSSL_sk_new(ossl_check_void_compfunc_type(cmp))) |
| 217 | #define sk_void_new_null() ((STACK_OF(void) *)OPENSSL_sk_new_null()) |
| 218 | #define sk_void_new_reserve(cmp, n) ((STACK_OF(void) *)OPENSSL_sk_new_reserve(ossl_check_void_compfunc_type(cmp), (n))) |
| 219 | #define sk_void_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_void_sk_type(sk), (n)) |
| 220 | #define sk_void_free(sk) OPENSSL_sk_free(ossl_check_void_sk_type(sk)) |
| 221 | #define sk_void_zero(sk) OPENSSL_sk_zero(ossl_check_void_sk_type(sk)) |
| 222 | #define sk_void_delete(sk, i) ((void *)OPENSSL_sk_delete(ossl_check_void_sk_type(sk), (i))) |
| 223 | #define sk_void_delete_ptr(sk, ptr) ((void *)OPENSSL_sk_delete_ptr(ossl_check_void_sk_type(sk), ossl_check_void_type(ptr))) |
| 224 | #define sk_void_push(sk, ptr) OPENSSL_sk_push(ossl_check_void_sk_type(sk), ossl_check_void_type(ptr)) |
| 225 | #define sk_void_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_void_sk_type(sk), ossl_check_void_type(ptr)) |
| 226 | #define sk_void_pop(sk) ((void *)OPENSSL_sk_pop(ossl_check_void_sk_type(sk))) |
| 227 | #define sk_void_shift(sk) ((void *)OPENSSL_sk_shift(ossl_check_void_sk_type(sk))) |
| 228 | #define sk_void_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_void_sk_type(sk), ossl_check_void_freefunc_type(freefunc)) |
| 229 | #define sk_void_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_void_sk_type(sk), ossl_check_void_type(ptr), (idx)) |
| 230 | #define sk_void_set(sk, idx, ptr) ((void *)OPENSSL_sk_set(ossl_check_void_sk_type(sk), (idx), ossl_check_void_type(ptr))) |
| 231 | #define sk_void_find(sk, ptr) OPENSSL_sk_find(ossl_check_void_sk_type(sk), ossl_check_void_type(ptr)) |
| 232 | #define sk_void_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_void_sk_type(sk), ossl_check_void_type(ptr)) |
| 233 | #define sk_void_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_void_sk_type(sk), ossl_check_void_type(ptr), pnum) |
| 234 | #define sk_void_sort(sk) OPENSSL_sk_sort(ossl_check_void_sk_type(sk)) |
| 235 | #define sk_void_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_void_sk_type(sk)) |
| 236 | #define sk_void_dup(sk) ((STACK_OF(void) *)OPENSSL_sk_dup(ossl_check_const_void_sk_type(sk))) |
| 237 | #define sk_void_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(void) *)OPENSSL_sk_deep_copy(ossl_check_const_void_sk_type(sk), ossl_check_void_copyfunc_type(copyfunc), ossl_check_void_freefunc_type(freefunc))) |
| 238 | #define sk_void_set_cmp_func(sk, cmp) ((sk_void_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_void_sk_type(sk), ossl_check_void_compfunc_type(cmp))) |
| 239 | |
| 240 | |
| 241 | |
| 242 | /* |
| 243 | * Per class, we have a STACK of function pointers. |
| 244 | */ |
| 245 | # define CRYPTO_EX_INDEX_SSL 0 |
| 246 | # define CRYPTO_EX_INDEX_SSL_CTX 1 |
| 247 | # define CRYPTO_EX_INDEX_SSL_SESSION 2 |
| 248 | # define CRYPTO_EX_INDEX_X509 3 |
| 249 | # define CRYPTO_EX_INDEX_X509_STORE 4 |
| 250 | # define CRYPTO_EX_INDEX_X509_STORE_CTX 5 |
| 251 | # define CRYPTO_EX_INDEX_DH 6 |
| 252 | # define CRYPTO_EX_INDEX_DSA 7 |
| 253 | # define CRYPTO_EX_INDEX_EC_KEY 8 |
| 254 | # define CRYPTO_EX_INDEX_RSA 9 |
| 255 | # define CRYPTO_EX_INDEX_ENGINE 10 |
| 256 | # define CRYPTO_EX_INDEX_UI 11 |
| 257 | # define CRYPTO_EX_INDEX_BIO 12 |
| 258 | # define CRYPTO_EX_INDEX_APP 13 |
| 259 | # define CRYPTO_EX_INDEX_UI_METHOD 14 |
| 260 | # define CRYPTO_EX_INDEX_RAND_DRBG 15 |
| 261 | # define CRYPTO_EX_INDEX_DRBG CRYPTO_EX_INDEX_RAND_DRBG |
| 262 | # define CRYPTO_EX_INDEX_OSSL_LIB_CTX 16 |
| 263 | # define CRYPTO_EX_INDEX_EVP_PKEY 17 |
| 264 | # define CRYPTO_EX_INDEX__COUNT 18 |
| 265 | |
| 266 | typedef void CRYPTO_EX_new (void *parent, void *ptr, CRYPTO_EX_DATA *ad, |
| 267 | int idx, long argl, void *argp); |
| 268 | typedef void CRYPTO_EX_free (void *parent, void *ptr, CRYPTO_EX_DATA *ad, |
| 269 | int idx, long argl, void *argp); |
| 270 | typedef int CRYPTO_EX_dup (CRYPTO_EX_DATA *to, const CRYPTO_EX_DATA *from, |
| 271 | void **from_d, int idx, long argl, void *argp); |
| 272 | __owur int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp, |
| 273 | CRYPTO_EX_new *new_func, |
| 274 | CRYPTO_EX_dup *dup_func, |
| 275 | CRYPTO_EX_free *free_func); |
| 276 | /* No longer use an index. */ |
| 277 | int CRYPTO_free_ex_index(int class_index, int idx); |
| 278 | |
| 279 | /* |
| 280 | * Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a |
| 281 | * given class (invokes whatever per-class callbacks are applicable) |
| 282 | */ |
| 283 | int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); |
| 284 | int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, |
| 285 | const CRYPTO_EX_DATA *from); |
| 286 | |
| 287 | void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); |
| 288 | |
| 289 | /* Allocate a single item in the CRYPTO_EX_DATA variable */ |
| 290 | int CRYPTO_alloc_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad, |
| 291 | int idx); |
| 292 | |
| 293 | /* |
| 294 | * Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular |
| 295 | * index (relative to the class type involved) |
| 296 | */ |
| 297 | int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val); |
| 298 | void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx); |
| 299 | |
| 300 | # ifndef OPENSSL_NO_DEPRECATED_1_1_0 |
| 301 | /* |
| 302 | * This function cleans up all "ex_data" state. It mustn't be called under |
| 303 | * potential race-conditions. |
| 304 | */ |
| 305 | # define CRYPTO_cleanup_all_ex_data() while(0) continue |
| 306 | |
| 307 | /* |
| 308 | * The old locking functions have been removed completely without compatibility |
| 309 | * macros. This is because the old functions either could not properly report |
| 310 | * errors, or the returned error values were not clearly documented. |
| 311 | * Replacing the locking functions with no-ops would cause race condition |
| 312 | * issues in the affected applications. It is far better for them to fail at |
| 313 | * compile time. |
| 314 | * On the other hand, the locking callbacks are no longer used. Consequently, |
| 315 | * the callback management functions can be safely replaced with no-op macros. |
| 316 | */ |
| 317 | # define CRYPTO_num_locks() (1) |
| 318 | # define CRYPTO_set_locking_callback(func) |
| 319 | # define CRYPTO_get_locking_callback() (NULL) |
| 320 | # define CRYPTO_set_add_lock_callback(func) |
| 321 | # define CRYPTO_get_add_lock_callback() (NULL) |
| 322 | |
| 323 | /* |
| 324 | * These defines where used in combination with the old locking callbacks, |
| 325 | * they are not called anymore, but old code that's not called might still |
| 326 | * use them. |
| 327 | */ |
| 328 | # define CRYPTO_LOCK 1 |
| 329 | # define CRYPTO_UNLOCK 2 |
| 330 | # define CRYPTO_READ 4 |
| 331 | # define CRYPTO_WRITE 8 |
| 332 | |
| 333 | /* This structure is no longer used */ |
| 334 | typedef struct crypto_threadid_st { |
| 335 | int dummy; |
| 336 | } CRYPTO_THREADID; |
| 337 | /* Only use CRYPTO_THREADID_set_[numeric|pointer]() within callbacks */ |
| 338 | # define CRYPTO_THREADID_set_numeric(id, val) |
| 339 | # define CRYPTO_THREADID_set_pointer(id, ptr) |
| 340 | # define CRYPTO_THREADID_set_callback(threadid_func) (0) |
| 341 | # define CRYPTO_THREADID_get_callback() (NULL) |
| 342 | # define CRYPTO_THREADID_current(id) |
| 343 | # define CRYPTO_THREADID_cmp(a, b) (-1) |
| 344 | # define CRYPTO_THREADID_cpy(dest, src) |
| 345 | # define CRYPTO_THREADID_hash(id) (0UL) |
| 346 | |
| 347 | # ifndef OPENSSL_NO_DEPRECATED_1_0_0 |
| 348 | # define CRYPTO_set_id_callback(func) |
| 349 | # define CRYPTO_get_id_callback() (NULL) |
| 350 | # define CRYPTO_thread_id() (0UL) |
| 351 | # endif /* OPENSSL_NO_DEPRECATED_1_0_0 */ |
| 352 | |
| 353 | # define CRYPTO_set_dynlock_create_callback(dyn_create_function) |
| 354 | # define CRYPTO_set_dynlock_lock_callback(dyn_lock_function) |
| 355 | # define CRYPTO_set_dynlock_destroy_callback(dyn_destroy_function) |
| 356 | # define CRYPTO_get_dynlock_create_callback() (NULL) |
| 357 | # define CRYPTO_get_dynlock_lock_callback() (NULL) |
| 358 | # define CRYPTO_get_dynlock_destroy_callback() (NULL) |
| 359 | # endif /* OPENSSL_NO_DEPRECATED_1_1_0 */ |
| 360 | |
| 361 | typedef void *(*CRYPTO_malloc_fn)(size_t num, const char *file, int line); |
| 362 | typedef void *(*CRYPTO_realloc_fn)(void *addr, size_t num, const char *file, |
| 363 | int line); |
| 364 | typedef void (*CRYPTO_free_fn)(void *addr, const char *file, int line); |
| 365 | int CRYPTO_set_mem_functions(CRYPTO_malloc_fn malloc_fn, |
| 366 | CRYPTO_realloc_fn realloc_fn, |
| 367 | CRYPTO_free_fn free_fn); |
| 368 | void CRYPTO_get_mem_functions(CRYPTO_malloc_fn *malloc_fn, |
| 369 | CRYPTO_realloc_fn *realloc_fn, |
| 370 | CRYPTO_free_fn *free_fn); |
| 371 | |
| 372 | OSSL_CRYPTO_ALLOC void *CRYPTO_malloc(size_t num, const char *file, int line); |
| 373 | OSSL_CRYPTO_ALLOC void *CRYPTO_zalloc(size_t num, const char *file, int line); |
| 374 | OSSL_CRYPTO_ALLOC void *CRYPTO_malloc_array(size_t num, size_t size, |
| 375 | const char *file, int line); |
| 376 | OSSL_CRYPTO_ALLOC void *CRYPTO_calloc(size_t num, size_t size, |
| 377 | const char *file, int line); |
| 378 | OSSL_CRYPTO_ALLOC void *CRYPTO_aligned_alloc(size_t num, size_t align, |
| 379 | void **freeptr, const char *file, |
| 380 | int line); |
| 381 | OSSL_CRYPTO_ALLOC void *CRYPTO_aligned_alloc_array(size_t num, size_t size, |
| 382 | size_t align, void **freeptr, |
| 383 | const char *file, int line); |
| 384 | void *CRYPTO_memdup(const void *str, size_t siz, const char *file, int line); |
| 385 | char *CRYPTO_strdup(const char *str, const char *file, int line); |
| 386 | char *CRYPTO_strndup(const char *str, size_t s, const char *file, int line); |
| 387 | void CRYPTO_free(void *ptr, const char *file, int line); |
| 388 | void CRYPTO_clear_free(void *ptr, size_t num, const char *file, int line); |
| 389 | void *CRYPTO_realloc(void *addr, size_t num, const char *file, int line); |
| 390 | void *CRYPTO_clear_realloc(void *addr, size_t old_num, size_t num, |
| 391 | const char *file, int line); |
| 392 | void *CRYPTO_realloc_array(void *addr, size_t num, size_t size, |
| 393 | const char *file, int line); |
| 394 | void *CRYPTO_clear_realloc_array(void *addr, size_t old_num, size_t num, |
| 395 | size_t size, const char *file, int line); |
| 396 | |
| 397 | int CRYPTO_secure_malloc_init(size_t sz, size_t minsize); |
| 398 | int CRYPTO_secure_malloc_done(void); |
| 399 | OSSL_CRYPTO_ALLOC void *CRYPTO_secure_malloc(size_t num, const char *file, int line); |
| 400 | OSSL_CRYPTO_ALLOC void *CRYPTO_secure_zalloc(size_t num, const char *file, int line); |
| 401 | OSSL_CRYPTO_ALLOC void *CRYPTO_secure_malloc_array(size_t num, size_t size, |
| 402 | const char *file, int line); |
| 403 | OSSL_CRYPTO_ALLOC void *CRYPTO_secure_calloc(size_t num, size_t size, |
| 404 | const char *file, int line); |
| 405 | void CRYPTO_secure_free(void *ptr, const char *file, int line); |
| 406 | void CRYPTO_secure_clear_free(void *ptr, size_t num, |
| 407 | const char *file, int line); |
| 408 | int CRYPTO_secure_allocated(const void *ptr); |
| 409 | int CRYPTO_secure_malloc_initialized(void); |
| 410 | size_t CRYPTO_secure_actual_size(void *ptr); |
| 411 | size_t CRYPTO_secure_used(void); |
| 412 | |
| 413 | void OPENSSL_cleanse(void *ptr, size_t len); |
| 414 | |
| 415 | # ifndef OPENSSL_NO_CRYPTO_MDEBUG |
| 416 | /* |
| 417 | * The following can be used to detect memory leaks in the library. If |
| 418 | * used, it turns on malloc checking |
| 419 | */ |
| 420 | # define CRYPTO_MEM_CHECK_OFF 0x0 /* Control only */ |
| 421 | # define CRYPTO_MEM_CHECK_ON 0x1 /* Control and mode bit */ |
| 422 | # define CRYPTO_MEM_CHECK_ENABLE 0x2 /* Control and mode bit */ |
| 423 | # define CRYPTO_MEM_CHECK_DISABLE 0x3 /* Control only */ |
| 424 | |
| 425 | /* max allowed length for value of OPENSSL_MALLOC_FAILURES env var. */ |
| 426 | # define CRYPTO_MEM_CHECK_MAX_FS 256 |
| 427 | |
| 428 | void CRYPTO_get_alloc_counts(int *mcount, int *rcount, int *fcount); |
| 429 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
| 430 | # define OPENSSL_mem_debug_push(info) \ |
| 431 | CRYPTO_mem_debug_push(info, OPENSSL_FILE, OPENSSL_LINE) |
| 432 | # define OPENSSL_mem_debug_pop() \ |
| 433 | CRYPTO_mem_debug_pop() |
| 434 | # endif |
| 435 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
| 436 | OSSL_DEPRECATEDIN_3_0 int CRYPTO_set_mem_debug(int flag); |
| 437 | OSSL_DEPRECATEDIN_3_0 int CRYPTO_mem_ctrl(int mode); |
| 438 | OSSL_DEPRECATEDIN_3_0 int CRYPTO_mem_debug_push(const char *info, |
| 439 | const char *file, int line); |
| 440 | OSSL_DEPRECATEDIN_3_0 int CRYPTO_mem_debug_pop(void); |
| 441 | OSSL_DEPRECATEDIN_3_0 void CRYPTO_mem_debug_malloc(void *addr, size_t num, |
| 442 | int flag, |
| 443 | const char *file, int line); |
| 444 | OSSL_DEPRECATEDIN_3_0 void CRYPTO_mem_debug_realloc(void *addr1, void *addr2, |
| 445 | size_t num, int flag, |
| 446 | const char *file, int line); |
| 447 | OSSL_DEPRECATEDIN_3_0 void CRYPTO_mem_debug_free(void *addr, int flag, |
| 448 | const char *file, int line); |
| 449 | OSSL_DEPRECATEDIN_3_0 |
| 450 | int CRYPTO_mem_leaks_cb(int (*cb)(const char *str, size_t len, void *u), |
| 451 | void *u); |
| 452 | # endif |
| 453 | # ifndef OPENSSL_NO_STDIO |
| 454 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
| 455 | OSSL_DEPRECATEDIN_3_0 int CRYPTO_mem_leaks_fp(FILE *); |
| 456 | # endif |
| 457 | # endif |
| 458 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
| 459 | OSSL_DEPRECATEDIN_3_0 int CRYPTO_mem_leaks(BIO *bio); |
| 460 | # endif |
| 461 | # endif /* OPENSSL_NO_CRYPTO_MDEBUG */ |
| 462 | |
| 463 | /* die if we have to */ |
| 464 | ossl_noreturn void OPENSSL_die(const char *assertion, const char *file, int line); |
| 465 | # ifndef OPENSSL_NO_DEPRECATED_1_1_0 |
| 466 | # define OpenSSLDie(f,l,a) OPENSSL_die((a),(f),(l)) |
| 467 | # endif |
| 468 | # define OPENSSL_assert(e) \ |
| 469 | (void)((e) ? 0 : (OPENSSL_die("assertion failed: " #e, OPENSSL_FILE, OPENSSL_LINE), 1)) |
| 470 | |
| 471 | int OPENSSL_isservice(void); |
| 472 | |
| 473 | void OPENSSL_init(void); |
| 474 | # ifdef OPENSSL_SYS_UNIX |
| 475 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
| 476 | OSSL_DEPRECATEDIN_3_0 void OPENSSL_fork_prepare(void); |
| 477 | OSSL_DEPRECATEDIN_3_0 void OPENSSL_fork_parent(void); |
| 478 | OSSL_DEPRECATEDIN_3_0 void OPENSSL_fork_child(void); |
| 479 | # endif |
| 480 | # endif |
| 481 | |
| 482 | struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result); |
| 483 | int OPENSSL_gmtime_adj(struct tm *tm, int offset_day, long offset_sec); |
| 484 | int OPENSSL_gmtime_diff(int *pday, int *psec, |
| 485 | const struct tm *from, const struct tm *to); |
| 486 | |
| 487 | /* |
| 488 | * CRYPTO_memcmp returns zero iff the |len| bytes at |a| and |b| are equal. |
| 489 | * It takes an amount of time dependent on |len|, but independent of the |
| 490 | * contents of |a| and |b|. Unlike memcmp, it cannot be used to put elements |
| 491 | * into a defined order as the return value when a != b is undefined, other |
| 492 | * than to be non-zero. |
| 493 | */ |
| 494 | int CRYPTO_memcmp(const void * in_a, const void * in_b, size_t len); |
| 495 | |
| 496 | /* Standard initialisation options */ |
| 497 | # define OPENSSL_INIT_NO_LOAD_CRYPTO_STRINGS 0x00000001L |
| 498 | # define OPENSSL_INIT_LOAD_CRYPTO_STRINGS 0x00000002L |
| 499 | # define OPENSSL_INIT_ADD_ALL_CIPHERS 0x00000004L |
| 500 | # define OPENSSL_INIT_ADD_ALL_DIGESTS 0x00000008L |
| 501 | # define OPENSSL_INIT_NO_ADD_ALL_CIPHERS 0x00000010L |
| 502 | # define OPENSSL_INIT_NO_ADD_ALL_DIGESTS 0x00000020L |
| 503 | # define OPENSSL_INIT_LOAD_CONFIG 0x00000040L |
| 504 | # define OPENSSL_INIT_NO_LOAD_CONFIG 0x00000080L |
| 505 | # define OPENSSL_INIT_ASYNC 0x00000100L |
| 506 | # define OPENSSL_INIT_ENGINE_RDRAND 0x00000200L |
| 507 | # define OPENSSL_INIT_ENGINE_DYNAMIC 0x00000400L |
| 508 | # define OPENSSL_INIT_ENGINE_OPENSSL 0x00000800L |
| 509 | # define OPENSSL_INIT_ENGINE_CRYPTODEV 0x00001000L |
| 510 | # define OPENSSL_INIT_ENGINE_CAPI 0x00002000L |
| 511 | # define OPENSSL_INIT_ENGINE_PADLOCK 0x00004000L |
| 512 | # define OPENSSL_INIT_ENGINE_AFALG 0x00008000L |
| 513 | /* FREE: 0x00010000L */ |
| 514 | # define OPENSSL_INIT_ATFORK 0x00020000L |
| 515 | /* OPENSSL_INIT_BASE_ONLY 0x00040000L */ |
| 516 | # define OPENSSL_INIT_NO_ATEXIT 0x00080000L |
| 517 | /* OPENSSL_INIT flag range 0x03f00000 reserved for OPENSSL_init_ssl() */ |
| 518 | /* FREE: 0x04000000L */ |
| 519 | /* FREE: 0x08000000L */ |
| 520 | /* FREE: 0x10000000L */ |
| 521 | /* FREE: 0x20000000L */ |
| 522 | /* FREE: 0x40000000L */ |
| 523 | /* FREE: 0x80000000L */ |
| 524 | /* Max OPENSSL_INIT flag value is 0x80000000 */ |
| 525 | |
| 526 | /* openssl and dasync not counted as builtin */ |
| 527 | # define OPENSSL_INIT_ENGINE_ALL_BUILTIN \ |
| 528 | (OPENSSL_INIT_ENGINE_RDRAND | OPENSSL_INIT_ENGINE_DYNAMIC \ |
| 529 | | OPENSSL_INIT_ENGINE_CRYPTODEV | OPENSSL_INIT_ENGINE_CAPI | \ |
| 530 | OPENSSL_INIT_ENGINE_PADLOCK) |
| 531 | |
| 532 | /* Library initialisation functions */ |
| 533 | void OPENSSL_cleanup(void); |
| 534 | int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings); |
| 535 | int OPENSSL_atexit(void (*handler)(void)); |
| 536 | void OPENSSL_thread_stop(void); |
| 537 | void OPENSSL_thread_stop_ex(OSSL_LIB_CTX *ctx); |
| 538 | |
| 539 | /* Low-level control of initialization */ |
| 540 | OPENSSL_INIT_SETTINGS *OPENSSL_INIT_new(void); |
| 541 | # ifndef OPENSSL_NO_STDIO |
| 542 | int OPENSSL_INIT_set_config_filename(OPENSSL_INIT_SETTINGS *settings, |
| 543 | const char *config_filename); |
| 544 | void OPENSSL_INIT_set_config_file_flags(OPENSSL_INIT_SETTINGS *settings, |
| 545 | unsigned long flags); |
| 546 | int OPENSSL_INIT_set_config_appname(OPENSSL_INIT_SETTINGS *settings, |
| 547 | const char *config_appname); |
| 548 | # endif |
| 549 | void OPENSSL_INIT_free(OPENSSL_INIT_SETTINGS *settings); |
| 550 | |
| 551 | # if defined(OPENSSL_THREADS) && !defined(CRYPTO_TDEBUG) |
| 552 | # if defined(_WIN32) |
| 553 | # if defined(BASETYPES) || defined(_WINDEF_H) |
| 554 | /* application has to include <windows.h> in order to use this */ |
| 555 | typedef DWORD CRYPTO_THREAD_LOCAL; |
| 556 | typedef DWORD CRYPTO_THREAD_ID; |
| 557 | |
| 558 | typedef LONG CRYPTO_ONCE; |
| 559 | # define CRYPTO_ONCE_STATIC_INIT 0 |
| 560 | # endif |
| 561 | # else |
| 562 | # if defined(__TANDEM) && defined(_SPT_MODEL_) |
| 563 | # define SPT_THREAD_SIGNAL 1 |
| 564 | # define SPT_THREAD_AWARE 1 |
| 565 | # include <spthread.h> |
| 566 | # else |
| 567 | # include <pthread.h> |
| 568 | # endif |
| 569 | typedef pthread_once_t CRYPTO_ONCE; |
| 570 | typedef pthread_key_t CRYPTO_THREAD_LOCAL; |
| 571 | typedef pthread_t CRYPTO_THREAD_ID; |
| 572 | |
| 573 | # define CRYPTO_ONCE_STATIC_INIT PTHREAD_ONCE_INIT |
| 574 | # endif |
| 575 | # endif |
| 576 | |
| 577 | # if !defined(CRYPTO_ONCE_STATIC_INIT) |
| 578 | typedef unsigned int CRYPTO_ONCE; |
| 579 | typedef unsigned int CRYPTO_THREAD_LOCAL; |
| 580 | typedef unsigned int CRYPTO_THREAD_ID; |
| 581 | # define CRYPTO_ONCE_STATIC_INIT 0 |
| 582 | # endif |
| 583 | |
| 584 | int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void)); |
| 585 | |
| 586 | int CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *)); |
| 587 | void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key); |
| 588 | int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val); |
| 589 | int CRYPTO_THREAD_cleanup_local(CRYPTO_THREAD_LOCAL *key); |
| 590 | |
| 591 | CRYPTO_THREAD_ID CRYPTO_THREAD_get_current_id(void); |
| 592 | int CRYPTO_THREAD_compare_id(CRYPTO_THREAD_ID a, CRYPTO_THREAD_ID b); |
| 593 | |
| 594 | OSSL_LIB_CTX *OSSL_LIB_CTX_new(void); |
| 595 | OSSL_LIB_CTX *OSSL_LIB_CTX_new_from_dispatch(const OSSL_CORE_HANDLE *handle, |
| 596 | const OSSL_DISPATCH *in); |
| 597 | OSSL_LIB_CTX *OSSL_LIB_CTX_new_child(const OSSL_CORE_HANDLE *handle, |
| 598 | const OSSL_DISPATCH *in); |
| 599 | int OSSL_LIB_CTX_load_config(OSSL_LIB_CTX *ctx, const char *config_file); |
| 600 | void OSSL_LIB_CTX_free(OSSL_LIB_CTX *); |
| 601 | OSSL_LIB_CTX *OSSL_LIB_CTX_get0_global_default(void); |
| 602 | OSSL_LIB_CTX *OSSL_LIB_CTX_set0_default(OSSL_LIB_CTX *libctx); |
| 603 | int OSSL_LIB_CTX_get_conf_diagnostics(OSSL_LIB_CTX *ctx); |
| 604 | void OSSL_LIB_CTX_set_conf_diagnostics(OSSL_LIB_CTX *ctx, int value); |
| 605 | |
| 606 | void OSSL_sleep(uint64_t millis); |
| 607 | |
| 608 | |
| 609 | void *OSSL_LIB_CTX_get_data(OSSL_LIB_CTX *ctx, int index); |
| 610 | |
| 611 | # ifdef __cplusplus |
| 612 | } |
| 613 | # endif |
| 614 | #endif |
| 615 | |