| 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. |
| 45 | OPENSSL_EXPORT void CRYPTO_library_init(void); |
| 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. |
| 52 | OPENSSL_EXPORT int CRYPTO_is_confidential_build(void); |
| 53 |
| 54 | // CRYPTO_has_asm returns one unless BoringSSL was built with OPENSSL_NO_ASM, |
| 55 | // in which case it returns zero. |
| 56 | OPENSSL_EXPORT int CRYPTO_has_asm(void); |
| 57 |
| 58 | // FIPS_mode returns zero unless BoringSSL is built with BORINGSSL_FIPS, in |
| 59 | // which case it returns one. |
| 60 | OPENSSL_EXPORT int FIPS_mode(void); |
| 61 |
| 62 | // BORINGSSL_self_test triggers the FIPS KAT-based self tests. It returns one on |
| 63 | // success and zero on error. The argument is the integrity hash of the FIPS |
| 64 | // module and may be used to check and write flag files to suppress duplicate |
| 65 | // self-tests. If it is all zeros, no flag file will be checked nor written and |
| 66 | // tests will always be run. |
| 67 | OPENSSL_EXPORT int BORINGSSL_self_test( |
| 68 | const uint8_t module_sha512_hash[SHA512_DIGEST_LENGTH]); |
| 69 |
| 70 |
| 71 | // Deprecated functions. |
| 72 |
| 73 | // OPENSSL_VERSION_TEXT contains a string the identifies the version of |
| 74 | // “OpenSSL”. node.js requires a version number in this text. |
| 75 | #define OPENSSL_VERSION_TEXT "OpenSSL 1.1.0 (compatible; BoringSSL)" |
| 76 |
| 77 | #define OPENSSL_VERSION 0 |
| 78 | #define OPENSSL_CFLAGS 1 |
| 79 | #define OPENSSL_BUILT_ON 2 |
| 80 | #define OPENSSL_PLATFORM 3 |
| 81 | #define OPENSSL_DIR 4 |
| 82 |
| 83 | // OpenSSL_version is a compatibility function that returns the string |
| 84 | // "BoringSSL" if |which| is |OPENSSL_VERSION| and placeholder strings |
| 85 | // otherwise. |
| 86 | OPENSSL_EXPORT const char *OpenSSL_version(int which); |
| 87 |
| 88 | #define SSLEAY_VERSION OPENSSL_VERSION |
| 89 | #define SSLEAY_CFLAGS OPENSSL_CFLAGS |
| 90 | #define SSLEAY_BUILT_ON OPENSSL_BUILT_ON |
| 91 | #define SSLEAY_PLATFORM OPENSSL_PLATFORM |
| 92 | #define SSLEAY_DIR OPENSSL_DIR |
| 93 |
| 94 | // SSLeay_version calls |OpenSSL_version|. |
| 95 | OPENSSL_EXPORT const char *SSLeay_version(int which); |
| 96 |
| 97 | // SSLeay is a compatibility function that returns OPENSSL_VERSION_NUMBER from |
| 98 | // base.h. |
| 99 | OPENSSL_EXPORT unsigned long SSLeay(void); |
| 100 |
| 101 | // OpenSSL_version_num is a compatibility function that returns |
| 102 | // OPENSSL_VERSION_NUMBER from base.h. |
| 103 | OPENSSL_EXPORT unsigned long OpenSSL_version_num(void); |
| 104 |
| 105 | // CRYPTO_malloc_init returns one. |
| 106 | OPENSSL_EXPORT int CRYPTO_malloc_init(void); |
| 107 |
| 108 | // OPENSSL_malloc_init returns one. |
| 109 | OPENSSL_EXPORT int OPENSSL_malloc_init(void); |
| 110 |
| 111 | // ENGINE_load_builtin_engines does nothing. |
| 112 | OPENSSL_EXPORT void ENGINE_load_builtin_engines(void); |
| 113 |
| 114 | // ENGINE_register_all_complete returns one. |
| 115 | OPENSSL_EXPORT int ENGINE_register_all_complete(void); |
| 116 |
| 117 | // OPENSSL_load_builtin_modules does nothing. |
| 118 | OPENSSL_EXPORT void OPENSSL_load_builtin_modules(void); |
| 119 |
| 120 | #define OPENSSL_INIT_NO_LOAD_CRYPTO_STRINGS 0 |
| 121 | #define OPENSSL_INIT_LOAD_CRYPTO_STRINGS 0 |
| 122 | #define OPENSSL_INIT_ADD_ALL_CIPHERS 0 |
| 123 | #define OPENSSL_INIT_ADD_ALL_DIGESTS 0 |
| 124 | #define OPENSSL_INIT_NO_ADD_ALL_CIPHERS 0 |
| 125 | #define OPENSSL_INIT_NO_ADD_ALL_DIGESTS 0 |
| 126 | #define OPENSSL_INIT_LOAD_CONFIG 0 |
| 127 | #define OPENSSL_INIT_NO_LOAD_CONFIG 0 |
| 128 |
| 129 | // OPENSSL_init_crypto calls |CRYPTO_library_init| and returns one. |
| 130 | OPENSSL_EXPORT int OPENSSL_init_crypto(uint64_t opts, |
| 131 | const OPENSSL_INIT_SETTINGS *settings); |
| 132 |
| 133 | // OPENSSL_cleanup does nothing. |
| 134 | OPENSSL_EXPORT void OPENSSL_cleanup(void); |
| 135 |
| 136 | // FIPS_mode_set returns one if |on| matches whether BoringSSL was built with |
| 137 | // |BORINGSSL_FIPS| and zero otherwise. |
| 138 | OPENSSL_EXPORT int FIPS_mode_set(int on); |
| 139 |
| 140 |
| 141 | #if defined(__cplusplus) |
| 142 | } // extern C |
| 143 | #endif |
| 144 |
| 145 | #endif // OPENSSL_HEADER_CRYPTO_H |
| 146 |