2 * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 #ifndef HEADER_CRYPTLIB_H
11 # define HEADER_CRYPTLIB_H
16 # ifdef OPENSSL_USE_APPLINK
17 # undef BIO_FLAGS_UPLINK
18 # define BIO_FLAGS_UPLINK 0x8000
19 # include "ms/uplink.h"
22 # include <openssl/crypto.h>
23 # include <openssl/buffer.h>
24 # include <openssl/bio.h>
25 # include <openssl/err.h>
26 # include "internal/nelem.h"
29 # define ossl_assert(x) ((x) != 0)
31 __owur static ossl_inline int ossl_assert_int(int expr, const char *exprstr,
32 const char *file, int line)
35 OPENSSL_die(exprstr, file, line);
40 # define ossl_assert(x) ossl_assert_int((x) != 0, "Assertion failed: "#x, \
46 * Use this inside a union with the field that needs to be aligned to a
47 * reasonable boundary for the platform. The most pessimistic alignment
48 * of the listed types will be used by the compiler.
50 # define OSSL_UNION_ALIGN \
52 ossl_uintmax_t align_int; \
55 typedef struct ex_callback_st EX_CALLBACK;
57 DEFINE_STACK_OF(EX_CALLBACK)
59 typedef struct app_mem_info_st APP_INFO;
61 typedef struct mem_st MEM;
64 # define OPENSSL_CONF "openssl.cnf"
66 # ifndef OPENSSL_SYS_VMS
67 # define X509_CERT_AREA OPENSSLDIR
68 # define X509_CERT_DIR OPENSSLDIR "/certs"
69 # define X509_CERT_FILE OPENSSLDIR "/cert.pem"
70 # define X509_PRIVATE_DIR OPENSSLDIR "/private"
71 # define CTLOG_FILE OPENSSLDIR "/ct_log_list.cnf"
73 # define X509_CERT_AREA "OSSL$DATAROOT:[000000]"
74 # define X509_CERT_DIR "OSSL$DATAROOT:[CERTS]"
75 # define X509_CERT_FILE "OSSL$DATAROOT:[000000]cert.pem"
76 # define X509_PRIVATE_DIR "OSSL$DATAROOT:[PRIVATE]"
77 # define CTLOG_FILE "OSSL$DATAROOT:[000000]ct_log_list.cnf"
80 # define X509_CERT_DIR_EVP "SSL_CERT_DIR"
81 # define X509_CERT_FILE_EVP "SSL_CERT_FILE"
82 # define CTLOG_FILE_EVP "CTLOG_FILE"
84 /* size of string representations */
85 # define DECIMAL_SIZE(type) ((sizeof(type)*8+2)/3+1)
86 # define HEX_SIZE(type) (sizeof(type)*2)
88 void OPENSSL_cpuid_setup(void);
89 extern unsigned int OPENSSL_ia32cap_P[];
90 void OPENSSL_showfatal(const char *fmta, ...);
91 void crypto_cleanup_all_ex_data_int(void);
92 int openssl_init_fork_handlers(void);
94 char *ossl_safe_getenv(const char *name);
96 extern CRYPTO_RWLOCK *memdbg_lock;
97 int openssl_strerror_r(int errnum, char *buf, size_t buflen);
98 # if !defined(OPENSSL_NO_STDIO)
99 FILE *openssl_fopen(const char *filename, const char *mode);
101 void *openssl_fopen(const char *filename, const char *mode);
104 uint32_t OPENSSL_rdtsc(void);
105 size_t OPENSSL_instrument_bus(unsigned int *, size_t);
106 size_t OPENSSL_instrument_bus2(unsigned int *, size_t, size_t);
108 # define MAX_OPENSSL_CTX_RUN_ONCE 1
110 typedef struct openssl_ctx_method {
111 void *(*new_func)(void);
112 void (*free_func)(void *);
113 } OPENSSL_CTX_METHOD;
114 /* For each type of data to store in the context, an index must be created */
115 int openssl_ctx_new_index(const OPENSSL_CTX_METHOD *);
116 /* Functions to retrieve pointers to data by index */
117 void *openssl_ctx_get_data(OPENSSL_CTX *, int /* index */);
119 typedef int (*openssl_ctx_run_once_fn)(OPENSSL_CTX *ctx);
120 typedef void (*openssl_ctx_onfree_fn)(OPENSSL_CTX *ctx);
122 int openssl_ctx_run_once(OPENSSL_CTX *ctx, unsigned int idx,
123 openssl_ctx_run_once_fn run_once_fn);
124 int openssl_ctx_onfree(OPENSSL_CTX *ctx, openssl_ctx_onfree_fn onfreefn);