Switch ssl_ecdh to C++.
The EC_POINT munging is sufficiently heavy on the goto err that I went
ahead and tidied it up.
Bug: 132
Change-Id: I7a3b3b3f166e39e4559acec834dd8e1ea9ac8620
Reviewed-on: https://boringssl-review.googlesource.com/17747
Reviewed-by: Steven Valdez <svaldez@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
diff --git a/include/openssl/bn.h b/include/openssl/bn.h
index 5ebdade..0d2068f 100644
--- a/include/openssl/bn.h
+++ b/include/openssl/bn.h
@@ -938,6 +938,7 @@
#if defined(__cplusplus)
} /* extern C */
+#if !defined(OPENSSL_NO_CXX)
extern "C++" {
namespace bssl {
@@ -946,9 +947,22 @@
BORINGSSL_MAKE_DELETER(BN_CTX, BN_CTX_free)
BORINGSSL_MAKE_DELETER(BN_MONT_CTX, BN_MONT_CTX_free)
+class BN_CTXScope {
+ public:
+ BN_CTXScope(BN_CTX *ctx) : ctx_(ctx) { BN_CTX_start(ctx_); }
+ ~BN_CTXScope() { BN_CTX_end(ctx_); }
+
+ private:
+ BN_CTX *ctx_;
+
+ BN_CTXScope(BN_CTXScope &) = delete;
+ BN_CTXScope &operator=(BN_CTXScope &) = delete;
+};
+
} // namespace bssl
} /* extern C++ */
+#endif
#endif