Replace Scoped* heap types with bssl::UniquePtr.
Unlike the Scoped* types, bssl::UniquePtr is available to C++ users, and
offered for a large variety of types. The 'extern "C++"' trick is used
to make the C++ bits digestible to C callers that wrap header files in
'extern "C"'.
Change-Id: Ifbca4c2997d6628e33028c7d7620c72aff0f862e
Reviewed-on: https://boringssl-review.googlesource.com/10521
Reviewed-by: David Benjamin <davidben@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/tool/speed.cc b/tool/speed.cc
index 780a7ea..f089498 100644
--- a/tool/speed.cc
+++ b/tool/speed.cc
@@ -22,9 +22,13 @@
#include <string.h>
#include <openssl/aead.h>
+#include <openssl/bn.h>
#include <openssl/curve25519.h>
#include <openssl/digest.h>
#include <openssl/err.h>
+#include <openssl/ec.h>
+#include <openssl/ecdsa.h>
+#include <openssl/ec_key.h>
#include <openssl/newhope.h>
#include <openssl/nid.h>
#include <openssl/rand.h>
@@ -38,7 +42,6 @@
#include <sys/time.h>
#endif
-#include "../crypto/test/scoped_types.h"
#include "internal.h"
@@ -166,7 +169,7 @@
* RSA key, with a new |BN_MONT_CTX| for the public modulus. If we were
* to use |key| directly instead, then these costs wouldn't be
* accounted for. */
- ScopedRSA verify_key(RSA_new());
+ bssl::UniquePtr<RSA> verify_key(RSA_new());
if (!verify_key) {
return false;
}
@@ -334,17 +337,17 @@
TimeResults results;
if (!TimeFunction(&results, [nid]() -> bool {
- ScopedEC_KEY key(EC_KEY_new_by_curve_name(nid));
+ bssl::UniquePtr<EC_KEY> key(EC_KEY_new_by_curve_name(nid));
if (!key ||
!EC_KEY_generate_key(key.get())) {
return false;
}
const EC_GROUP *const group = EC_KEY_get0_group(key.get());
- ScopedEC_POINT point(EC_POINT_new(group));
- ScopedBN_CTX ctx(BN_CTX_new());
+ bssl::UniquePtr<EC_POINT> point(EC_POINT_new(group));
+ bssl::UniquePtr<BN_CTX> ctx(BN_CTX_new());
- ScopedBIGNUM x(BN_new());
- ScopedBIGNUM y(BN_new());
+ bssl::UniquePtr<BIGNUM> x(BN_new());
+ bssl::UniquePtr<BIGNUM> y(BN_new());
if (!point || !ctx || !x || !y ||
!EC_POINT_mul(group, point.get(), NULL,
@@ -370,7 +373,7 @@
return true;
}
- ScopedEC_KEY key(EC_KEY_new_by_curve_name(nid));
+ bssl::UniquePtr<EC_KEY> key(EC_KEY_new_by_curve_name(nid));
if (!key ||
!EC_KEY_generate_key(key.get())) {
return false;
@@ -499,9 +502,9 @@
static const uint8_t kAliceName[] = {'A'};
static const uint8_t kBobName[] = {'B'};
static const uint8_t kPassword[] = "password";
- ScopedSPAKE2_CTX alice(SPAKE2_CTX_new(spake2_role_alice, kAliceName,
- sizeof(kAliceName), kBobName,
- sizeof(kBobName)));
+ bssl::UniquePtr<SPAKE2_CTX> alice(SPAKE2_CTX_new(spake2_role_alice,
+ kAliceName, sizeof(kAliceName), kBobName,
+ sizeof(kBobName)));
uint8_t alice_msg[SPAKE2_MAX_MSG_SIZE];
size_t alice_msg_len;
@@ -513,9 +516,9 @@
}
if (!TimeFunction(&results, [&alice_msg, alice_msg_len]() -> bool {
- ScopedSPAKE2_CTX bob(SPAKE2_CTX_new(spake2_role_bob, kBobName,
- sizeof(kBobName), kAliceName,
- sizeof(kAliceName)));
+ bssl::UniquePtr<SPAKE2_CTX> bob(SPAKE2_CTX_new(spake2_role_bob,
+ kBobName, sizeof(kBobName), kAliceName,
+ sizeof(kAliceName)));
uint8_t bob_msg[SPAKE2_MAX_MSG_SIZE], bob_key[64];
size_t bob_msg_len, bob_key_len;
if (!SPAKE2_generate_msg(bob.get(), bob_msg, &bob_msg_len,