Debian Codegraph @

debian/rust-vendor/aws-lc-sys/aws-lc/include/openssl/crypto.h

raw
1 // Copyright (c) 2014, Google Inc.
2 // SPDX-License-Identifier: ISC
3
4 #ifndef OPENSSL_HEADER_CRYPTO_H
5 #define OPENSSL_HEADER_CRYPTO_H
6
7 #include <openssl/base.h>
8 #include <openssl/err.h>
9 #include <openssl/sha.h>
10
11 // Upstream OpenSSL defines |OPENSSL_malloc|, etc., in crypto.h rather than
12 // mem.h.
13 #include <openssl/mem.h>
14
15 // Upstream OpenSSL defines |CRYPTO_LOCK|, etc., in crypto.h rather than
16 // thread.h.
17 #include <openssl/thread.h>
18
19
20 #if defined(__cplusplus)
21 extern "C" {
22 #endif
23
24
25 // crypto.h contains functions for initializing the crypto library.
26
27
28 // CRYPTO_library_init initializes the crypto library. It must be called if the
29 // library is built with BORINGSSL_NO_STATIC_INITIALIZER. Otherwise, it does
30 // nothing and a static initializer is used instead. It is safe to call this
31 // function multiple times and concurrently from multiple threads.
32 //
33 // On some ARM configurations, this function may require filesystem access and
34 // should be called before entering a sandbox.
35 OPENSSL_EXPORT void CRYPTO_library_init(void);
36
37 // CRYPTO_is_confidential_build returns one if the linked version of BoringSSL
38 // has been built with the BORINGSSL_CONFIDENTIAL define and zero otherwise.
39 //
40 // This is used by some consumers to identify whether they are using an
41 // internal version of BoringSSL.
42 OPENSSL_EXPORT int CRYPTO_is_confidential_build(void);
43
44 // CRYPTO_has_asm returns one unless BoringSSL was built with OPENSSL_NO_ASM,
45 // in which case it returns zero.
46 OPENSSL_EXPORT int CRYPTO_has_asm(void);
47
48 // BORINGSSL_self_test triggers the FIPS KAT-based self tests. It returns one on
49 // success and zero on error.
50 OPENSSL_EXPORT int BORINGSSL_self_test(void);
51
52 // BORINGSSL_integrity_test triggers the module's integrity test where the code
53 // and data of the module is matched against a hash injected at build time. It
54 // returns one on success or zero if there's a mismatch. This function only
55 // exists if the module was built in FIPS mode without ASAN.
56 OPENSSL_EXPORT int BORINGSSL_integrity_test(void);
57
58 // CRYPTO_pre_sandbox_init initializes the crypto library, pre-acquiring some
59 // unusual resources to aid running in sandboxed environments. It is safe to
60 // call this function multiple times and concurrently from multiple threads.
61 //
62 // For more details on using BoringSSL in a sandboxed environment, see
63 // SANDBOXING.md in the source tree.
64 OPENSSL_EXPORT void CRYPTO_pre_sandbox_init(void);
65
66 #if defined(OPENSSL_ARM) && defined(OPENSSL_LINUX) && \
67 !defined(OPENSSL_STATIC_ARMCAP)
68 // CRYPTO_has_broken_NEON returns zero.
69 OPENSSL_EXPORT int CRYPTO_has_broken_NEON(void);
70
71 // CRYPTO_needs_hwcap2_workaround returns one if the ARMv8 AArch32 AT_HWCAP2
72 // workaround was needed. See https://crbug.com/boringssl/46.
73 OPENSSL_EXPORT int CRYPTO_needs_hwcap2_workaround(void);
74 #endif // OPENSSL_ARM && OPENSSL_LINUX && !OPENSSL_STATIC_ARMCAP
75
76 // Data-Independent Timing (DIT) on AArch64
77 #if defined(OPENSSL_AARCH64) && (defined(OPENSSL_LINUX) || defined(OPENSSL_APPLE))
78 // (TODO): See if we can detect the DIT capability in Windows environment
79 #define AARCH64_DIT_SUPPORTED
80 #endif
81
82 #if defined(AARCH64_DIT_SUPPORTED)
83
84 // armv8_disable_dit is a runtime disabler of the DIT capability.
85 // It results in CRYPTO_is_ARMv8_DIT_capable() returning 0 even if the
86 // capability exists.
87 // Important: This runtime control is provided to users that would use
88 // the build flag ENABLE_DATA_INDEPENDENT_TIMING, but would
89 // then disable DIT capability at runtime. This is ideally done in
90 // an initialization routine of AWS-LC before any threads are spawn.
91 // Otherwise, there may be data races created because this function writes
92 // to |OPENSSL_armcap_P|.
93 OPENSSL_EXPORT void armv8_disable_dit(void);
94
95 // armv8_enable_dit is a runtime enabler of the DIT capability. If
96 // |armv8_disable_dit| was used to disable the DIT capability, this function
97 // makes it available again.
98 // Important: See note in |armv8_disable_dit|.
99 OPENSSL_EXPORT void armv8_enable_dit(void);
100
101 #endif // AARCH64_DIT_SUPPORTED
102
103 // FIPS monitoring
104
105 // FIPS_mode returns zero unless BoringSSL is built with BORINGSSL_FIPS, in
106 // which case it returns one.
107 OPENSSL_EXPORT int FIPS_mode(void);
108
109 // FIPS_is_entropy_cpu_jitter returns 1 if CPU jitter is used as the entropy source
110 // for AWS-LC. Otherwise, returns 0;
111 OPENSSL_EXPORT int FIPS_is_entropy_cpu_jitter(void);
112
113 // Deprecated functions.
114
115 // OPENSSL_VERSION_TEXT contains a string the identifies the version of
116 // “OpenSSL”. node.js requires a version number in this text.
117 #define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1 (compatible; AWS-LC " AWSLC_VERSION_NUMBER_STRING ")"
118
119 #define OPENSSL_VERSION 0
120 #define OPENSSL_CFLAGS 1
121 #define OPENSSL_BUILT_ON 2
122 #define OPENSSL_PLATFORM 3
123 #define OPENSSL_DIR 4
124
125 // OpenSSL_version is a compatibility function that returns the string
126 // "AWS-LC" with the AWS-LC version number appended if |which| is
127 // |OPENSSL_VERSION| and placeholder strings otherwise.
128 OPENSSL_EXPORT const char *OpenSSL_version(int which);
129
130 #define SSLEAY_VERSION OPENSSL_VERSION
131 #define SSLEAY_CFLAGS OPENSSL_CFLAGS
132 #define SSLEAY_BUILT_ON OPENSSL_BUILT_ON
133 #define SSLEAY_PLATFORM OPENSSL_PLATFORM
134 #define SSLEAY_DIR OPENSSL_DIR
135
136 // SSLeay_version calls |OpenSSL_version|.
137 OPENSSL_EXPORT const char *SSLeay_version(int which);
138
139 // SSLeay is a compatibility function that returns OPENSSL_VERSION_NUMBER from
140 // base.h.
141 OPENSSL_EXPORT unsigned long SSLeay(void);
142
143 // OpenSSL_version_num is a compatibility function that returns
144 // OPENSSL_VERSION_NUMBER from base.h.
145 OPENSSL_EXPORT unsigned long OpenSSL_version_num(void);
146
147 OPENSSL_EXPORT unsigned long awslc_api_version_num(void);
148
149 // CRYPTO_malloc_init returns one.
150 OPENSSL_EXPORT int CRYPTO_malloc_init(void);
151
152 // OPENSSL_malloc_init returns one.
153 OPENSSL_EXPORT int OPENSSL_malloc_init(void);
154
155 // ENGINE_load_builtin_engines does nothing.
156 OPENSSL_DEPRECATED OPENSSL_EXPORT void ENGINE_load_builtin_engines(void);
157
158 // ENGINE_register_all_ciphers does nothing.
159 OPENSSL_DEPRECATED OPENSSL_EXPORT void ENGINE_register_all_ciphers(void);
160
161 // ENGINE_register_all_digests does nothing.
162 OPENSSL_DEPRECATED OPENSSL_EXPORT void ENGINE_register_all_digests(void);
163
164 // ENGINE_register_all_complete returns one.
165 OPENSSL_DEPRECATED OPENSSL_EXPORT int ENGINE_register_all_complete(void);
166
167 // OPENSSL_load_builtin_modules does nothing.
168 OPENSSL_EXPORT void OPENSSL_load_builtin_modules(void);
169
170 // AWS-LC does not support custom flags when initializing the library, these
171 // values are included to simplify building other software that expects them.
172
173 #define OPENSSL_INIT_NO_LOAD_CRYPTO_STRINGS 0
174 #define OPENSSL_INIT_LOAD_CRYPTO_STRINGS 0
175 #define OPENSSL_INIT_ADD_ALL_CIPHERS 0
176 #define OPENSSL_INIT_ADD_ALL_DIGESTS 0
177 #define OPENSSL_INIT_NO_ADD_ALL_CIPHERS 0
178 #define OPENSSL_INIT_NO_ADD_ALL_DIGESTS 0
179 #define OPENSSL_INIT_LOAD_CONFIG 0
180 #define OPENSSL_INIT_NO_LOAD_CONFIG 0
181 #define OPENSSL_INIT_ENGINE_ALL_BUILTIN 0
182 #define OPENSSL_INIT_ATFORK 0
183
184 // OPENSSL_init_crypto calls |CRYPTO_library_init| and returns one.
185 OPENSSL_EXPORT int OPENSSL_init_crypto(uint64_t opts,
186 const OPENSSL_INIT_SETTINGS *settings);
187
188 // OPENSSL_init does nothing.
189 OPENSSL_EXPORT void OPENSSL_init(void);
190
191 // OPENSSL_cleanup does nothing.
192 OPENSSL_EXPORT void OPENSSL_cleanup(void);
193
194 // FIPS_mode_set returns one if |on| matches whether BoringSSL was built with
195 // |BORINGSSL_FIPS| and zero otherwise.
196 OPENSSL_EXPORT int FIPS_mode_set(int on);
197
198 // CRYPTO_mem_ctrl intentionally does nothing and returns 0.
199 // AWS-LC defines |OPENSSL_NO_CRYPTO_MDEBUG| by default.
200 // These are related to memory debugging functionalities provided by OpenSSL,
201 // but are not supported in AWS-LC.
202 OPENSSL_EXPORT OPENSSL_DEPRECATED int CRYPTO_mem_ctrl(int mode);
203
204 #define CRYPTO_MEM_CHECK_ON 0
205
206
207 #if defined(__cplusplus)
208 } // extern C
209 #endif
210
211 #endif // OPENSSL_HEADER_CRYPTO_H