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 20 // Upstream OpenSSL defines |OPENSSL_malloc|, etc., in crypto.h rather than 21 // mem.h. 22 #include <openssl/mem.h> 23 24 // Upstream OpenSSL defines |CRYPTO_LOCK|, etc., in crypto.h rather than 25 // thread.h. 26 #include <openssl/thread.h> 27 28 29 #if defined(__cplusplus) 30 extern "C" { 31 #endif 32 33 34 // crypto.h contains functions for initializing the crypto library. 35 36 37 // CRYPTO_library_init initializes the crypto library. It must be called if the 38 // library is built with BORINGSSL_NO_STATIC_INITIALIZER. Otherwise, it does 39 // nothing and a static initializer is used instead. It is safe to call this 40 // function multiple times and concurrently from multiple threads. 41 // 42 // On some ARM configurations, this function may require filesystem access and 43 // should be called before entering a sandbox. 44 OPENSSL_EXPORT void CRYPTO_library_init(void); 45 46 // CRYPTO_is_confidential_build returns one if the linked version of BoringSSL 47 // has been built with the BORINGSSL_CONFIDENTIAL define and zero otherwise. 48 // 49 // This is used by some consumers to identify whether they are using an 50 // internal version of BoringSSL. 51 OPENSSL_EXPORT int CRYPTO_is_confidential_build(void); 52 53 // CRYPTO_has_asm returns one unless BoringSSL was built with OPENSSL_NO_ASM, 54 // in which case it returns zero. 55 OPENSSL_EXPORT int CRYPTO_has_asm(void); 56 57 // FIPS_mode returns zero unless BoringSSL is built with BORINGSSL_FIPS, in 58 // which case it returns one. 59 OPENSSL_EXPORT int FIPS_mode(void); 60 61 // BORINGSSL_self_test triggers the FIPS KAT-based self tests. It returns one 62 // on success and zero on error. 63 OPENSSL_EXPORT int BORINGSSL_self_test(void); 64 65 66 // Deprecated functions. 67 68 // OPENSSL_VERSION_TEXT contains a string the identifies the version of 69 // “OpenSSL”. node.js requires a version number in this text. 70 #define OPENSSL_VERSION_TEXT "OpenSSL 1.1.0 (compatible; BoringSSL)" 71 72 #define OPENSSL_VERSION 0 73 #define OPENSSL_CFLAGS 1 74 #define OPENSSL_BUILT_ON 2 75 #define OPENSSL_PLATFORM 3 76 #define OPENSSL_DIR 4 77 78 // OpenSSL_version is a compatibility function that returns the string 79 // "BoringSSL" if |which| is |OPENSSL_VERSION| and placeholder strings 80 // otherwise. 81 OPENSSL_EXPORT const char *OpenSSL_version(int which); 82 83 #define SSLEAY_VERSION OPENSSL_VERSION 84 #define SSLEAY_CFLAGS OPENSSL_CFLAGS 85 #define SSLEAY_BUILT_ON OPENSSL_BUILT_ON 86 #define SSLEAY_PLATFORM OPENSSL_PLATFORM 87 #define SSLEAY_DIR OPENSSL_DIR 88 89 // SSLeay_version calls |OpenSSL_version|. 90 OPENSSL_EXPORT const char *SSLeay_version(int which); 91 92 // SSLeay is a compatibility function that returns OPENSSL_VERSION_NUMBER from 93 // base.h. 94 OPENSSL_EXPORT unsigned long SSLeay(void); 95 96 // OpenSSL_version_num is a compatibility function that returns 97 // OPENSSL_VERSION_NUMBER from base.h. 98 OPENSSL_EXPORT unsigned long OpenSSL_version_num(void); 99 100 // CRYPTO_malloc_init returns one. 101 OPENSSL_EXPORT int CRYPTO_malloc_init(void); 102 103 // OPENSSL_malloc_init returns one. 104 OPENSSL_EXPORT int OPENSSL_malloc_init(void); 105 106 // ENGINE_load_builtin_engines does nothing. 107 OPENSSL_EXPORT void ENGINE_load_builtin_engines(void); 108 109 // ENGINE_register_all_complete returns one. 110 OPENSSL_EXPORT int ENGINE_register_all_complete(void); 111 112 // OPENSSL_load_builtin_modules does nothing. 113 OPENSSL_EXPORT void OPENSSL_load_builtin_modules(void); 114 115 #define OPENSSL_INIT_NO_LOAD_CRYPTO_STRINGS 0 116 #define OPENSSL_INIT_LOAD_CRYPTO_STRINGS 0 117 #define OPENSSL_INIT_ADD_ALL_CIPHERS 0 118 #define OPENSSL_INIT_ADD_ALL_DIGESTS 0 119 #define OPENSSL_INIT_NO_ADD_ALL_CIPHERS 0 120 #define OPENSSL_INIT_NO_ADD_ALL_DIGESTS 0 121 #define OPENSSL_INIT_LOAD_CONFIG 0 122 #define OPENSSL_INIT_NO_LOAD_CONFIG 0 123 124 // OPENSSL_init_crypto calls |CRYPTO_library_init| and returns one. 125 OPENSSL_EXPORT int OPENSSL_init_crypto(uint64_t opts, 126 const OPENSSL_INIT_SETTINGS *settings); 127 128 // OPENSSL_cleanup does nothing. 129 OPENSSL_EXPORT void OPENSSL_cleanup(void); 130 131 // FIPS_mode_set returns one if |on| matches whether BoringSSL was built with 132 // |BORINGSSL_FIPS| and zero otherwise. 133 OPENSSL_EXPORT int FIPS_mode_set(int on); 134 135 136 #if defined(__cplusplus) 137 } // extern C 138 #endif 139 140 #endif // OPENSSL_HEADER_CRYPTO_H 141