Adam Langley | 4c921e1 | 2014-07-14 15:28:14 -0700 | [diff] [blame] | 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 | |
David Benjamin | a70c75c | 2014-09-11 19:11:15 -0400 | [diff] [blame] | 15 | #ifndef OPENSSL_HEADER_CRYPTO_H |
| 16 | #define OPENSSL_HEADER_CRYPTO_H |
| 17 | |
| 18 | #include <openssl/base.h> |
| 19 | |
David Benjamin | 4512b79 | 2017-08-18 19:21:50 -0400 | [diff] [blame] | 20 | // Upstream OpenSSL defines |OPENSSL_malloc|, etc., in crypto.h rather than |
| 21 | // mem.h. |
David Benjamin | 2c6080f | 2015-04-24 10:15:31 -0400 | [diff] [blame] | 22 | #include <openssl/mem.h> |
| 23 | |
David Benjamin | 4512b79 | 2017-08-18 19:21:50 -0400 | [diff] [blame] | 24 | // Upstream OpenSSL defines |CRYPTO_LOCK|, etc., in crypto.h rather than |
| 25 | // thread.h. |
Matt Braithwaite | d0e1f1c | 2015-08-05 11:40:35 -0700 | [diff] [blame] | 26 | #include <openssl/thread.h> |
| 27 | |
David Benjamin | a70c75c | 2014-09-11 19:11:15 -0400 | [diff] [blame] | 28 | |
| 29 | #if defined(__cplusplus) |
| 30 | extern "C" { |
| 31 | #endif |
| 32 | |
| 33 | |
David Benjamin | 4512b79 | 2017-08-18 19:21:50 -0400 | [diff] [blame] | 34 | // crypto.h contains functions for initializing the crypto library. |
David Benjamin | a70c75c | 2014-09-11 19:11:15 -0400 | [diff] [blame] | 35 | |
| 36 | |
David Benjamin | 4512b79 | 2017-08-18 19:21:50 -0400 | [diff] [blame] | 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. |
David Benjamin | a70c75c | 2014-09-11 19:11:15 -0400 | [diff] [blame] | 44 | OPENSSL_EXPORT void CRYPTO_library_init(void); |
| 45 | |
David Benjamin | 4512b79 | 2017-08-18 19:21:50 -0400 | [diff] [blame] | 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. |
Adam Langley | b83c680 | 2016-05-03 09:16:21 -0700 | [diff] [blame] | 51 | OPENSSL_EXPORT int CRYPTO_is_confidential_build(void); |
| 52 | |
David Benjamin | 4512b79 | 2017-08-18 19:21:50 -0400 | [diff] [blame] | 53 | // CRYPTO_has_asm returns one unless BoringSSL was built with OPENSSL_NO_ASM, |
| 54 | // in which case it returns zero. |
Adam Langley | 4fac8d0 | 2016-05-16 13:44:40 -0700 | [diff] [blame] | 55 | OPENSSL_EXPORT int CRYPTO_has_asm(void); |
| 56 | |
David Benjamin | 4512b79 | 2017-08-18 19:21:50 -0400 | [diff] [blame] | 57 | // FIPS_mode returns zero unless BoringSSL is built with BORINGSSL_FIPS, in |
| 58 | // which case it returns one. |
Adam Langley | fd49993 | 2017-04-04 14:21:43 -0700 | [diff] [blame] | 59 | OPENSSL_EXPORT int FIPS_mode(void); |
| 60 | |
David Benjamin | a70c75c | 2014-09-11 19:11:15 -0400 | [diff] [blame] | 61 | |
David Benjamin | 4512b79 | 2017-08-18 19:21:50 -0400 | [diff] [blame] | 62 | // Deprecated functions. |
Adam Langley | c3ef76f | 2015-04-13 14:34:17 -0700 | [diff] [blame] | 63 | |
David Benjamin | 4512b79 | 2017-08-18 19:21:50 -0400 | [diff] [blame] | 64 | // OPENSSL_VERSION_TEXT contains a string the identifies the version of |
| 65 | // “OpenSSL”. node.js requires a version number in this text. |
David Benjamin | 81f030b | 2016-08-12 14:48:19 -0400 | [diff] [blame] | 66 | #define OPENSSL_VERSION_TEXT "OpenSSL 1.1.0 (compatible; BoringSSL)" |
Adam Langley | c3ef76f | 2015-04-13 14:34:17 -0700 | [diff] [blame] | 67 | |
| 68 | #define SSLEAY_VERSION 0 |
| 69 | |
David Benjamin | 4512b79 | 2017-08-18 19:21:50 -0400 | [diff] [blame] | 70 | // SSLeay_version is a compatibility function that returns the string |
| 71 | // "BoringSSL". |
Adam Langley | c3ef76f | 2015-04-13 14:34:17 -0700 | [diff] [blame] | 72 | OPENSSL_EXPORT const char *SSLeay_version(int unused); |
| 73 | |
David Benjamin | 81f030b | 2016-08-12 14:48:19 -0400 | [diff] [blame] | 74 | #define OPENSSL_VERSION 0 |
| 75 | |
| 76 | // OpenSSL_version is a compatibility function that returns the string |
| 77 | // "BoringSSL". |
| 78 | OPENSSL_EXPORT const char *OpenSSL_version(int unused); |
| 79 | |
David Benjamin | 4512b79 | 2017-08-18 19:21:50 -0400 | [diff] [blame] | 80 | // SSLeay is a compatibility function that returns OPENSSL_VERSION_NUMBER from |
| 81 | // base.h. |
Adam Langley | b3a262c | 2015-05-19 16:30:20 -0700 | [diff] [blame] | 82 | OPENSSL_EXPORT unsigned long SSLeay(void); |
Adam Langley | c3ef76f | 2015-04-13 14:34:17 -0700 | [diff] [blame] | 83 | |
David Benjamin | 81f030b | 2016-08-12 14:48:19 -0400 | [diff] [blame] | 84 | // OpenSSL_version_num is a compatibility function that returns |
| 85 | // OPENSSL_VERSION_NUMBER from base.h. |
| 86 | OPENSSL_EXPORT unsigned long OpenSSL_version_num(void); |
| 87 | |
David Benjamin | 4512b79 | 2017-08-18 19:21:50 -0400 | [diff] [blame] | 88 | // CRYPTO_malloc_init returns one. |
Adam Langley | 05ee4fd | 2015-08-02 09:35:44 -0700 | [diff] [blame] | 89 | OPENSSL_EXPORT int CRYPTO_malloc_init(void); |
| 90 | |
David Benjamin | 4512b79 | 2017-08-18 19:21:50 -0400 | [diff] [blame] | 91 | // ENGINE_load_builtin_engines does nothing. |
Adam Langley | 05ee4fd | 2015-08-02 09:35:44 -0700 | [diff] [blame] | 92 | OPENSSL_EXPORT void ENGINE_load_builtin_engines(void); |
| 93 | |
David Benjamin | 4512b79 | 2017-08-18 19:21:50 -0400 | [diff] [blame] | 94 | // ENGINE_register_all_complete returns one. |
Adam Langley | 27516f7 | 2016-07-12 10:26:56 -0700 | [diff] [blame] | 95 | OPENSSL_EXPORT int ENGINE_register_all_complete(void); |
| 96 | |
David Benjamin | 4512b79 | 2017-08-18 19:21:50 -0400 | [diff] [blame] | 97 | // OPENSSL_load_builtin_modules does nothing. |
David Benjamin | e5aa791 | 2016-01-26 01:09:19 -0500 | [diff] [blame] | 98 | OPENSSL_EXPORT void OPENSSL_load_builtin_modules(void); |
| 99 | |
David Benjamin | 81f030b | 2016-08-12 14:48:19 -0400 | [diff] [blame] | 100 | #define OPENSSL_INIT_NO_LOAD_CRYPTO_STRINGS 0 |
| 101 | #define OPENSSL_INIT_LOAD_CRYPTO_STRINGS 0 |
| 102 | #define OPENSSL_INIT_ADD_ALL_CIPHERS 0 |
| 103 | #define OPENSSL_INIT_ADD_ALL_DIGESTS 0 |
| 104 | #define OPENSSL_INIT_NO_ADD_ALL_CIPHERS 0 |
| 105 | #define OPENSSL_INIT_NO_ADD_ALL_DIGESTS 0 |
| 106 | #define OPENSSL_INIT_LOAD_CONFIG 0 |
| 107 | #define OPENSSL_INIT_NO_LOAD_CONFIG 0 |
| 108 | |
| 109 | // OPENSSL_init_crypto calls |CRYPTO_library_init| and returns one. |
| 110 | OPENSSL_EXPORT int OPENSSL_init_crypto(uint64_t opts, |
| 111 | const OPENSSL_INIT_SETTINGS *settings); |
| 112 | |
Adam Langley | c3ef76f | 2015-04-13 14:34:17 -0700 | [diff] [blame] | 113 | |
David Benjamin | a70c75c | 2014-09-11 19:11:15 -0400 | [diff] [blame] | 114 | #if defined(__cplusplus) |
David Benjamin | 4512b79 | 2017-08-18 19:21:50 -0400 | [diff] [blame] | 115 | } // extern C |
David Benjamin | a70c75c | 2014-09-11 19:11:15 -0400 | [diff] [blame] | 116 | #endif |
Adam Langley | 4c921e1 | 2014-07-14 15:28:14 -0700 | [diff] [blame] | 117 | |
David Benjamin | 4512b79 | 2017-08-18 19:21:50 -0400 | [diff] [blame] | 118 | #endif // OPENSSL_HEADER_CRYPTO_H |