1*1dcdf01fSchristos /*
2*1dcdf01fSchristos * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
3*1dcdf01fSchristos *
4*1dcdf01fSchristos * Licensed under the OpenSSL license (the "License"). You may not use
5*1dcdf01fSchristos * this file except in compliance with the License. You can obtain a copy
6*1dcdf01fSchristos * in the file LICENSE in the source distribution or at
7*1dcdf01fSchristos * https://www.openssl.org/source/license.html
8*1dcdf01fSchristos */
9*1dcdf01fSchristos
10*1dcdf01fSchristos #ifndef OSSL_INTERNAL_CRYPTLIB_H
11*1dcdf01fSchristos # define OSSL_INTERNAL_CRYPTLIB_H
12*1dcdf01fSchristos
13*1dcdf01fSchristos # include <stdlib.h>
14*1dcdf01fSchristos # include <string.h>
15*1dcdf01fSchristos
16*1dcdf01fSchristos # ifdef OPENSSL_USE_APPLINK
17*1dcdf01fSchristos # undef BIO_FLAGS_UPLINK
18*1dcdf01fSchristos # define BIO_FLAGS_UPLINK 0x8000
19*1dcdf01fSchristos # include "ms/uplink.h"
20*1dcdf01fSchristos # endif
21*1dcdf01fSchristos
22*1dcdf01fSchristos # include <openssl/crypto.h>
23*1dcdf01fSchristos # include <openssl/buffer.h>
24*1dcdf01fSchristos # include <openssl/bio.h>
25*1dcdf01fSchristos # include <openssl/err.h>
26*1dcdf01fSchristos # include "internal/nelem.h"
27*1dcdf01fSchristos
28*1dcdf01fSchristos #ifdef NDEBUG
29*1dcdf01fSchristos # define ossl_assert(x) ((x) != 0)
30*1dcdf01fSchristos #else
ossl_assert_int(int expr,const char * exprstr,const char * file,int line)31*1dcdf01fSchristos __owur static ossl_inline int ossl_assert_int(int expr, const char *exprstr,
32*1dcdf01fSchristos const char *file, int line)
33*1dcdf01fSchristos {
34*1dcdf01fSchristos if (!expr)
35*1dcdf01fSchristos OPENSSL_die(exprstr, file, line);
36*1dcdf01fSchristos
37*1dcdf01fSchristos return expr;
38*1dcdf01fSchristos }
39*1dcdf01fSchristos
40*1dcdf01fSchristos # define ossl_assert(x) ossl_assert_int((x) != 0, "Assertion failed: "#x, \
41*1dcdf01fSchristos __FILE__, __LINE__)
42*1dcdf01fSchristos
43*1dcdf01fSchristos #endif
44*1dcdf01fSchristos
45*1dcdf01fSchristos typedef struct ex_callback_st EX_CALLBACK;
46*1dcdf01fSchristos
47*1dcdf01fSchristos DEFINE_STACK_OF(EX_CALLBACK)
48*1dcdf01fSchristos
49*1dcdf01fSchristos typedef struct app_mem_info_st APP_INFO;
50*1dcdf01fSchristos
51*1dcdf01fSchristos typedef struct mem_st MEM;
52*1dcdf01fSchristos DEFINE_LHASH_OF(MEM);
53*1dcdf01fSchristos
54*1dcdf01fSchristos # define OPENSSL_CONF "openssl.cnf"
55*1dcdf01fSchristos
56*1dcdf01fSchristos # ifndef OPENSSL_SYS_VMS
57*1dcdf01fSchristos # define X509_CERT_AREA OPENSSLDIR
58*1dcdf01fSchristos # define X509_CERT_DIR OPENSSLDIR "/certs"
59*1dcdf01fSchristos # define X509_CERT_FILE OPENSSLDIR "/cert.pem"
60*1dcdf01fSchristos # define X509_PRIVATE_DIR OPENSSLDIR "/private"
61*1dcdf01fSchristos # define CTLOG_FILE OPENSSLDIR "/ct_log_list.cnf"
62*1dcdf01fSchristos # else
63*1dcdf01fSchristos # define X509_CERT_AREA "OSSL$DATAROOT:[000000]"
64*1dcdf01fSchristos # define X509_CERT_DIR "OSSL$DATAROOT:[CERTS]"
65*1dcdf01fSchristos # define X509_CERT_FILE "OSSL$DATAROOT:[000000]cert.pem"
66*1dcdf01fSchristos # define X509_PRIVATE_DIR "OSSL$DATAROOT:[PRIVATE]"
67*1dcdf01fSchristos # define CTLOG_FILE "OSSL$DATAROOT:[000000]ct_log_list.cnf"
68*1dcdf01fSchristos # endif
69*1dcdf01fSchristos
70*1dcdf01fSchristos # define X509_CERT_DIR_EVP "SSL_CERT_DIR"
71*1dcdf01fSchristos # define X509_CERT_FILE_EVP "SSL_CERT_FILE"
72*1dcdf01fSchristos # define CTLOG_FILE_EVP "CTLOG_FILE"
73*1dcdf01fSchristos
74*1dcdf01fSchristos /* size of string representations */
75*1dcdf01fSchristos # define DECIMAL_SIZE(type) ((sizeof(type)*8+2)/3+1)
76*1dcdf01fSchristos # define HEX_SIZE(type) (sizeof(type)*2)
77*1dcdf01fSchristos
78*1dcdf01fSchristos void OPENSSL_cpuid_setup(void);
79*1dcdf01fSchristos extern unsigned int OPENSSL_ia32cap_P[];
80*1dcdf01fSchristos void OPENSSL_showfatal(const char *fmta, ...);
81*1dcdf01fSchristos void crypto_cleanup_all_ex_data_int(void);
82*1dcdf01fSchristos int openssl_init_fork_handlers(void);
83*1dcdf01fSchristos int openssl_get_fork_id(void);
84*1dcdf01fSchristos
85*1dcdf01fSchristos char *ossl_safe_getenv(const char *name);
86*1dcdf01fSchristos
87*1dcdf01fSchristos extern CRYPTO_RWLOCK *memdbg_lock;
88*1dcdf01fSchristos int openssl_strerror_r(int errnum, char *buf, size_t buflen);
89*1dcdf01fSchristos # if !defined(OPENSSL_NO_STDIO)
90*1dcdf01fSchristos FILE *openssl_fopen(const char *filename, const char *mode);
91*1dcdf01fSchristos # else
92*1dcdf01fSchristos void *openssl_fopen(const char *filename, const char *mode);
93*1dcdf01fSchristos # endif
94*1dcdf01fSchristos
95*1dcdf01fSchristos uint32_t OPENSSL_rdtsc(void);
96*1dcdf01fSchristos size_t OPENSSL_instrument_bus(unsigned int *, size_t);
97*1dcdf01fSchristos size_t OPENSSL_instrument_bus2(unsigned int *, size_t, size_t);
98*1dcdf01fSchristos
99*1dcdf01fSchristos #endif
100