crypto.h
Go to the documentation of this file.
1 /* Copyright (c) 2014, Google Inc.
2  *
3  * Permission to use, copy, modify, and/or distribute this software for any
4  * purpose with or without fee is hereby granted, provided that the above
5  * copyright notice and this permission notice appear in all copies.
6  *
7  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10  * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
14 
15 #ifndef OPENSSL_HEADER_CRYPTO_H
16 #define OPENSSL_HEADER_CRYPTO_H
17 
18 #include <openssl/base.h>
19 #include <openssl/sha.h>
20 
21 // Upstream OpenSSL defines |OPENSSL_malloc|, etc., in crypto.h rather than
22 // mem.h.
23 #include <openssl/mem.h>
24 
25 // Upstream OpenSSL defines |CRYPTO_LOCK|, etc., in crypto.h rather than
26 // thread.h.
27 #include <openssl/thread.h>
28 
29 
30 #if defined(__cplusplus)
31 extern "C" {
32 #endif
33 
34 
35 // crypto.h contains functions for initializing the crypto library.
36 
37 
38 // CRYPTO_library_init initializes the crypto library. It must be called if the
39 // library is built with BORINGSSL_NO_STATIC_INITIALIZER. Otherwise, it does
40 // nothing and a static initializer is used instead. It is safe to call this
41 // function multiple times and concurrently from multiple threads.
42 //
43 // On some ARM configurations, this function may require filesystem access and
44 // should be called before entering a sandbox.
46 
47 // CRYPTO_is_confidential_build returns one if the linked version of BoringSSL
48 // has been built with the BORINGSSL_CONFIDENTIAL define and zero otherwise.
49 //
50 // This is used by some consumers to identify whether they are using an
51 // internal version of BoringSSL.
53 
54 // CRYPTO_has_asm returns one unless BoringSSL was built with OPENSSL_NO_ASM,
55 // in which case it returns zero.
57 
58 // BORINGSSL_self_test triggers the FIPS KAT-based self tests. It returns one on
59 // success and zero on error.
61 
62 // CRYPTO_pre_sandbox_init initializes the crypto library, pre-acquiring some
63 // unusual resources to aid running in sandboxed environments. It is safe to
64 // call this function multiple times and concurrently from multiple threads.
65 //
66 // For more details on using BoringSSL in a sandboxed environment, see
67 // SANDBOXING.md in the source tree.
69 
70 
71 // FIPS monitoring
72 
73 // FIPS_mode returns zero unless BoringSSL is built with BORINGSSL_FIPS, in
74 // which case it returns one.
75 OPENSSL_EXPORT int FIPS_mode(void);
76 
77 // fips_counter_t denotes specific APIs/algorithms. A counter is maintained for
78 // each in FIPS mode so that tests can be written to assert that the expected,
79 // FIPS functions are being called by a certain peice of code.
85 
87 };
88 
89 // FIPS_read_counter returns a counter of the number of times the specific
90 // function denoted by |counter| has been used. This always returns zero unless
91 // BoringSSL was built with BORINGSSL_FIPS_COUNTERS defined.
93 
94 
95 // Deprecated functions.
96 
97 // OPENSSL_VERSION_TEXT contains a string the identifies the version of
98 // “OpenSSL”. node.js requires a version number in this text.
99 #define OPENSSL_VERSION_TEXT "OpenSSL 1.1.1 (compatible; BoringSSL)"
100 
101 #define OPENSSL_VERSION 0
102 #define OPENSSL_CFLAGS 1
103 #define OPENSSL_BUILT_ON 2
104 #define OPENSSL_PLATFORM 3
105 #define OPENSSL_DIR 4
106 
107 // OpenSSL_version is a compatibility function that returns the string
108 // "BoringSSL" if |which| is |OPENSSL_VERSION| and placeholder strings
109 // otherwise.
110 OPENSSL_EXPORT const char *OpenSSL_version(int which);
111 
112 #define SSLEAY_VERSION OPENSSL_VERSION
113 #define SSLEAY_CFLAGS OPENSSL_CFLAGS
114 #define SSLEAY_BUILT_ON OPENSSL_BUILT_ON
115 #define SSLEAY_PLATFORM OPENSSL_PLATFORM
116 #define SSLEAY_DIR OPENSSL_DIR
117 
118 // SSLeay_version calls |OpenSSL_version|.
119 OPENSSL_EXPORT const char *SSLeay_version(int which);
120 
121 // SSLeay is a compatibility function that returns OPENSSL_VERSION_NUMBER from
122 // base.h.
123 OPENSSL_EXPORT unsigned long SSLeay(void);
124 
125 // OpenSSL_version_num is a compatibility function that returns
126 // OPENSSL_VERSION_NUMBER from base.h.
127 OPENSSL_EXPORT unsigned long OpenSSL_version_num(void);
128 
129 // CRYPTO_malloc_init returns one.
131 
132 // OPENSSL_malloc_init returns one.
134 
135 // ENGINE_load_builtin_engines does nothing.
137 
138 // ENGINE_register_all_complete returns one.
140 
141 // OPENSSL_load_builtin_modules does nothing.
143 
144 #define OPENSSL_INIT_NO_LOAD_CRYPTO_STRINGS 0
145 #define OPENSSL_INIT_LOAD_CRYPTO_STRINGS 0
146 #define OPENSSL_INIT_ADD_ALL_CIPHERS 0
147 #define OPENSSL_INIT_ADD_ALL_DIGESTS 0
148 #define OPENSSL_INIT_NO_ADD_ALL_CIPHERS 0
149 #define OPENSSL_INIT_NO_ADD_ALL_DIGESTS 0
150 #define OPENSSL_INIT_LOAD_CONFIG 0
151 #define OPENSSL_INIT_NO_LOAD_CONFIG 0
152 
153 // OPENSSL_init_crypto calls |CRYPTO_library_init| and returns one.
156 
157 // OPENSSL_cleanup does nothing.
159 
160 // FIPS_mode_set returns one if |on| matches whether BoringSSL was built with
161 // |BORINGSSL_FIPS| and zero otherwise.
162 OPENSSL_EXPORT int FIPS_mode_set(int on);
163 
164 
165 #if defined(__cplusplus)
166 } // extern C
167 #endif
168 
169 #endif // OPENSSL_HEADER_CRYPTO_H
OPENSSL_load_builtin_modules
OPENSSL_EXPORT void OPENSSL_load_builtin_modules(void)
Definition: crypto.c:219
CRYPTO_is_confidential_build
OPENSSL_EXPORT int CRYPTO_is_confidential_build(void)
Definition: crypto.c:163
OPENSSL_cleanup
OPENSSL_EXPORT void OPENSSL_cleanup(void)
Definition: crypto.c:226
CRYPTO_malloc_init
OPENSSL_EXPORT int CRYPTO_malloc_init(void)
Definition: crypto.c:211
CRYPTO_pre_sandbox_init
OPENSSL_EXPORT void CRYPTO_pre_sandbox_init(void)
Definition: crypto.c:179
OPENSSL_malloc_init
OPENSSL_EXPORT int OPENSSL_malloc_init(void)
Definition: crypto.c:213
cstest_report.opts
opts
Definition: cstest_report.py:81
CRYPTO_library_init
OPENSSL_EXPORT void CRYPTO_library_init(void)
Definition: crypto.c:154
SSLeay
OPENSSL_EXPORT unsigned long SSLeay(void)
Definition: crypto.c:207
base.h
FIPS_read_counter
OPENSSL_EXPORT size_t FIPS_read_counter(enum fips_counter_t counter)
Definition: fips.c:74
ENGINE_register_all_complete
OPENSSL_EXPORT int ENGINE_register_all_complete(void)
Definition: crypto.c:217
fips_counter_evp_aes_128_ctr
@ fips_counter_evp_aes_128_ctr
Definition: crypto.h:83
fips_counter_t
fips_counter_t
Definition: crypto.h:80
sha.h
fips_counter_max
@ fips_counter_max
Definition: crypto.h:86
uint64_t
unsigned __int64 uint64_t
Definition: stdint-msvc2008.h:90
python_utils.jobset.which
def which(filename)
Definition: jobset.py:157
counter
static int counter
Definition: abseil-cpp/absl/flags/reflection_test.cc:131
OPENSSL_init_crypto
OPENSSL_EXPORT int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings)
Definition: crypto.c:221
OpenSSL_version_num
OPENSSL_EXPORT unsigned long OpenSSL_version_num(void)
Definition: crypto.c:209
ENGINE_load_builtin_engines
OPENSSL_EXPORT void ENGINE_load_builtin_engines(void)
Definition: crypto.c:215
FIPS_mode_set
OPENSSL_EXPORT int FIPS_mode_set(int on)
Definition: fips.c:29
OPENSSL_INIT_SETTINGS
struct ossl_init_settings_st OPENSSL_INIT_SETTINGS
Definition: base.h:420
check_version.settings
settings
Definition: check_version.py:61
FIPS_mode
OPENSSL_EXPORT int FIPS_mode(void)
Definition: fips.c:21
fips_counter_evp_aes_256_ctr
@ fips_counter_evp_aes_256_ctr
Definition: crypto.h:84
CRYPTO_has_asm
OPENSSL_EXPORT int CRYPTO_has_asm(void)
Definition: crypto.c:171
OPENSSL_EXPORT
#define OPENSSL_EXPORT
Definition: base.h:222
OpenSSL_version
const OPENSSL_EXPORT char * OpenSSL_version(int which)
Definition: crypto.c:190
mem.h
fips_counter_evp_aes_128_gcm
@ fips_counter_evp_aes_128_gcm
Definition: crypto.h:81
SSLeay_version
const OPENSSL_EXPORT char * SSLeay_version(int which)
Definition: crypto.c:188
thread.h
fips_counter_evp_aes_256_gcm
@ fips_counter_evp_aes_256_gcm
Definition: crypto.h:82
BORINGSSL_self_test
OPENSSL_EXPORT int BORINGSSL_self_test(void)
Definition: self_check.c:870


grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:59:00