2014-07-14 23:28:14 +01:00
|
|
|
/* ====================================================================
|
|
|
|
* Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
*
|
|
|
|
* 3. All advertising materials mentioning features or use of this
|
|
|
|
* software must display the following acknowledgment:
|
|
|
|
* "This product includes software developed by the OpenSSL Project
|
|
|
|
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
|
|
|
*
|
|
|
|
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
|
|
|
* endorse or promote products derived from this software without
|
|
|
|
* prior written permission. For written permission, please contact
|
|
|
|
* openssl-core@openssl.org.
|
|
|
|
*
|
|
|
|
* 5. Products derived from this software may not be called "OpenSSL"
|
|
|
|
* nor may "OpenSSL" appear in their names without prior written
|
|
|
|
* permission of the OpenSSL Project.
|
|
|
|
*
|
|
|
|
* 6. Redistributions of any form whatsoever must retain the following
|
|
|
|
* acknowledgment:
|
|
|
|
* "This product includes software developed by the OpenSSL Project
|
|
|
|
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
|
|
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
|
|
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
|
|
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
* ====================================================================
|
|
|
|
*
|
|
|
|
* This product includes cryptographic software written by Eric Young
|
|
|
|
* (eay@cryptsoft.com). This product includes software written by Tim
|
|
|
|
* Hudson (tjh@cryptsoft.com). */
|
|
|
|
|
|
|
|
#ifndef OPENSSL_HEADER_BASE_H
|
|
|
|
#define OPENSSL_HEADER_BASE_H
|
|
|
|
|
2014-07-31 00:02:14 +01:00
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// This file should be the first included by all BoringSSL headers.
|
2014-07-31 00:02:14 +01:00
|
|
|
|
2015-03-28 07:12:01 +00:00
|
|
|
#include <stddef.h>
|
2014-07-14 23:28:14 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
2016-10-10 19:41:44 +01:00
|
|
|
#if defined(__MINGW32__)
|
2017-08-19 00:21:50 +01:00
|
|
|
// stdio.h is needed on MinGW for __MINGW_PRINTF_FORMAT.
|
2016-10-10 19:41:44 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#endif
|
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// Include a BoringSSL-only header so consumers including this header without
|
|
|
|
// setting up include paths do not accidentally pick up the system
|
|
|
|
// opensslconf.h.
|
2017-04-12 21:28:25 +01:00
|
|
|
#include <openssl/is_boringssl.h>
|
2016-02-25 16:39:59 +00:00
|
|
|
#include <openssl/opensslconf.h>
|
2014-07-15 03:21:44 +01:00
|
|
|
|
2016-04-14 21:35:26 +01:00
|
|
|
#if defined(BORINGSSL_PREFIX)
|
|
|
|
#include <boringssl_prefix_symbols.h>
|
|
|
|
#endif
|
|
|
|
|
2014-09-02 22:28:49 +01:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2014-07-14 23:28:14 +01:00
|
|
|
#if defined(__x86_64) || defined(_M_AMD64) || defined(_M_X64)
|
|
|
|
#define OPENSSL_64_BIT
|
|
|
|
#define OPENSSL_X86_64
|
|
|
|
#elif defined(__x86) || defined(__i386) || defined(__i386__) || defined(_M_IX86)
|
|
|
|
#define OPENSSL_32_BIT
|
|
|
|
#define OPENSSL_X86
|
|
|
|
#elif defined(__aarch64__)
|
|
|
|
#define OPENSSL_64_BIT
|
|
|
|
#define OPENSSL_AARCH64
|
|
|
|
#elif defined(__arm) || defined(__arm__) || defined(_M_ARM)
|
|
|
|
#define OPENSSL_32_BIT
|
|
|
|
#define OPENSSL_ARM
|
2016-09-23 20:47:24 +01:00
|
|
|
#elif (defined(__PPC64__) || defined(__powerpc64__)) && defined(_LITTLE_ENDIAN)
|
2015-01-09 23:44:37 +00:00
|
|
|
#define OPENSSL_64_BIT
|
2016-09-23 20:47:24 +01:00
|
|
|
#define OPENSSL_PPC64LE
|
2015-03-20 23:46:23 +00:00
|
|
|
#elif defined(__mips__) && !defined(__LP64__)
|
2014-07-14 23:28:14 +01:00
|
|
|
#define OPENSSL_32_BIT
|
|
|
|
#define OPENSSL_MIPS
|
2015-03-20 23:46:23 +00:00
|
|
|
#elif defined(__mips__) && defined(__LP64__)
|
|
|
|
#define OPENSSL_64_BIT
|
|
|
|
#define OPENSSL_MIPS64
|
2014-07-14 23:28:14 +01:00
|
|
|
#elif defined(__pnacl__)
|
|
|
|
#define OPENSSL_32_BIT
|
|
|
|
#define OPENSSL_PNACL
|
2018-03-20 23:12:56 +00:00
|
|
|
#elif defined(__wasm__)
|
|
|
|
#define OPENSSL_32_BIT
|
|
|
|
#elif defined(__asmjs__)
|
|
|
|
#define OPENSSL_32_BIT
|
2016-07-21 23:46:57 +01:00
|
|
|
#elif defined(__myriad2__)
|
|
|
|
#define OPENSSL_32_BIT
|
2014-07-14 23:28:14 +01:00
|
|
|
#else
|
2017-08-19 00:21:50 +01:00
|
|
|
// Note BoringSSL only supports standard 32-bit and 64-bit two's-complement,
|
|
|
|
// little-endian architectures. Functions will not produce the correct answer
|
|
|
|
// on other systems. Run the crypto_test binary, notably
|
|
|
|
// crypto/compiler_test.cc, before adding a new architecture.
|
2014-07-14 23:28:14 +01:00
|
|
|
#error "Unknown target CPU"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__APPLE__)
|
|
|
|
#define OPENSSL_APPLE
|
|
|
|
#endif
|
|
|
|
|
2015-07-31 21:11:31 +01:00
|
|
|
#if defined(_WIN32)
|
2014-07-31 00:02:14 +01:00
|
|
|
#define OPENSSL_WINDOWS
|
|
|
|
#endif
|
|
|
|
|
2016-07-09 13:02:18 +01:00
|
|
|
#if defined(__linux__)
|
|
|
|
#define OPENSSL_LINUX
|
|
|
|
#endif
|
|
|
|
|
2017-01-13 19:49:38 +00:00
|
|
|
#if defined(__Fuchsia__)
|
|
|
|
#define OPENSSL_FUCHSIA
|
|
|
|
#endif
|
|
|
|
|
2015-05-08 02:28:27 +01:00
|
|
|
#if defined(TRUSTY)
|
|
|
|
#define OPENSSL_TRUSTY
|
|
|
|
#define OPENSSL_NO_THREADS
|
|
|
|
#endif
|
|
|
|
|
2016-08-12 19:48:19 +01:00
|
|
|
#if !defined(OPENSSL_NO_THREADS)
|
|
|
|
#define OPENSSL_THREADS
|
|
|
|
#endif
|
|
|
|
|
2014-07-14 23:28:14 +01:00
|
|
|
#define OPENSSL_IS_BORINGSSL
|
2016-08-12 19:48:19 +01:00
|
|
|
#define OPENSSL_VERSION_NUMBER 0x1010007f
|
2015-07-31 23:57:07 +01:00
|
|
|
#define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER
|
2014-07-14 23:28:14 +01:00
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// BORINGSSL_API_VERSION is a positive integer that increments as BoringSSL
|
|
|
|
// changes over time. The value itself is not meaningful. It will be incremented
|
|
|
|
// whenever is convenient to coordinate an API change with consumers. This will
|
|
|
|
// not denote any special point in development.
|
|
|
|
//
|
|
|
|
// A consumer may use this symbol in the preprocessor to temporarily build
|
|
|
|
// against multiple revisions of BoringSSL at the same time. It is not
|
|
|
|
// recommended to do so for longer than is necessary.
|
2018-04-12 23:39:28 +01:00
|
|
|
#define BORINGSSL_API_VERSION 8
|
2016-05-05 23:54:33 +01:00
|
|
|
|
2014-07-31 00:02:14 +01:00
|
|
|
#if defined(BORINGSSL_SHARED_LIBRARY)
|
2014-07-14 23:28:14 +01:00
|
|
|
|
2014-07-31 00:02:14 +01:00
|
|
|
#if defined(OPENSSL_WINDOWS)
|
|
|
|
|
|
|
|
#if defined(BORINGSSL_IMPLEMENTATION)
|
|
|
|
#define OPENSSL_EXPORT __declspec(dllexport)
|
|
|
|
#else
|
|
|
|
#define OPENSSL_EXPORT __declspec(dllimport)
|
|
|
|
#endif
|
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
#else // defined(OPENSSL_WINDOWS)
|
2014-07-31 00:02:14 +01:00
|
|
|
|
|
|
|
#if defined(BORINGSSL_IMPLEMENTATION)
|
|
|
|
#define OPENSSL_EXPORT __attribute__((visibility("default")))
|
|
|
|
#else
|
|
|
|
#define OPENSSL_EXPORT
|
|
|
|
#endif
|
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
#endif // defined(OPENSSL_WINDOWS)
|
2014-07-31 00:02:14 +01:00
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
#else // defined(BORINGSSL_SHARED_LIBRARY)
|
2014-07-31 00:02:14 +01:00
|
|
|
|
|
|
|
#define OPENSSL_EXPORT
|
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
#endif // defined(BORINGSSL_SHARED_LIBRARY)
|
2014-07-14 23:28:14 +01:00
|
|
|
|
2016-01-17 19:30:42 +00:00
|
|
|
|
2017-10-05 20:04:08 +01:00
|
|
|
#if defined(__GNUC__) || defined(__clang__)
|
2017-08-19 00:21:50 +01:00
|
|
|
// MinGW has two different printf implementations. Ensure the format macro
|
|
|
|
// matches the selected implementation. See
|
|
|
|
// https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/.
|
2016-10-10 19:41:44 +01:00
|
|
|
#if defined(__MINGW_PRINTF_FORMAT)
|
2016-01-17 19:30:42 +00:00
|
|
|
#define OPENSSL_PRINTF_FORMAT_FUNC(string_index, first_to_check) \
|
2016-10-10 19:41:44 +01:00
|
|
|
__attribute__( \
|
|
|
|
(__format__(__MINGW_PRINTF_FORMAT, string_index, first_to_check)))
|
|
|
|
#else
|
|
|
|
#define OPENSSL_PRINTF_FORMAT_FUNC(string_index, first_to_check) \
|
|
|
|
__attribute__((__format__(__printf__, string_index, first_to_check)))
|
|
|
|
#endif
|
2016-01-17 19:30:42 +00:00
|
|
|
#else
|
|
|
|
#define OPENSSL_PRINTF_FORMAT_FUNC(string_index, first_to_check)
|
|
|
|
#endif
|
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// OPENSSL_MSVC_PRAGMA emits a pragma on MSVC and nothing on other compilers.
|
2016-06-09 21:48:33 +01:00
|
|
|
#if defined(_MSC_VER)
|
|
|
|
#define OPENSSL_MSVC_PRAGMA(arg) __pragma(arg)
|
|
|
|
#else
|
|
|
|
#define OPENSSL_MSVC_PRAGMA(arg)
|
|
|
|
#endif
|
|
|
|
|
2017-05-24 23:04:18 +01:00
|
|
|
#if defined(__GNUC__) || defined(__clang__)
|
2017-04-15 23:12:55 +01:00
|
|
|
#define OPENSSL_UNUSED __attribute__((unused))
|
|
|
|
#else
|
|
|
|
#define OPENSSL_UNUSED
|
|
|
|
#endif
|
|
|
|
|
2016-11-09 22:57:31 +00:00
|
|
|
#if defined(BORINGSSL_UNSAFE_FUZZER_MODE) && \
|
|
|
|
!defined(BORINGSSL_UNSAFE_DETERMINISTIC_MODE)
|
|
|
|
#define BORINGSSL_UNSAFE_DETERMINISTIC_MODE
|
|
|
|
#endif
|
2016-01-17 19:30:42 +00:00
|
|
|
|
2017-05-08 20:53:15 +01:00
|
|
|
#if defined(__has_feature)
|
|
|
|
#if __has_feature(address_sanitizer)
|
|
|
|
#define OPENSSL_ASAN
|
|
|
|
#endif
|
2017-05-17 21:05:50 +01:00
|
|
|
#if __has_feature(memory_sanitizer)
|
|
|
|
#define OPENSSL_MSAN
|
|
|
|
#endif
|
2017-05-08 20:53:15 +01:00
|
|
|
#endif
|
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
// CRYPTO_THREADID is a dummy value.
|
2015-04-20 16:32:12 +01:00
|
|
|
typedef int CRYPTO_THREADID;
|
|
|
|
|
2014-07-14 23:28:14 +01:00
|
|
|
typedef int ASN1_BOOLEAN;
|
|
|
|
typedef int ASN1_NULL;
|
|
|
|
typedef struct ASN1_ITEM_st ASN1_ITEM;
|
|
|
|
typedef struct asn1_object_st ASN1_OBJECT;
|
|
|
|
typedef struct asn1_pctx_st ASN1_PCTX;
|
|
|
|
typedef struct asn1_string_st ASN1_BIT_STRING;
|
|
|
|
typedef struct asn1_string_st ASN1_BMPSTRING;
|
|
|
|
typedef struct asn1_string_st ASN1_ENUMERATED;
|
|
|
|
typedef struct asn1_string_st ASN1_GENERALIZEDTIME;
|
|
|
|
typedef struct asn1_string_st ASN1_GENERALSTRING;
|
|
|
|
typedef struct asn1_string_st ASN1_IA5STRING;
|
|
|
|
typedef struct asn1_string_st ASN1_INTEGER;
|
|
|
|
typedef struct asn1_string_st ASN1_OCTET_STRING;
|
|
|
|
typedef struct asn1_string_st ASN1_PRINTABLESTRING;
|
|
|
|
typedef struct asn1_string_st ASN1_STRING;
|
|
|
|
typedef struct asn1_string_st ASN1_T61STRING;
|
|
|
|
typedef struct asn1_string_st ASN1_TIME;
|
|
|
|
typedef struct asn1_string_st ASN1_UNIVERSALSTRING;
|
|
|
|
typedef struct asn1_string_st ASN1_UTCTIME;
|
|
|
|
typedef struct asn1_string_st ASN1_UTF8STRING;
|
|
|
|
typedef struct asn1_string_st ASN1_VISIBLESTRING;
|
2016-08-18 04:10:28 +01:00
|
|
|
typedef struct asn1_type_st ASN1_TYPE;
|
2014-07-14 23:28:14 +01:00
|
|
|
typedef struct AUTHORITY_KEYID_st AUTHORITY_KEYID;
|
2016-07-19 20:41:35 +01:00
|
|
|
typedef struct BASIC_CONSTRAINTS_st BASIC_CONSTRAINTS;
|
2014-07-14 23:28:14 +01:00
|
|
|
typedef struct DIST_POINT_st DIST_POINT;
|
2016-07-19 20:41:35 +01:00
|
|
|
typedef struct DSA_SIG_st DSA_SIG;
|
2014-07-14 23:28:14 +01:00
|
|
|
typedef struct ISSUING_DIST_POINT_st ISSUING_DIST_POINT;
|
|
|
|
typedef struct NAME_CONSTRAINTS_st NAME_CONSTRAINTS;
|
2015-08-03 22:14:14 +01:00
|
|
|
typedef struct Netscape_spkac_st NETSCAPE_SPKAC;
|
|
|
|
typedef struct Netscape_spki_st NETSCAPE_SPKI;
|
2016-03-08 22:17:02 +00:00
|
|
|
typedef struct RIPEMD160state_st RIPEMD160_CTX;
|
2014-07-14 23:28:14 +01:00
|
|
|
typedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE;
|
|
|
|
typedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL;
|
|
|
|
typedef struct X509_POLICY_NODE_st X509_POLICY_NODE;
|
|
|
|
typedef struct X509_POLICY_TREE_st X509_POLICY_TREE;
|
2016-07-19 20:41:35 +01:00
|
|
|
typedef struct X509_VERIFY_PARAM_st X509_VERIFY_PARAM;
|
2014-07-14 23:28:14 +01:00
|
|
|
typedef struct X509_algor_st X509_ALGOR;
|
2015-08-03 22:14:14 +01:00
|
|
|
typedef struct X509_crl_info_st X509_CRL_INFO;
|
2014-07-14 23:28:14 +01:00
|
|
|
typedef struct X509_crl_st X509_CRL;
|
2015-08-03 22:14:14 +01:00
|
|
|
typedef struct X509_extension_st X509_EXTENSION;
|
|
|
|
typedef struct X509_info_st X509_INFO;
|
|
|
|
typedef struct X509_name_entry_st X509_NAME_ENTRY;
|
|
|
|
typedef struct X509_name_st X509_NAME;
|
2014-07-14 23:28:14 +01:00
|
|
|
typedef struct X509_pubkey_st X509_PUBKEY;
|
2015-08-03 22:14:14 +01:00
|
|
|
typedef struct X509_req_info_st X509_REQ_INFO;
|
|
|
|
typedef struct X509_req_st X509_REQ;
|
|
|
|
typedef struct X509_sig_st X509_SIG;
|
|
|
|
typedef struct X509_val_st X509_VAL;
|
2014-07-14 23:28:14 +01:00
|
|
|
typedef struct bignum_ctx BN_CTX;
|
|
|
|
typedef struct bignum_st BIGNUM;
|
|
|
|
typedef struct bio_method_st BIO_METHOD;
|
|
|
|
typedef struct bio_st BIO;
|
|
|
|
typedef struct bn_gencb_st BN_GENCB;
|
|
|
|
typedef struct bn_mont_ctx_st BN_MONT_CTX;
|
|
|
|
typedef struct buf_mem_st BUF_MEM;
|
|
|
|
typedef struct cbb_st CBB;
|
|
|
|
typedef struct cbs_st CBS;
|
2015-05-06 00:36:32 +01:00
|
|
|
typedef struct cmac_ctx_st CMAC_CTX;
|
2014-07-14 23:28:14 +01:00
|
|
|
typedef struct conf_st CONF;
|
2015-03-28 07:12:01 +00:00
|
|
|
typedef struct conf_value_st CONF_VALUE;
|
2016-10-26 01:33:49 +01:00
|
|
|
typedef struct crypto_buffer_pool_st CRYPTO_BUFFER_POOL;
|
|
|
|
typedef struct crypto_buffer_st CRYPTO_BUFFER;
|
2014-07-14 23:28:14 +01:00
|
|
|
typedef struct dh_st DH;
|
|
|
|
typedef struct dsa_st DSA;
|
2016-07-19 20:41:35 +01:00
|
|
|
typedef struct ec_group_st EC_GROUP;
|
2014-07-14 23:28:14 +01:00
|
|
|
typedef struct ec_key_st EC_KEY;
|
2016-07-19 20:41:35 +01:00
|
|
|
typedef struct ec_point_st EC_POINT;
|
2014-07-14 23:28:14 +01:00
|
|
|
typedef struct ecdsa_method_st ECDSA_METHOD;
|
|
|
|
typedef struct ecdsa_sig_st ECDSA_SIG;
|
|
|
|
typedef struct engine_st ENGINE;
|
|
|
|
typedef struct env_md_ctx_st EVP_MD_CTX;
|
|
|
|
typedef struct env_md_st EVP_MD;
|
|
|
|
typedef struct evp_aead_st EVP_AEAD;
|
|
|
|
typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX;
|
|
|
|
typedef struct evp_cipher_st EVP_CIPHER;
|
2015-09-19 20:17:34 +01:00
|
|
|
typedef struct evp_encode_ctx_st EVP_ENCODE_CTX;
|
2014-07-14 23:28:14 +01:00
|
|
|
typedef struct evp_pkey_asn1_method_st EVP_PKEY_ASN1_METHOD;
|
|
|
|
typedef struct evp_pkey_ctx_st EVP_PKEY_CTX;
|
|
|
|
typedef struct evp_pkey_method_st EVP_PKEY_METHOD;
|
|
|
|
typedef struct evp_pkey_st EVP_PKEY;
|
|
|
|
typedef struct hmac_ctx_st HMAC_CTX;
|
2014-08-22 19:06:14 +01:00
|
|
|
typedef struct md4_state_st MD4_CTX;
|
2014-07-14 23:28:14 +01:00
|
|
|
typedef struct md5_state_st MD5_CTX;
|
2016-08-12 19:48:19 +01:00
|
|
|
typedef struct ossl_init_settings_st OPENSSL_INIT_SETTINGS;
|
2014-09-19 18:49:56 +01:00
|
|
|
typedef struct pkcs12_st PKCS12;
|
2015-08-03 22:14:14 +01:00
|
|
|
typedef struct pkcs8_priv_key_info_st PKCS8_PRIV_KEY_INFO;
|
|
|
|
typedef struct private_key_st X509_PKEY;
|
2014-07-14 23:28:14 +01:00
|
|
|
typedef struct rand_meth_st RAND_METHOD;
|
2015-02-20 23:32:52 +00:00
|
|
|
typedef struct rc4_key_st RC4_KEY;
|
2014-07-14 23:28:14 +01:00
|
|
|
typedef struct rsa_meth_st RSA_METHOD;
|
|
|
|
typedef struct rsa_st RSA;
|
|
|
|
typedef struct sha256_state_st SHA256_CTX;
|
|
|
|
typedef struct sha512_state_st SHA512_CTX;
|
|
|
|
typedef struct sha_state_st SHA_CTX;
|
2016-02-10 02:09:00 +00:00
|
|
|
typedef struct spake2_ctx_st SPAKE2_CTX;
|
2015-09-14 06:54:44 +01:00
|
|
|
typedef struct srtp_protection_profile_st SRTP_PROTECTION_PROFILE;
|
2015-09-13 18:53:19 +01:00
|
|
|
typedef struct ssl_cipher_st SSL_CIPHER;
|
2014-07-14 23:28:14 +01:00
|
|
|
typedef struct ssl_ctx_st SSL_CTX;
|
2017-07-20 17:22:21 +01:00
|
|
|
typedef struct ssl_method_st SSL_METHOD;
|
2017-02-28 19:26:51 +00:00
|
|
|
typedef struct ssl_private_key_method_st SSL_PRIVATE_KEY_METHOD;
|
2015-09-13 19:07:33 +01:00
|
|
|
typedef struct ssl_session_st SSL_SESSION;
|
2017-07-20 17:22:21 +01:00
|
|
|
typedef struct ssl_st SSL;
|
2017-03-09 03:33:21 +00:00
|
|
|
typedef struct ssl_ticket_aead_method_st SSL_TICKET_AEAD_METHOD;
|
2014-07-14 23:28:14 +01:00
|
|
|
typedef struct st_ERR_FNS ERR_FNS;
|
|
|
|
typedef struct v3_ext_ctx X509V3_CTX;
|
2015-08-03 22:14:14 +01:00
|
|
|
typedef struct x509_attributes_st X509_ATTRIBUTE;
|
|
|
|
typedef struct x509_cert_aux_st X509_CERT_AUX;
|
|
|
|
typedef struct x509_cinf_st X509_CINF;
|
2014-07-14 23:28:14 +01:00
|
|
|
typedef struct x509_crl_method_st X509_CRL_METHOD;
|
2016-08-18 04:10:28 +01:00
|
|
|
typedef struct x509_lookup_st X509_LOOKUP;
|
2014-07-14 23:28:14 +01:00
|
|
|
typedef struct x509_revoked_st X509_REVOKED;
|
|
|
|
typedef struct x509_st X509;
|
|
|
|
typedef struct x509_store_ctx_st X509_STORE_CTX;
|
|
|
|
typedef struct x509_store_st X509_STORE;
|
2015-08-03 22:14:14 +01:00
|
|
|
typedef struct x509_trust_st X509_TRUST;
|
|
|
|
|
2014-07-14 23:28:14 +01:00
|
|
|
typedef void *OPENSSL_BLOCK;
|
|
|
|
|
|
|
|
|
2014-09-02 22:28:49 +01:00
|
|
|
#if defined(__cplusplus)
|
2017-08-19 00:21:50 +01:00
|
|
|
} // extern C
|
2017-07-20 17:50:11 +01:00
|
|
|
#elif !defined(BORINGSSL_NO_CXX)
|
|
|
|
#define BORINGSSL_NO_CXX
|
|
|
|
#endif
|
2016-08-18 04:10:28 +01:00
|
|
|
|
|
|
|
// MSVC doesn't set __cplusplus to 201103 to indicate C++11 support (see
|
|
|
|
// https://connect.microsoft.com/VisualStudio/feedback/details/763051/a-value-of-predefined-macro-cplusplus-is-still-199711l)
|
|
|
|
// so MSVC is just assumed to support C++11.
|
2016-09-06 23:10:19 +01:00
|
|
|
#if !defined(BORINGSSL_NO_CXX) && __cplusplus < 201103L && !defined(_MSC_VER)
|
|
|
|
#define BORINGSSL_NO_CXX
|
|
|
|
#endif
|
|
|
|
|
2016-09-07 22:28:59 +01:00
|
|
|
#if !defined(BORINGSSL_NO_CXX)
|
|
|
|
extern "C++" {
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
// STLPort, used by some Android consumers, not have std::unique_ptr.
|
|
|
|
#if defined(_STLPORT_VERSION)
|
|
|
|
#define BORINGSSL_NO_CXX
|
|
|
|
#endif
|
|
|
|
|
|
|
|
} // extern C++
|
|
|
|
#endif // !BORINGSSL_NO_CXX
|
|
|
|
|
2016-09-06 23:10:19 +01:00
|
|
|
#if defined(BORINGSSL_NO_CXX)
|
2016-08-18 04:10:28 +01:00
|
|
|
|
|
|
|
#define BORINGSSL_MAKE_DELETER(type, deleter)
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2016-09-06 23:10:19 +01:00
|
|
|
extern "C++" {
|
|
|
|
|
2016-08-18 04:10:28 +01:00
|
|
|
namespace bssl {
|
|
|
|
|
|
|
|
namespace internal {
|
|
|
|
|
2017-07-19 03:45:18 +01:00
|
|
|
// The Enable parameter is ignored and only exists so specializations can use
|
|
|
|
// SFINAE.
|
|
|
|
template <typename T, typename Enable = void>
|
2016-09-09 19:54:10 +01:00
|
|
|
struct DeleterImpl {};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct Deleter {
|
|
|
|
void operator()(T *ptr) {
|
|
|
|
// Rather than specialize Deleter for each type, we specialize
|
|
|
|
// DeleterImpl. This allows bssl::UniquePtr<T> to be used while only
|
|
|
|
// including base.h as long as the destructor is not emitted. This matches
|
|
|
|
// std::unique_ptr's behavior on forward-declared types.
|
|
|
|
//
|
|
|
|
// DeleterImpl itself is specialized in the corresponding module's header
|
|
|
|
// and must be included to release an object. If not included, the compiler
|
|
|
|
// will error that DeleterImpl<T> does not have a method Free.
|
|
|
|
DeleterImpl<T>::Free(ptr);
|
|
|
|
}
|
|
|
|
};
|
2016-08-18 04:10:28 +01:00
|
|
|
|
2016-09-06 23:10:19 +01:00
|
|
|
template <typename T, typename CleanupRet, void (*init)(T *),
|
|
|
|
CleanupRet (*cleanup)(T *)>
|
|
|
|
class StackAllocated {
|
|
|
|
public:
|
|
|
|
StackAllocated() { init(&ctx_); }
|
|
|
|
~StackAllocated() { cleanup(&ctx_); }
|
|
|
|
|
2016-09-27 21:25:32 +01:00
|
|
|
StackAllocated(const StackAllocated<T, CleanupRet, init, cleanup> &) = delete;
|
|
|
|
T& operator=(const StackAllocated<T, CleanupRet, init, cleanup> &) = delete;
|
|
|
|
|
2016-09-06 23:10:19 +01:00
|
|
|
T *get() { return &ctx_; }
|
|
|
|
const T *get() const { return &ctx_; }
|
|
|
|
|
2017-08-02 22:16:31 +01:00
|
|
|
T *operator->() { return &ctx_; }
|
|
|
|
const T *operator->() const { return &ctx_; }
|
|
|
|
|
2016-09-06 23:10:19 +01:00
|
|
|
void Reset() {
|
|
|
|
cleanup(&ctx_);
|
|
|
|
init(&ctx_);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
T ctx_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
|
2016-09-09 19:54:10 +01:00
|
|
|
#define BORINGSSL_MAKE_DELETER(type, deleter) \
|
|
|
|
namespace internal { \
|
|
|
|
template <> \
|
|
|
|
struct DeleterImpl<type> { \
|
|
|
|
static void Free(type *ptr) { deleter(ptr); } \
|
|
|
|
}; \
|
2016-09-06 23:10:19 +01:00
|
|
|
}
|
2016-08-18 04:10:28 +01:00
|
|
|
|
|
|
|
// Holds ownership of heap-allocated BoringSSL structures. Sample usage:
|
2017-05-02 14:54:05 +01:00
|
|
|
// bssl::UniquePtr<RSA> rsa(RSA_new());
|
2016-08-18 04:10:28 +01:00
|
|
|
// bssl::UniquePtr<BIO> bio(BIO_new(BIO_s_mem()));
|
|
|
|
template <typename T>
|
|
|
|
using UniquePtr = std::unique_ptr<T, internal::Deleter<T>>;
|
|
|
|
|
|
|
|
} // namespace bssl
|
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
} // extern C++
|
2016-08-18 04:10:28 +01:00
|
|
|
|
2016-09-06 23:10:19 +01:00
|
|
|
#endif // !BORINGSSL_NO_CXX
|
|
|
|
|
2017-08-19 00:21:50 +01:00
|
|
|
#endif // OPENSSL_HEADER_BASE_H
|