diff options
author | David Benjamin <davidben@google.com> | 2016-09-07 01:10:19 +0300 |
---|---|---|
committer | CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org> | 2016-09-08 00:50:05 +0300 |
commit | f0e935d7ce2747bc72d7968d3baa503483f68ce0 (patch) | |
tree | 8ba2da08928aa82df32f38c66707e78d95f1435b /include/openssl | |
parent | 7072884350da8a01e2b1d5bbcd3749c93831d8d6 (diff) |
Fold stack-allocated types into headers.
Now that we have the extern "C++" trick, we can just embed them in the
normal headers. Move the EVP_CIPHER_CTX deleter to cipher.h and, in
doing so, take away a little bit of boilerplate in defining deleters.
Change-Id: I4a4b8d0db5274a3607914d94e76a38996bd611ec
Reviewed-on: https://boringssl-review.googlesource.com/10804
Reviewed-by: Matt Braithwaite <mab@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
Diffstat (limited to 'include/openssl')
32 files changed, 113 insertions, 275 deletions
diff --git a/include/openssl/aead.h b/include/openssl/aead.h index 7895825c..71071d2b 100644 --- a/include/openssl/aead.h +++ b/include/openssl/aead.h @@ -333,6 +333,21 @@ OPENSSL_EXPORT int EVP_AEAD_CTX_get_iv(const EVP_AEAD_CTX *ctx, #if defined(__cplusplus) } /* extern C */ + +#if !defined(BORINGSSL_NO_CXX) +extern "C++" { + +namespace bssl { + +using ScopedEVP_AEAD_CTX = + internal::StackAllocated<EVP_AEAD_CTX, void, EVP_AEAD_CTX_zero, + EVP_AEAD_CTX_cleanup>; + +} // namespace bssl + +} // extern C++ +#endif + #endif #endif /* OPENSSL_HEADER_AEAD_H */ diff --git a/include/openssl/asn1.h b/include/openssl/asn1.h index e99099ee..391be811 100644 --- a/include/openssl/asn1.h +++ b/include/openssl/asn1.h @@ -928,14 +928,10 @@ extern "C++" { namespace bssl { -namespace internal { - BORINGSSL_MAKE_DELETER(ASN1_OBJECT, ASN1_OBJECT_free) BORINGSSL_MAKE_DELETER(ASN1_STRING, ASN1_STRING_free) BORINGSSL_MAKE_DELETER(ASN1_TYPE, ASN1_TYPE_free) -} // namespace internal - } // namespace bssl } /* extern C++ */ diff --git a/include/openssl/base.h b/include/openssl/base.h index 8347c613..bfb4ea84 100644 --- a/include/openssl/base.h +++ b/include/openssl/base.h @@ -300,18 +300,22 @@ typedef void *OPENSSL_BLOCK; #if defined(__cplusplus) } /* extern C */ -extern "C++" { - // 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. -#if defined(BORINGSSL_NO_CXX) || (__cplusplus < 201103L && !defined(_MSC_VER)) +#if !defined(BORINGSSL_NO_CXX) && __cplusplus < 201103L && !defined(_MSC_VER) +#define BORINGSSL_NO_CXX +#endif + +#if defined(BORINGSSL_NO_CXX) #define BORINGSSL_MAKE_DELETER(type, deleter) #define BORINGSSL_MAKE_STACK_DELETER(type, deleter) #else +extern "C++" { + #include <memory> namespace bssl { @@ -320,21 +324,44 @@ namespace internal { template <class T> struct Deleter {}; +template <typename T, typename CleanupRet, void (*init)(T *), + CleanupRet (*cleanup)(T *)> +class StackAllocated { + public: + StackAllocated() { init(&ctx_); } + ~StackAllocated() { cleanup(&ctx_); } + + T *get() { return &ctx_; } + const T *get() const { return &ctx_; } + + void Reset() { + cleanup(&ctx_); + init(&ctx_); + } + + private: + T ctx_; +}; + +} // namespace internal + #define BORINGSSL_MAKE_DELETER(type, deleter) \ + namespace internal { \ template <> struct Deleter<type> { \ void operator()(type* ptr) { deleter(ptr); } \ - }; + }; \ + } // This makes a unique_ptr to STACK_OF(type) that owns all elements on the // stack, i.e. it uses sk_pop_free() to clean up. #define BORINGSSL_MAKE_STACK_DELETER(type, deleter) \ + namespace internal { \ template <> struct Deleter<STACK_OF(type)> { \ void operator()(STACK_OF(type)* ptr) { \ sk_##type##_pop_free(ptr, deleter); \ } \ - }; - -} // namespace internal + }; \ + } // Holds ownership of heap-allocated BoringSSL structures. Sample usage: // bssl::UniquePtr<BIO> rsa(RSA_new()); @@ -344,10 +371,10 @@ using UniquePtr = std::unique_ptr<T, internal::Deleter<T>>; } // namespace bssl -#endif // C++ allowed? - } /* extern C++ */ +#endif // !BORINGSSL_NO_CXX + #endif #endif /* OPENSSL_HEADER_BASE_H */ diff --git a/include/openssl/bio.h b/include/openssl/bio.h index 4aa9070c..41c30caa 100644 --- a/include/openssl/bio.h +++ b/include/openssl/bio.h @@ -900,12 +900,8 @@ extern "C++" { namespace bssl { -namespace internal { - BORINGSSL_MAKE_DELETER(BIO, BIO_free) -} // namespace internal - } // namespace bssl } /* extern C++ */ diff --git a/include/openssl/bn.h b/include/openssl/bn.h index c1b9e39b..554a81ba 100644 --- a/include/openssl/bn.h +++ b/include/openssl/bn.h @@ -918,14 +918,10 @@ extern "C++" { namespace bssl { -namespace internal { - BORINGSSL_MAKE_DELETER(BIGNUM, BN_free) BORINGSSL_MAKE_DELETER(BN_CTX, BN_CTX_free) BORINGSSL_MAKE_DELETER(BN_MONT_CTX, BN_MONT_CTX_free) -} // namespace internal - } // namespace bssl } /* extern C++ */ diff --git a/include/openssl/buf.h b/include/openssl/buf.h index 7e398642..30f3af79 100644 --- a/include/openssl/buf.h +++ b/include/openssl/buf.h @@ -122,12 +122,8 @@ extern "C++" { namespace bssl { -namespace internal { - BORINGSSL_MAKE_DELETER(BUF_MEM, BUF_MEM_free) -} // namespace internal - } // namespace bssl } /* extern C++ */ diff --git a/include/openssl/bytestring.h b/include/openssl/bytestring.h index c055a737..2985268e 100644 --- a/include/openssl/bytestring.h +++ b/include/openssl/bytestring.h @@ -416,6 +416,20 @@ OPENSSL_EXPORT int CBB_add_asn1_uint64(CBB *cbb, uint64_t value); #if defined(__cplusplus) } /* extern C */ + + +#if !defined(BORINGSSL_NO_CXX) +extern "C++" { + +namespace bssl { + +using ScopedCBB = internal::StackAllocated<CBB, void, CBB_zero, CBB_cleanup>; + +} // namespace bssl + +} // extern C++ +#endif + #endif #endif /* OPENSSL_HEADER_BYTESTRING_H */ diff --git a/include/openssl/c++/aead.h b/include/openssl/c++/aead.h deleted file mode 100644 index 15309230..00000000 --- a/include/openssl/c++/aead.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (c) 2016, 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_CXX_AEAD_H -#define OPENSSL_HEADER_CXX_AEAD_H - -#include <openssl/aead.h> -#include <openssl/c++/scoped_helpers.h> - -namespace bssl { - -using ScopedEVP_AEAD_CTX = - ScopedContext<EVP_AEAD_CTX, void, EVP_AEAD_CTX_zero, EVP_AEAD_CTX_cleanup>; - -} // namespace bssl - -#endif /* OPENSSL_HEADER_CXX_AEAD_H */ diff --git a/include/openssl/c++/bytestring.h b/include/openssl/c++/bytestring.h deleted file mode 100644 index 87325a9d..00000000 --- a/include/openssl/c++/bytestring.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright (c) 2016, 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_CXX_BYTESTRING_H -#define OPENSSL_HEADER_CXX_BYTESTRING_H - -#include <openssl/bytestring.h> -#include <openssl/c++/scoped_helpers.h> - -namespace bssl { - -using ScopedCBB = ScopedContext<CBB, void, CBB_zero, CBB_cleanup>; - -} // namespace bssl - -#endif /* OPENSSL_HEADER_CXX_BYTESTRING_H */ diff --git a/include/openssl/c++/cipher.h b/include/openssl/c++/cipher.h deleted file mode 100644 index 997a6061..00000000 --- a/include/openssl/c++/cipher.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (c) 2016, 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_CXX_CIPHER_H -#define OPENSSL_HEADER_CXX_CIPHER_H - -#include <openssl/cipher.h> -#include <openssl/c++/scoped_helpers.h> - -namespace bssl { - -using ScopedEVP_CIPHER_CTX = - ScopedContext<EVP_CIPHER_CTX, int, EVP_CIPHER_CTX_init, - EVP_CIPHER_CTX_cleanup>; - -} // namespace bssl - -#endif /* OPENSSL_HEADER_CXX_CIPHER_H */ diff --git a/include/openssl/c++/digest.h b/include/openssl/c++/digest.h deleted file mode 100644 index f557921d..00000000 --- a/include/openssl/c++/digest.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (c) 2016, 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_CXX_DIGEST_H -#define OPENSSL_HEADER_CXX_DIGEST_H - -#include <openssl/c++/scoped_helpers.h> -#include <openssl/evp.h> - -namespace bssl { - -using ScopedEVP_MD_CTX = - ScopedContext<EVP_MD_CTX, int, EVP_MD_CTX_init, EVP_MD_CTX_cleanup>; - -} // namespace bssl - -#endif /* OPENSSL_HEADER_CXX_DIGEST_H */ diff --git a/include/openssl/c++/hmac.h b/include/openssl/c++/hmac.h deleted file mode 100644 index 0e8d2e13..00000000 --- a/include/openssl/c++/hmac.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (c) 2016, 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_CXX_HMAC_H -#define OPENSSL_HEADER_CXX_HMAC_H - -#include <openssl/c++/scoped_helpers.h> -#include <openssl/hmac.h> - -namespace bssl { - -using ScopedHMAC_CTX = - ScopedContext<HMAC_CTX, void, HMAC_CTX_init, HMAC_CTX_cleanup>; - -} // namespace bssl - -#endif /* OPENSSL_HEADER_CXX_HMAC_H */ diff --git a/include/openssl/c++/scoped_helpers.h b/include/openssl/c++/scoped_helpers.h deleted file mode 100644 index daaf50ee..00000000 --- a/include/openssl/c++/scoped_helpers.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (c) 2016, 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_CXX_SCOPED_HELPERS_H -#define OPENSSL_HEADER_CXX_SCOPED_HELPERS_H - -namespace bssl { - -template<typename T, typename CleanupRet, void (*init_func)(T*), - CleanupRet (*cleanup_func)(T*)> -class ScopedContext { - public: - ScopedContext() { - init_func(&ctx_); - } - ~ScopedContext() { - cleanup_func(&ctx_); - } - - T *get() { return &ctx_; } - const T *get() const { return &ctx_; } - - void Reset() { - cleanup_func(&ctx_); - init_func(&ctx_); - } - - private: - T ctx_; -}; - -} // namespace bssl - -#endif /* OPENSSL_HEADER_CXX_SCOPED_HELPERS_H */ diff --git a/include/openssl/cipher.h b/include/openssl/cipher.h index 53123086..a8585d78 100644 --- a/include/openssl/cipher.h +++ b/include/openssl/cipher.h @@ -540,6 +540,23 @@ struct evp_cipher_st { #if defined(__cplusplus) } /* extern C */ + +#if !defined(BORINGSSL_NO_CXX) +extern "C++" { + +namespace bssl { + +BORINGSSL_MAKE_DELETER(EVP_CIPHER_CTX, EVP_CIPHER_CTX_free) + +using ScopedEVP_CIPHER_CTX = + internal::StackAllocated<EVP_CIPHER_CTX, int, EVP_CIPHER_CTX_init, + EVP_CIPHER_CTX_cleanup>; + +} // namespace bssl + +} // extern C++ +#endif + #endif #define CIPHER_R_AES_KEY_SETUP_FAILED 100 diff --git a/include/openssl/cmac.h b/include/openssl/cmac.h index fb0b9f25..0f05bc93 100644 --- a/include/openssl/cmac.h +++ b/include/openssl/cmac.h @@ -76,12 +76,8 @@ extern "C++" { namespace bssl { -namespace internal { - BORINGSSL_MAKE_DELETER(CMAC_CTX, CMAC_CTX_free) -} // namespace internal - } // namespace bssl } /* extern C++ */ diff --git a/include/openssl/conf.h b/include/openssl/conf.h index 8acb0849..6e6364f9 100644 --- a/include/openssl/conf.h +++ b/include/openssl/conf.h @@ -163,12 +163,8 @@ extern "C++" { namespace bssl { -namespace internal { - BORINGSSL_MAKE_DELETER(CONF, NCONF_free) -} // namespace internal - } // namespace bssl } /* extern C++ */ diff --git a/include/openssl/curve25519.h b/include/openssl/curve25519.h index 70eff7a4..e9ba04d9 100644 --- a/include/openssl/curve25519.h +++ b/include/openssl/curve25519.h @@ -172,12 +172,8 @@ extern "C++" { namespace bssl { -namespace internal { - BORINGSSL_MAKE_DELETER(SPAKE2_CTX, SPAKE2_CTX_free) -} // namespace internal - } // namespace bssl } /* extern C++ */ diff --git a/include/openssl/dh.h b/include/openssl/dh.h index a3f34d9f..ed2396d1 100644 --- a/include/openssl/dh.h +++ b/include/openssl/dh.h @@ -279,12 +279,8 @@ extern "C++" { namespace bssl { -namespace internal { - BORINGSSL_MAKE_DELETER(DH, DH_free) -} // namespace internal - } // namespace bssl } /* extern C++ */ diff --git a/include/openssl/digest.h b/include/openssl/digest.h index 6c5d6cf6..ec629939 100644 --- a/include/openssl/digest.h +++ b/include/openssl/digest.h @@ -261,6 +261,23 @@ struct env_md_ctx_st { #if defined(__cplusplus) } /* extern C */ + +#if !defined(BORINGSSL_NO_CXX) +extern "C++" { + +namespace bssl { + +BORINGSSL_MAKE_DELETER(EVP_MD_CTX, EVP_MD_CTX_destroy) + +using ScopedEVP_MD_CTX = + internal::StackAllocated<EVP_MD_CTX, int, EVP_MD_CTX_init, + EVP_MD_CTX_cleanup>; + +} // namespace bssl + +} // extern C++ +#endif + #endif #define DIGEST_R_INPUT_NOT_INITIALIZED 100 diff --git a/include/openssl/dsa.h b/include/openssl/dsa.h index 07f14953..d6c3204f 100644 --- a/include/openssl/dsa.h +++ b/include/openssl/dsa.h @@ -416,13 +416,9 @@ extern "C++" { namespace bssl { -namespace internal { - BORINGSSL_MAKE_DELETER(DSA, DSA_free) BORINGSSL_MAKE_DELETER(DSA_SIG, DSA_SIG_free) -} // namespace internal - } // namespace bssl } /* extern C++ */ diff --git a/include/openssl/ec.h b/include/openssl/ec.h index 23494033..c2ef0665 100644 --- a/include/openssl/ec.h +++ b/include/openssl/ec.h @@ -361,13 +361,9 @@ extern "C++" { namespace bssl { -namespace internal { - BORINGSSL_MAKE_DELETER(EC_POINT, EC_POINT_free) BORINGSSL_MAKE_DELETER(EC_GROUP, EC_GROUP_free) -} // namespace internal - } // namespace bssl } /* extern C++ */ diff --git a/include/openssl/ec_key.h b/include/openssl/ec_key.h index a7c8bf8b..1dbae62d 100644 --- a/include/openssl/ec_key.h +++ b/include/openssl/ec_key.h @@ -326,12 +326,8 @@ extern "C++" { namespace bssl { -namespace internal { - BORINGSSL_MAKE_DELETER(EC_KEY, EC_KEY_free) -} // namespace internal - } // namespace bssl } /* extern C++ */ diff --git a/include/openssl/ecdsa.h b/include/openssl/ecdsa.h index 5f07a9c7..f6e9982f 100644 --- a/include/openssl/ecdsa.h +++ b/include/openssl/ecdsa.h @@ -199,12 +199,8 @@ extern "C++" { namespace bssl { -namespace internal { - BORINGSSL_MAKE_DELETER(ECDSA_SIG, ECDSA_SIG_free) -} // namespace internal - } // namespace bssl } /* extern C++ */ diff --git a/include/openssl/engine.h b/include/openssl/engine.h index 9cbdf39a..b029ef94 100644 --- a/include/openssl/engine.h +++ b/include/openssl/engine.h @@ -96,12 +96,8 @@ extern "C++" { namespace bssl { -namespace internal { - BORINGSSL_MAKE_DELETER(ENGINE, ENGINE_free) -} // namespace internal - } // namespace bssl } /* extern C++ */ diff --git a/include/openssl/evp.h b/include/openssl/evp.h index 41e9e14f..58b388aa 100644 --- a/include/openssl/evp.h +++ b/include/openssl/evp.h @@ -754,14 +754,9 @@ struct evp_pkey_st { extern "C++" { namespace bssl { -namespace internal { - -BORINGSSL_MAKE_DELETER(EVP_CIPHER_CTX, EVP_CIPHER_CTX_free) BORINGSSL_MAKE_DELETER(EVP_PKEY, EVP_PKEY_free) BORINGSSL_MAKE_DELETER(EVP_PKEY_CTX, EVP_PKEY_CTX_free) -} // namespace internal - } // namespace bssl } /* extern C++ */ diff --git a/include/openssl/hmac.h b/include/openssl/hmac.h index 35c7f583..e4cc04e6 100644 --- a/include/openssl/hmac.h +++ b/include/openssl/hmac.h @@ -155,6 +155,20 @@ struct hmac_ctx_st { #if defined(__cplusplus) } /* extern C */ + +#if !defined(BORINGSSL_NO_CXX) +extern "C++" { + +namespace bssl { + +using ScopedHMAC_CTX = + internal::StackAllocated<HMAC_CTX, void, HMAC_CTX_init, HMAC_CTX_cleanup>; + +} // namespace bssl + +} // extern C++ +#endif + #endif #endif /* OPENSSL_HEADER_HMAC_H */ diff --git a/include/openssl/mem.h b/include/openssl/mem.h index 98ee0775..5d96a2d7 100644 --- a/include/openssl/mem.h +++ b/include/openssl/mem.h @@ -138,13 +138,9 @@ extern "C++" { namespace bssl { -namespace internal { - BORINGSSL_MAKE_DELETER(char, OPENSSL_free) BORINGSSL_MAKE_DELETER(uint8_t, OPENSSL_free) -} // namespace internal - } // namespace bssl } /* extern C++ */ diff --git a/include/openssl/newhope.h b/include/openssl/newhope.h index 67728ea5..47b9913d 100644 --- a/include/openssl/newhope.h +++ b/include/openssl/newhope.h @@ -147,12 +147,8 @@ extern "C++" { namespace bssl { -namespace internal { - BORINGSSL_MAKE_DELETER(NEWHOPE_POLY, NEWHOPE_POLY_free) -} // namespace internal - } // namespace bssl } /* extern C++ */ diff --git a/include/openssl/pkcs8.h b/include/openssl/pkcs8.h index 0939d8ca..e04a4f34 100644 --- a/include/openssl/pkcs8.h +++ b/include/openssl/pkcs8.h @@ -192,13 +192,9 @@ extern "C++" { namespace bssl { -namespace internal { - BORINGSSL_MAKE_DELETER(PKCS12, PKCS12_free) BORINGSSL_MAKE_DELETER(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO_free) -} // namespace internal - } // namespace bssl } /* extern C++ */ diff --git a/include/openssl/rsa.h b/include/openssl/rsa.h index f761dc68..78d5b32c 100644 --- a/include/openssl/rsa.h +++ b/include/openssl/rsa.h @@ -641,12 +641,8 @@ extern "C++" { namespace bssl { -namespace internal { - BORINGSSL_MAKE_DELETER(RSA, RSA_free) -} // namespace internal - } // namespace bssl } /* extern C++ */ diff --git a/include/openssl/ssl.h b/include/openssl/ssl.h index 46640d9c..ce2ba41a 100644 --- a/include/openssl/ssl.h +++ b/include/openssl/ssl.h @@ -4651,14 +4651,10 @@ extern "C++" { namespace bssl { -namespace internal { - BORINGSSL_MAKE_DELETER(SSL, SSL_free) BORINGSSL_MAKE_DELETER(SSL_CTX, SSL_CTX_free) BORINGSSL_MAKE_DELETER(SSL_SESSION, SSL_SESSION_free) -} // namespace internal - } // namespace bssl } /* extern C++ */ diff --git a/include/openssl/x509.h b/include/openssl/x509.h index c32a6e72..b45dd3bc 100644 --- a/include/openssl/x509.h +++ b/include/openssl/x509.h @@ -1229,8 +1229,6 @@ extern "C++" { namespace bssl { -namespace internal { - BORINGSSL_MAKE_STACK_DELETER(X509, X509_free) BORINGSSL_MAKE_DELETER(X509, X509_free) BORINGSSL_MAKE_DELETER(X509_ALGOR, X509_ALGOR_free) @@ -1250,8 +1248,6 @@ BORINGSSL_MAKE_DELETER(X509_STORE, X509_STORE_free) BORINGSSL_MAKE_DELETER(X509_STORE_CTX, X509_STORE_CTX_free) BORINGSSL_MAKE_DELETER(X509_VERIFY_PARAM, X509_VERIFY_PARAM_free) -} // namespace internal - } // namespace bssl } /* extern C++ */ |