Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Langley <agl@google.com>2016-07-12 01:22:19 +0300
committerAdam Langley <agl@google.com>2016-07-12 02:08:27 +0300
commit8c3c3135a29ed91e4ed73498a8cbb76af68c4c38 (patch)
treef492a15aed3b9051b8cf085b21c3d92e7a769728
parent09feb0f3d95a2bc58ce0faaf14256d3bd30f52a4 (diff)
Remove scoped_types.h.
This change scatters the contents of the two scoped_types.h files into the headers for each of the areas of the code. The types are now in the |bssl| namespace. Change-Id: I802b8de68fba4786b6a0ac1bacd11d81d5842423 Reviewed-on: https://boringssl-review.googlesource.com/8731 Reviewed-by: Adam Langley <agl@google.com>
-rw-r--r--crypto/asn1/asn1_test.cc2
-rw-r--r--crypto/bio/bio_test.cc2
-rw-r--r--crypto/bn/bn_test.cc2
-rw-r--r--crypto/bytestring/bytestring_test.cc1
-rw-r--r--crypto/cipher/aead_test.cc1
-rw-r--r--crypto/cipher/cipher_test.cc1
-rw-r--r--crypto/cmac/cmac_test.cc3
-rw-r--r--crypto/curve25519/spake25519_test.cc1
-rw-r--r--crypto/dh/dh_test.cc1
-rw-r--r--crypto/digest/digest_test.cc2
-rw-r--r--crypto/ec/ec_test.cc4
-rw-r--r--crypto/ecdsa/ecdsa_test.cc2
-rw-r--r--crypto/evp/evp_extra_test.cc3
-rw-r--r--crypto/evp/evp_test.cc1
-rw-r--r--crypto/hmac/hmac_test.cc1
-rw-r--r--crypto/newhope/newhope_statistical_test.cc1
-rw-r--r--crypto/newhope/newhope_test.cc1
-rw-r--r--crypto/newhope/newhope_vectors_test.cc1
-rw-r--r--crypto/pkcs8/pkcs12_test.cc2
-rw-r--r--crypto/pkcs8/pkcs8_test.cc2
-rw-r--r--crypto/rsa/rsa_test.cc2
-rw-r--r--crypto/test/scoped_types.h97
-rw-r--r--crypto/x509/x509_test.cc2
-rw-r--r--include/openssl/aead.h12
-rw-r--r--include/openssl/asn1.h11
-rw-r--r--include/openssl/base.h5
-rw-r--r--include/openssl/bio.h11
-rw-r--r--include/openssl/bn.h13
-rw-r--r--include/openssl/bytestring.h11
-rw-r--r--include/openssl/cipher.h13
-rw-r--r--include/openssl/cmac.h11
-rw-r--r--include/openssl/curve25519.h11
-rw-r--r--include/openssl/dh.h11
-rw-r--r--include/openssl/digest.h12
-rw-r--r--include/openssl/ec.h12
-rw-r--r--include/openssl/ec_key.h11
-rw-r--r--include/openssl/ecdsa.h11
-rw-r--r--include/openssl/evp.h12
-rw-r--r--include/openssl/hmac.h12
-rw-r--r--include/openssl/mem.h7
-rw-r--r--include/openssl/newhope.h11
-rw-r--r--include/openssl/pkcs8.h13
-rw-r--r--include/openssl/rsa.h11
-rw-r--r--include/openssl/ssl.h13
-rw-r--r--include/openssl/stack.h5
-rw-r--r--include/openssl/x509.h16
-rw-r--r--ssl/ssl_test.cc1
-rw-r--r--ssl/test/async_bio.h2
-rw-r--r--ssl/test/bssl_shim.cc2
-rw-r--r--ssl/test/packeted_bio.h2
-rw-r--r--ssl/test/scoped_types.h32
-rw-r--r--tool/ciphers.cc2
-rw-r--r--tool/client.cc2
-rw-r--r--tool/generate_ed25519.cc9
-rw-r--r--tool/genrsa.cc1
-rw-r--r--tool/speed.cc4
-rw-r--r--util/BUILD5
57 files changed, 273 insertions, 179 deletions
diff --git a/crypto/asn1/asn1_test.cc b/crypto/asn1/asn1_test.cc
index e3e310bd..86dd02a5 100644
--- a/crypto/asn1/asn1_test.cc
+++ b/crypto/asn1/asn1_test.cc
@@ -18,8 +18,6 @@
#include <openssl/crypto.h>
#include <openssl/err.h>
-#include "../test/scoped_types.h"
-
namespace bssl {
diff --git a/crypto/bio/bio_test.cc b/crypto/bio/bio_test.cc
index e7c061eb..cd56e620 100644
--- a/crypto/bio/bio_test.cc
+++ b/crypto/bio/bio_test.cc
@@ -40,8 +40,6 @@ OPENSSL_MSVC_PRAGMA(warning(pop))
#include <algorithm>
-#include "../test/scoped_types.h"
-
namespace bssl {
diff --git a/crypto/bn/bn_test.cc b/crypto/bn/bn_test.cc
index 3028745c..67ab9242 100644
--- a/crypto/bn/bn_test.cc
+++ b/crypto/bn/bn_test.cc
@@ -81,12 +81,12 @@
#include <utility>
#include <openssl/bn.h>
+#include <openssl/bytestring.h>
#include <openssl/crypto.h>
#include <openssl/err.h>
#include <openssl/mem.h>
#include "../crypto/test/file_test.h"
-#include "../crypto/test/scoped_types.h"
#include "../crypto/test/test_util.h"
diff --git a/crypto/bytestring/bytestring_test.cc b/crypto/bytestring/bytestring_test.cc
index 95d9b85c..39ac0aed 100644
--- a/crypto/bytestring/bytestring_test.cc
+++ b/crypto/bytestring/bytestring_test.cc
@@ -26,7 +26,6 @@
#include <openssl/bytestring.h>
#include "internal.h"
-#include "../test/scoped_types.h"
namespace bssl {
diff --git a/crypto/cipher/aead_test.cc b/crypto/cipher/aead_test.cc
index cf0f24a6..70b84ab4 100644
--- a/crypto/cipher/aead_test.cc
+++ b/crypto/cipher/aead_test.cc
@@ -22,7 +22,6 @@
#include <openssl/err.h>
#include "../test/file_test.h"
-#include "../test/scoped_types.h"
namespace bssl {
diff --git a/crypto/cipher/cipher_test.cc b/crypto/cipher/cipher_test.cc
index 221eb67e..beaef2cd 100644
--- a/crypto/cipher/cipher_test.cc
+++ b/crypto/cipher/cipher_test.cc
@@ -62,7 +62,6 @@
#include <openssl/err.h>
#include "../test/file_test.h"
-#include "../test/scoped_types.h"
namespace bssl {
diff --git a/crypto/cmac/cmac_test.cc b/crypto/cmac/cmac_test.cc
index 11b7ad69..7b421293 100644
--- a/crypto/cmac/cmac_test.cc
+++ b/crypto/cmac/cmac_test.cc
@@ -17,8 +17,9 @@
#include <algorithm>
#include <openssl/cmac.h>
+#include <openssl/evp.h>
+#include <openssl/mem.h>
-#include "../test/scoped_types.h"
#include "../test/test_util.h"
diff --git a/crypto/curve25519/spake25519_test.cc b/crypto/curve25519/spake25519_test.cc
index b8742ed9..ee7e0fb4 100644
--- a/crypto/curve25519/spake25519_test.cc
+++ b/crypto/curve25519/spake25519_test.cc
@@ -19,7 +19,6 @@
#include <string.h>
#include <openssl/curve25519.h>
-#include "../test/scoped_types.h"
namespace bssl {
diff --git a/crypto/dh/dh_test.cc b/crypto/dh/dh_test.cc
index 8fe496c9..9cf76f6c 100644
--- a/crypto/dh/dh_test.cc
+++ b/crypto/dh/dh_test.cc
@@ -68,7 +68,6 @@
#include <openssl/mem.h>
#include "internal.h"
-#include "../test/scoped_types.h"
namespace bssl {
diff --git a/crypto/digest/digest_test.cc b/crypto/digest/digest_test.cc
index 32d12d24..c3909139 100644
--- a/crypto/digest/digest_test.cc
+++ b/crypto/digest/digest_test.cc
@@ -23,8 +23,6 @@
#include <openssl/md5.h>
#include <openssl/sha.h>
-#include "../test/scoped_types.h"
-
namespace bssl {
diff --git a/crypto/ec/ec_test.cc b/crypto/ec/ec_test.cc
index 864cd499..75724347 100644
--- a/crypto/ec/ec_test.cc
+++ b/crypto/ec/ec_test.cc
@@ -17,13 +17,13 @@
#include <vector>
+#include <openssl/bn.h>
#include <openssl/bytestring.h>
#include <openssl/crypto.h>
#include <openssl/ec_key.h>
#include <openssl/err.h>
#include <openssl/mem.h>
-
-#include "../test/scoped_types.h"
+#include <openssl/obj.h>
namespace bssl {
diff --git a/crypto/ecdsa/ecdsa_test.cc b/crypto/ecdsa/ecdsa_test.cc
index ad2325b6..6b42d4e3 100644
--- a/crypto/ecdsa/ecdsa_test.cc
+++ b/crypto/ecdsa/ecdsa_test.cc
@@ -62,8 +62,6 @@
#include <openssl/nid.h>
#include <openssl/rand.h>
-#include "../test/scoped_types.h"
-
namespace bssl {
diff --git a/crypto/evp/evp_extra_test.cc b/crypto/evp/evp_extra_test.cc
index 2253c56b..750da755 100644
--- a/crypto/evp/evp_extra_test.cc
+++ b/crypto/evp/evp_extra_test.cc
@@ -25,10 +25,9 @@
#include <openssl/digest.h>
#include <openssl/err.h>
#include <openssl/evp.h>
+#include <openssl/pkcs8.h>
#include <openssl/rsa.h>
-#include "../test/scoped_types.h"
-
namespace bssl {
diff --git a/crypto/evp/evp_test.cc b/crypto/evp/evp_test.cc
index 9b8a6839..a20c6a60 100644
--- a/crypto/evp/evp_test.cc
+++ b/crypto/evp/evp_test.cc
@@ -74,7 +74,6 @@ OPENSSL_MSVC_PRAGMA(warning(pop))
#include <openssl/err.h>
#include "../test/file_test.h"
-#include "../test/scoped_types.h"
namespace bssl {
diff --git a/crypto/hmac/hmac_test.cc b/crypto/hmac/hmac_test.cc
index ba84cc22..9f764951 100644
--- a/crypto/hmac/hmac_test.cc
+++ b/crypto/hmac/hmac_test.cc
@@ -65,7 +65,6 @@
#include <openssl/hmac.h>
#include "../test/file_test.h"
-#include "../test/scoped_types.h"
namespace bssl {
diff --git a/crypto/newhope/newhope_statistical_test.cc b/crypto/newhope/newhope_statistical_test.cc
index d3a54430..1344506b 100644
--- a/crypto/newhope/newhope_statistical_test.cc
+++ b/crypto/newhope/newhope_statistical_test.cc
@@ -21,7 +21,6 @@
#include <openssl/crypto.h>
#include <openssl/rand.h>
-#include "../test/scoped_types.h"
#include "internal.h"
diff --git a/crypto/newhope/newhope_test.cc b/crypto/newhope/newhope_test.cc
index d94eee8f..c127d4fb 100644
--- a/crypto/newhope/newhope_test.cc
+++ b/crypto/newhope/newhope_test.cc
@@ -19,7 +19,6 @@
#include <openssl/crypto.h>
#include <openssl/rand.h>
-#include "../test/scoped_types.h"
#include "internal.h"
diff --git a/crypto/newhope/newhope_vectors_test.cc b/crypto/newhope/newhope_vectors_test.cc
index 691d693b..a3398faa 100644
--- a/crypto/newhope/newhope_vectors_test.cc
+++ b/crypto/newhope/newhope_vectors_test.cc
@@ -20,7 +20,6 @@
#include <openssl/rand.h>
#include "../test/file_test.h"
-#include "../test/scoped_types.h"
#include "internal.h"
diff --git a/crypto/pkcs8/pkcs12_test.cc b/crypto/pkcs8/pkcs12_test.cc
index 10694446..2c4adc48 100644
--- a/crypto/pkcs8/pkcs12_test.cc
+++ b/crypto/pkcs8/pkcs12_test.cc
@@ -23,8 +23,6 @@
#include <openssl/stack.h>
#include <openssl/x509.h>
-#include "../test/scoped_types.h"
-
/* kPKCS12DER contains sample PKCS#12 data generated by OpenSSL with:
* openssl pkcs12 -export -inkey key.pem -in cacert.pem */
diff --git a/crypto/pkcs8/pkcs8_test.cc b/crypto/pkcs8/pkcs8_test.cc
index e54a6997..b58461f7 100644
--- a/crypto/pkcs8/pkcs8_test.cc
+++ b/crypto/pkcs8/pkcs8_test.cc
@@ -21,8 +21,6 @@
#include <openssl/pkcs8.h>
#include <openssl/x509.h>
-#include "../test/scoped_types.h"
-
/* kDER is a PKCS#8 encrypted private key. It was generated with:
*
diff --git a/crypto/rsa/rsa_test.cc b/crypto/rsa/rsa_test.cc
index 5307f2cb..698eb92c 100644
--- a/crypto/rsa/rsa_test.cc
+++ b/crypto/rsa/rsa_test.cc
@@ -65,8 +65,6 @@
#include <openssl/err.h>
#include <openssl/nid.h>
-#include "../test/scoped_types.h"
-
// kPlaintext is a sample plaintext.
static const uint8_t kPlaintext[] = "\x54\x85\x9b\x34\x2c\x49\xea\x2a";
diff --git a/crypto/test/scoped_types.h b/crypto/test/scoped_types.h
deleted file mode 100644
index 7e4a48e8..00000000
--- a/crypto/test/scoped_types.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* Copyright (c) 2015, Google Inc.
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
-
-#ifndef OPENSSL_HEADER_CRYPTO_TEST_SCOPED_TYPES_H
-#define OPENSSL_HEADER_CRYPTO_TEST_SCOPED_TYPES_H
-
-#include <openssl/base.h>
-
-#include <stdint.h>
-#include <stdio.h>
-
-#include <memory>
-
-#include <openssl/aead.h>
-#include <openssl/asn1.h>
-#include <openssl/bio.h>
-#include <openssl/bn.h>
-#include <openssl/bytestring.h>
-#include <openssl/cmac.h>
-#include <openssl/curve25519.h>
-#include <openssl/dh.h>
-#include <openssl/ecdsa.h>
-#include <openssl/ec.h>
-#include <openssl/ec_key.h>
-#include <openssl/evp.h>
-#include <openssl/hmac.h>
-#include <openssl/mem.h>
-#include <openssl/newhope.h>
-#include <openssl/pkcs8.h>
-#include <openssl/rsa.h>
-#include <openssl/stack.h>
-#include <openssl/x509.h>
-
-namespace bssl {
-
-struct FileCloser {
- void operator()(FILE *file) {
- fclose(file);
- }
-};
-
-using ScopedASN1_TYPE = ScopedType<ASN1_TYPE, ASN1_TYPE_free>;
-using ScopedBIO = ScopedType<BIO, BIO_vfree>;
-using ScopedBIGNUM = ScopedType<BIGNUM, BN_free>;
-using ScopedBN_CTX = ScopedType<BN_CTX, BN_CTX_free>;
-using ScopedBN_MONT_CTX = ScopedType<BN_MONT_CTX, BN_MONT_CTX_free>;
-using ScopedCMAC_CTX = ScopedType<CMAC_CTX, CMAC_CTX_free>;
-using ScopedDH = ScopedType<DH, DH_free>;
-using ScopedECDSA_SIG = ScopedType<ECDSA_SIG, ECDSA_SIG_free>;
-using ScopedEC_GROUP = ScopedType<EC_GROUP, EC_GROUP_free>;
-using ScopedEC_KEY = ScopedType<EC_KEY, EC_KEY_free>;
-using ScopedEC_POINT = ScopedType<EC_POINT, EC_POINT_free>;
-using ScopedEVP_PKEY = ScopedType<EVP_PKEY, EVP_PKEY_free>;
-using ScopedEVP_PKEY_CTX = ScopedType<EVP_PKEY_CTX, EVP_PKEY_CTX_free>;
-using ScopedNEWHOPE_POLY = ScopedType<NEWHOPE_POLY, NEWHOPE_POLY_free>;
-using ScopedPKCS8_PRIV_KEY_INFO =
- ScopedType<PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO_free>;
-using ScopedPKCS12 = ScopedType<PKCS12, PKCS12_free>;
-using ScopedSPAKE2_CTX = ScopedType<SPAKE2_CTX, SPAKE2_CTX_free>;
-using ScopedRSA = ScopedType<RSA, RSA_free>;
-using ScopedX509 = ScopedType<X509, X509_free>;
-using ScopedX509_ALGOR = ScopedType<X509_ALGOR, X509_ALGOR_free>;
-using ScopedX509_SIG = ScopedType<X509_SIG, X509_SIG_free>;
-using ScopedX509_STORE_CTX = ScopedType<X509_STORE_CTX, X509_STORE_CTX_free>;
-
-using ScopedX509Stack = ScopedStack<STACK_OF(X509), X509, X509_free>;
-
-using ScopedCBB = ScopedContext<CBB, void, CBB_zero, CBB_cleanup>;
-using ScopedEVP_AEAD_CTX =
- ScopedContext<EVP_AEAD_CTX, void, EVP_AEAD_CTX_zero, EVP_AEAD_CTX_cleanup>;
-using ScopedEVP_CIPHER_CTX =
- ScopedContext<EVP_CIPHER_CTX, int, EVP_CIPHER_CTX_init,
- EVP_CIPHER_CTX_cleanup>;
-using ScopedEVP_MD_CTX =
- ScopedContext<EVP_MD_CTX, int, EVP_MD_CTX_init, EVP_MD_CTX_cleanup>;
-using ScopedHMAC_CTX =
- ScopedContext<HMAC_CTX, void, HMAC_CTX_init, HMAC_CTX_cleanup>;
-
-using ScopedBytes = std::unique_ptr<uint8_t, Free<uint8_t>>;
-using ScopedString = std::unique_ptr<char, Free<char>>;
-
-using ScopedFILE = std::unique_ptr<FILE, FileCloser>;
-
-} // namespace bssl
-
-#endif // OPENSSL_HEADER_CRYPTO_TEST_SCOPED_TYPES_H
diff --git a/crypto/x509/x509_test.cc b/crypto/x509/x509_test.cc
index cb28df70..41221ce3 100644
--- a/crypto/x509/x509_test.cc
+++ b/crypto/x509/x509_test.cc
@@ -24,8 +24,6 @@
#include <openssl/pem.h>
#include <openssl/x509.h>
-#include "../test/scoped_types.h"
-
namespace bssl {
diff --git a/include/openssl/aead.h b/include/openssl/aead.h
index 7895825c..2a9ce90a 100644
--- a/include/openssl/aead.h
+++ b/include/openssl/aead.h
@@ -333,6 +333,18 @@ OPENSSL_EXPORT int EVP_AEAD_CTX_get_iv(const EVP_AEAD_CTX *ctx,
#if defined(__cplusplus)
} /* extern C */
+
+#if __cplusplus >= 201103
+
+namespace bssl {
+
+using ScopedEVP_AEAD_CTX =
+ ScopedContext<EVP_AEAD_CTX, void, EVP_AEAD_CTX_zero, EVP_AEAD_CTX_cleanup>;
+
+} // namespace bssl
+
+#endif
+
#endif
#endif /* OPENSSL_HEADER_AEAD_H */
diff --git a/include/openssl/asn1.h b/include/openssl/asn1.h
index 42c95351..4756de8c 100644
--- a/include/openssl/asn1.h
+++ b/include/openssl/asn1.h
@@ -1016,6 +1016,17 @@ OPENSSL_EXPORT ASN1_TYPE *ASN1_generate_v3(char *str, X509V3_CTX *cnf);
#ifdef __cplusplus
}
+
+#if __cplusplus >= 201103
+
+namespace bssl {
+
+using ScopedASN1_TYPE = ScopedType<ASN1_TYPE, ASN1_TYPE_free>;
+
+} // namespace bssl
+
+#endif
+
#endif
#define ASN1_R_ASN1_LENGTH_MISMATCH 100
diff --git a/include/openssl/base.h b/include/openssl/base.h
index 68df1078..7fdaed43 100644
--- a/include/openssl/base.h
+++ b/include/openssl/base.h
@@ -293,6 +293,9 @@ typedef void *OPENSSL_BLOCK;
#if defined(__cplusplus)
} /* extern C */
+
+#if __cplusplus >= 201103
+
namespace bssl {
template<typename T, void (*func)(T*)>
@@ -332,4 +335,6 @@ class ScopedContext {
#endif
+#endif
+
#endif /* OPENSSL_HEADER_BASE_H */
diff --git a/include/openssl/bio.h b/include/openssl/bio.h
index 5416c657..75449bdd 100644
--- a/include/openssl/bio.h
+++ b/include/openssl/bio.h
@@ -895,6 +895,17 @@ struct bio_st {
#if defined(__cplusplus)
} /* extern C */
+
+#if __cplusplus >= 201103
+
+namespace bssl {
+
+using ScopedBIO = ScopedType<BIO, BIO_vfree>;
+
+} // namespace bssl
+
+#endif
+
#endif
#define BIO_R_BAD_FOPEN_MODE 100
diff --git a/include/openssl/bn.h b/include/openssl/bn.h
index a6866964..9764140c 100644
--- a/include/openssl/bn.h
+++ b/include/openssl/bn.h
@@ -866,6 +866,19 @@ OPENSSL_EXPORT unsigned BN_num_bits_word(BN_ULONG l);
#if defined(__cplusplus)
} /* extern C */
+
+#if __cplusplus >= 201103
+
+namespace bssl {
+
+using ScopedBIGNUM = ScopedType<BIGNUM, BN_free>;
+using ScopedBN_CTX = ScopedType<BN_CTX, BN_CTX_free>;
+using ScopedBN_MONT_CTX = ScopedType<BN_MONT_CTX, BN_MONT_CTX_free>;
+
+} // namespace bssl
+
+#endif
+
#endif
#define BN_R_ARG2_LT_ARG3 100
diff --git a/include/openssl/bytestring.h b/include/openssl/bytestring.h
index c24281a5..7352411f 100644
--- a/include/openssl/bytestring.h
+++ b/include/openssl/bytestring.h
@@ -393,6 +393,17 @@ OPENSSL_EXPORT int CBB_add_asn1_uint64(CBB *cbb, uint64_t value);
#if defined(__cplusplus)
} /* extern C */
+
+#if __cplusplus >= 201103
+
+namespace bssl {
+
+using ScopedCBB = ScopedContext<CBB, void, CBB_zero, CBB_cleanup>;
+
+} // namespace bssl
+
+#endif
+
#endif
#endif /* OPENSSL_HEADER_BYTESTRING_H */
diff --git a/include/openssl/cipher.h b/include/openssl/cipher.h
index 53123086..ecab121b 100644
--- a/include/openssl/cipher.h
+++ b/include/openssl/cipher.h
@@ -540,6 +540,19 @@ struct evp_cipher_st {
#if defined(__cplusplus)
} /* extern C */
+
+#if __cplusplus >= 201103
+
+namespace bssl {
+
+using ScopedEVP_CIPHER_CTX =
+ ScopedContext<EVP_CIPHER_CTX, int, EVP_CIPHER_CTX_init,
+ EVP_CIPHER_CTX_cleanup>;
+
+} // namespace bssl
+
+#endif
+
#endif
#define CIPHER_R_AES_KEY_SETUP_FAILED 100
diff --git a/include/openssl/cmac.h b/include/openssl/cmac.h
index 0bb44b95..c536beff 100644
--- a/include/openssl/cmac.h
+++ b/include/openssl/cmac.h
@@ -71,6 +71,17 @@ OPENSSL_EXPORT int CMAC_Final(CMAC_CTX *ctx, uint8_t *out, size_t *out_len);
#if defined(__cplusplus)
} /* extern C */
+
+#if __cplusplus >= 201103
+
+namespace bssl {
+
+using ScopedCMAC_CTX = ScopedType<CMAC_CTX, CMAC_CTX_free>;
+
+} // namespace bssl
+
+#endif
+
#endif
#endif /* OPENSSL_HEADER_CMAC_H */
diff --git a/include/openssl/curve25519.h b/include/openssl/curve25519.h
index a9441cd4..5eaa191f 100644
--- a/include/openssl/curve25519.h
+++ b/include/openssl/curve25519.h
@@ -167,6 +167,17 @@ OPENSSL_EXPORT int SPAKE2_process_msg(SPAKE2_CTX *ctx, uint8_t *out_key,
#if defined(__cplusplus)
} /* extern C */
+
+#if __cplusplus >= 201103
+
+namespace bssl {
+
+using ScopedSPAKE2_CTX = ScopedType<SPAKE2_CTX, SPAKE2_CTX_free>;
+
+} // namespace bssl
+
+#endif
+
#endif
#endif /* OPENSSL_HEADER_CURVE25519_H */
diff --git a/include/openssl/dh.h b/include/openssl/dh.h
index a0876518..c750970e 100644
--- a/include/openssl/dh.h
+++ b/include/openssl/dh.h
@@ -255,6 +255,17 @@ struct dh_st {
#if defined(__cplusplus)
} /* extern C */
+
+#if __cplusplus >= 201103
+
+namespace bssl {
+
+using ScopedDH = ScopedType<DH, DH_free>;
+
+} // namespace bssl
+
+#endif
+
#endif
#define DH_R_BAD_GENERATOR 100
diff --git a/include/openssl/digest.h b/include/openssl/digest.h
index 07ea07a6..b749092f 100644
--- a/include/openssl/digest.h
+++ b/include/openssl/digest.h
@@ -260,6 +260,18 @@ struct env_md_ctx_st {
#if defined(__cplusplus)
} /* extern C */
+
+#if __cplusplus >= 201103
+
+namespace bssl {
+
+using ScopedEVP_MD_CTX =
+ ScopedContext<EVP_MD_CTX, int, EVP_MD_CTX_init, EVP_MD_CTX_cleanup>;
+
+} // namespace bssl
+
+#endif
+
#endif
#define DIGEST_R_INPUT_NOT_INITIALIZED 100
diff --git a/include/openssl/ec.h b/include/openssl/ec.h
index 32aded65..8e90ae33 100644
--- a/include/openssl/ec.h
+++ b/include/openssl/ec.h
@@ -359,6 +359,18 @@ OPENSSL_EXPORT size_t EC_get_builtin_curves(EC_builtin_curve *out_curves,
#if defined(__cplusplus)
} /* extern C */
+
+#if __cplusplus >= 201103
+
+namespace bssl {
+
+using ScopedEC_GROUP = ScopedType<EC_GROUP, EC_GROUP_free>;
+using ScopedEC_POINT = ScopedType<EC_POINT, EC_POINT_free>;
+
+} // namespace bssl
+
+#endif
+
#endif
#define EC_R_BUFFER_TOO_SMALL 100
diff --git a/include/openssl/ec_key.h b/include/openssl/ec_key.h
index 63554a78..78b2f256 100644
--- a/include/openssl/ec_key.h
+++ b/include/openssl/ec_key.h
@@ -322,6 +322,17 @@ OPENSSL_EXPORT int i2o_ECPublicKey(const EC_KEY *key, unsigned char **outp);
#if defined(__cplusplus)
} /* extern C */
+
+#if __cplusplus >= 201103
+
+namespace bssl {
+
+using ScopedEC_KEY = ScopedType<EC_KEY, EC_KEY_free>;
+
+} // namespace bssl
+
+#endif
+
#endif
#endif /* OPENSSL_HEADER_EC_KEY_H */
diff --git a/include/openssl/ecdsa.h b/include/openssl/ecdsa.h
index a060eab3..30e7ef36 100644
--- a/include/openssl/ecdsa.h
+++ b/include/openssl/ecdsa.h
@@ -194,6 +194,17 @@ OPENSSL_EXPORT int i2d_ECDSA_SIG(const ECDSA_SIG *sig, uint8_t **outp);
#if defined(__cplusplus)
} /* extern C */
+
+#if __cplusplus >= 201103
+
+namespace bssl {
+
+using ScopedECDSA_SIG = ScopedType<ECDSA_SIG, ECDSA_SIG_free>;
+
+} // namespace bssl
+
+#endif
+
#endif
#define ECDSA_R_BAD_SIGNATURE 100
diff --git a/include/openssl/evp.h b/include/openssl/evp.h
index 54074073..64554cd8 100644
--- a/include/openssl/evp.h
+++ b/include/openssl/evp.h
@@ -747,6 +747,18 @@ struct evp_pkey_st {
#if defined(__cplusplus)
} /* extern C */
+
+#if __cplusplus >= 201103
+
+namespace bssl {
+
+using ScopedEVP_PKEY = ScopedType<EVP_PKEY, EVP_PKEY_free>;
+using ScopedEVP_PKEY_CTX = ScopedType<EVP_PKEY_CTX, EVP_PKEY_CTX_free>;
+
+} // namespace bssl
+
+#endif
+
#endif
#define EVP_R_BUFFER_TOO_SMALL 100
diff --git a/include/openssl/hmac.h b/include/openssl/hmac.h
index 5a4e9c7f..4e1c7b90 100644
--- a/include/openssl/hmac.h
+++ b/include/openssl/hmac.h
@@ -153,6 +153,18 @@ struct hmac_ctx_st {
#if defined(__cplusplus)
} /* extern C */
+
+#if __cplusplus >= 201103
+
+namespace bssl {
+
+using ScopedHMAC_CTX =
+ ScopedContext<HMAC_CTX, void, HMAC_CTX_init, HMAC_CTX_cleanup>;
+
+} // namespace bssl
+
+#endif
+
#endif
#endif /* OPENSSL_HEADER_HMAC_H */
diff --git a/include/openssl/mem.h b/include/openssl/mem.h
index d7737526..aca489b7 100644
--- a/include/openssl/mem.h
+++ b/include/openssl/mem.h
@@ -134,6 +134,8 @@ OPENSSL_EXPORT int BIO_vsnprintf(char *buf, size_t n, const char *format,
#if defined(__cplusplus)
} /* extern C */
+#if __cplusplus >= 201103
+
namespace bssl {
template<typename T>
@@ -143,8 +145,13 @@ struct Free {
}
};
+using ScopedBytes = std::unique_ptr<uint8_t, Free<uint8_t>>;
+using ScopedString = std::unique_ptr<char, Free<char>>;
+
} // namespace bssl
#endif
+#endif
+
#endif /* OPENSSL_HEADER_MEM_H */
diff --git a/include/openssl/newhope.h b/include/openssl/newhope.h
index 487e03f6..16900fce 100644
--- a/include/openssl/newhope.h
+++ b/include/openssl/newhope.h
@@ -142,6 +142,17 @@ OPENSSL_EXPORT void NEWHOPE_offer_frommsg(
#if defined(__cplusplus)
} /* extern "C" */
+
+#if __cplusplus >= 201103
+
+namespace bssl {
+
+using ScopedNEWHOPE_POLY = ScopedType<NEWHOPE_POLY, NEWHOPE_POLY_free>;
+
+} // namespace bssl
+
+#endif
+
#endif
#endif /* OPENSSL_HEADER_NEWHOPE_H */
diff --git a/include/openssl/pkcs8.h b/include/openssl/pkcs8.h
index 28cf6ac1..a6bf7594 100644
--- a/include/openssl/pkcs8.h
+++ b/include/openssl/pkcs8.h
@@ -187,6 +187,19 @@ OPENSSL_EXPORT void PKCS12_free(PKCS12 *p12);
#if defined(__cplusplus)
} /* extern C */
+
+#if __cplusplus >= 201103
+
+namespace bssl {
+
+using ScopedPKCS8_PRIV_KEY_INFO =
+ ScopedType<PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO_free>;
+using ScopedPKCS12 = ScopedType<PKCS12, PKCS12_free>;
+
+} // namespace bssl
+
+#endif
+
#endif
#define PKCS8_R_BAD_PKCS12_DATA 100
diff --git a/include/openssl/rsa.h b/include/openssl/rsa.h
index 063d2e8b..513fb33c 100644
--- a/include/openssl/rsa.h
+++ b/include/openssl/rsa.h
@@ -612,6 +612,17 @@ struct rsa_st {
#if defined(__cplusplus)
} /* extern C */
+
+#if __cplusplus >= 201103
+
+namespace bssl {
+
+using ScopedRSA = ScopedType<RSA, RSA_free>;
+
+} // namespace bssl
+
+#endif
+
#endif
#define RSA_R_BAD_ENCODING 100
diff --git a/include/openssl/ssl.h b/include/openssl/ssl.h
index 2ae5ab1a..917601e7 100644
--- a/include/openssl/ssl.h
+++ b/include/openssl/ssl.h
@@ -4505,6 +4505,19 @@ OPENSSL_EXPORT int SSL_set_ssl_method(SSL *s, const SSL_METHOD *method);
#if defined(__cplusplus)
} /* extern C */
+
+#if __cplusplus >= 201103
+
+namespace bssl {
+
+using ScopedSSL = ScopedType<SSL, SSL_free>;
+using ScopedSSL_CTX = ScopedType<SSL_CTX, SSL_CTX_free>;
+using ScopedSSL_SESSION = ScopedType<SSL_SESSION, SSL_SESSION_free>;
+
+} // namespace bssl
+
+#endif
+
#endif
#define SSL_R_APP_DATA_IN_HANDSHAKE 100
diff --git a/include/openssl/stack.h b/include/openssl/stack.h
index 913db504..4c0a3e88 100644
--- a/include/openssl/stack.h
+++ b/include/openssl/stack.h
@@ -291,6 +291,8 @@ OPENSSL_EXPORT _STACK *sk_deep_copy(const _STACK *sk,
#if defined(__cplusplus)
} /* extern C */
+#if __cplusplus >= 201103
+
namespace bssl {
template<typename StackType, typename T, void (*func)(T*)>
@@ -306,6 +308,9 @@ using ScopedStack =
std::unique_ptr<StackType, StackDeleter<StackType, T, func>>;
} // namespace bssl
+
+#endif
+
#endif
#endif /* OPENSSL_HEADER_STACK_H */
diff --git a/include/openssl/x509.h b/include/openssl/x509.h
index bbc263e0..cfe96573 100644
--- a/include/openssl/x509.h
+++ b/include/openssl/x509.h
@@ -1225,6 +1225,22 @@ OPENSSL_EXPORT int PKCS7_get_PEM_CRLs(STACK_OF(X509_CRL) *out_crls,
#ifdef __cplusplus
}
+
+#if __cplusplus >= 201103
+
+namespace bssl {
+
+using ScopedX509 = ScopedType<X509, X509_free>;
+using ScopedX509_ALGOR = ScopedType<X509_ALGOR, X509_ALGOR_free>;
+using ScopedX509_SIG = ScopedType<X509_SIG, X509_SIG_free>;
+using ScopedX509_STORE_CTX = ScopedType<X509_STORE_CTX, X509_STORE_CTX_free>;
+
+using ScopedX509Stack = ScopedStack<STACK_OF(X509), X509, X509_free>;
+
+} // namespace bssl
+
+#endif
+
#endif
#define X509_R_AKID_MISMATCH 100
diff --git a/ssl/ssl_test.cc b/ssl/ssl_test.cc
index 92fad05d..30c9777d 100644
--- a/ssl/ssl_test.cc
+++ b/ssl/ssl_test.cc
@@ -29,7 +29,6 @@
#include <openssl/ssl.h>
#include <openssl/x509.h>
-#include "test/scoped_types.h"
#include "../crypto/test/test_util.h"
diff --git a/ssl/test/async_bio.h b/ssl/test/async_bio.h
index 1799347b..6bfe1a9b 100644
--- a/ssl/test/async_bio.h
+++ b/ssl/test/async_bio.h
@@ -17,8 +17,6 @@
#include <openssl/bio.h>
-#include "../../crypto/test/scoped_types.h"
-
namespace bssl {
diff --git a/ssl/test/bssl_shim.cc b/ssl/test/bssl_shim.cc
index 9ce8b5f2..30aaba60 100644
--- a/ssl/test/bssl_shim.cc
+++ b/ssl/test/bssl_shim.cc
@@ -55,10 +55,8 @@ OPENSSL_MSVC_PRAGMA(warning(pop))
#include <string>
#include <vector>
-#include "../../crypto/test/scoped_types.h"
#include "async_bio.h"
#include "packeted_bio.h"
-#include "scoped_types.h"
#include "test_config.h"
diff --git a/ssl/test/packeted_bio.h b/ssl/test/packeted_bio.h
index e6dcfe4c..351fc2c5 100644
--- a/ssl/test/packeted_bio.h
+++ b/ssl/test/packeted_bio.h
@@ -18,8 +18,6 @@
#include <openssl/base.h>
#include <openssl/bio.h>
-#include "../../crypto/test/scoped_types.h"
-
#if defined(OPENSSL_WINDOWS)
OPENSSL_MSVC_PRAGMA(warning(push, 3))
#include <winsock2.h>
diff --git a/ssl/test/scoped_types.h b/ssl/test/scoped_types.h
deleted file mode 100644
index 0b3b5629..00000000
--- a/ssl/test/scoped_types.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (c) 2015, Google Inc.
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
-
-#ifndef OPENSSL_HEADER_SSL_TEST_SCOPED_TYPES_H
-#define OPENSSL_HEADER_SSL_TEST_SCOPED_TYPES_H
-
-#include <openssl/ssl.h>
-
-#include "../../crypto/test/scoped_types.h"
-
-
-namespace bssl {
-
-using ScopedSSL = ScopedType<SSL, SSL_free>;
-using ScopedSSL_CTX = ScopedType<SSL_CTX, SSL_CTX_free>;
-using ScopedSSL_SESSION = ScopedType<SSL_SESSION, SSL_SESSION_free>;
-
-} // namespace bssl
-
-
-#endif // OPENSSL_HEADER_SSL_TEST_SCOPED_TYPES_H
diff --git a/tool/ciphers.cc b/tool/ciphers.cc
index fa060aba..2de29a6f 100644
--- a/tool/ciphers.cc
+++ b/tool/ciphers.cc
@@ -20,8 +20,6 @@
#include <openssl/ssl.h>
-#include "../crypto/test/scoped_types.h"
-#include "../ssl/test/scoped_types.h"
#include "internal.h"
diff --git a/tool/client.cc b/tool/client.cc
index 593e3c61..03e46a42 100644
--- a/tool/client.cc
+++ b/tool/client.cc
@@ -20,8 +20,6 @@
#include <openssl/pem.h>
#include <openssl/ssl.h>
-#include "../crypto/test/scoped_types.h"
-#include "../ssl/test/scoped_types.h"
#include "internal.h"
#include "transport_common.h"
diff --git a/tool/generate_ed25519.cc b/tool/generate_ed25519.cc
index 9672b78c..17f086b2 100644
--- a/tool/generate_ed25519.cc
+++ b/tool/generate_ed25519.cc
@@ -18,7 +18,6 @@
#include <stdio.h>
#include <string.h>
-#include "../crypto/test/scoped_types.h"
#include "internal.h"
@@ -37,6 +36,14 @@ static const struct argument kArguments[] = {
},
};
+struct FileCloser {
+ void operator()(FILE *file) {
+ fclose(file);
+ }
+};
+
+using ScopedFILE = std::unique_ptr<FILE, FileCloser>;
+
static bool WriteToFile(const std::string &path, const uint8_t *in,
size_t in_len) {
ScopedFILE file(fopen(path.c_str(), "wb"));
diff --git a/tool/genrsa.cc b/tool/genrsa.cc
index 576bd7c9..3412475d 100644
--- a/tool/genrsa.cc
+++ b/tool/genrsa.cc
@@ -18,7 +18,6 @@
#include <openssl/pem.h>
#include <openssl/rsa.h>
-#include "../crypto/test/scoped_types.h"
#include "internal.h"
diff --git a/tool/speed.cc b/tool/speed.cc
index 8efd1f40..1fdda6b7 100644
--- a/tool/speed.cc
+++ b/tool/speed.cc
@@ -21,8 +21,11 @@
#include <string.h>
#include <openssl/aead.h>
+#include <openssl/bn.h>
#include <openssl/curve25519.h>
#include <openssl/digest.h>
+#include <openssl/ecdsa.h>
+#include <openssl/ec.h>
#include <openssl/err.h>
#include <openssl/newhope.h>
#include <openssl/nid.h>
@@ -37,7 +40,6 @@ OPENSSL_MSVC_PRAGMA(warning(pop))
#include <sys/time.h>
#endif
-#include "../crypto/test/scoped_types.h"
#include "internal.h"
diff --git a/util/BUILD b/util/BUILD
index 51e95b18..6b645e61 100644
--- a/util/BUILD
+++ b/util/BUILD
@@ -113,10 +113,7 @@ cc_library(
cc_binary(
name = "bssl",
- srcs = tool_sources + tool_headers + [
- "src/crypto/test/scoped_types.h",
- "src/ssl/test/scoped_types.h",
- ],
+ srcs = tool_sources + tool_headers,
copts = boringssl_copts_cxx,
visibility = ["//visibility:public"],
deps = [":ssl"],