Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Unified Diff: net/android/keystore_openssl.cc

Issue 361193003: Eliminate ScopedOpenSSL in favour of scoped_ptr<> specializations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review feedback Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/android/keystore_openssl.cc
diff --git a/net/android/keystore_openssl.cc b/net/android/keystore_openssl.cc
index ec08d70236a84018adcda576bac38b7c17990edf..e2e53d7b10e93a774238e212b7ab8aedcdea9d16 100644
--- a/net/android/keystore_openssl.cc
+++ b/net/android/keystore_openssl.cc
@@ -26,6 +26,7 @@
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "crypto/openssl_util.h"
+#include "crypto/scoped_openssl_types.h"
#include "net/android/keystore.h"
#include "net/ssl/ssl_client_cert_type.h"
@@ -101,11 +102,7 @@ namespace android {
namespace {
-typedef crypto::ScopedOpenSSL<EVP_PKEY, EVP_PKEY_free> ScopedEVP_PKEY;
-typedef crypto::ScopedOpenSSL<RSA, RSA_free> ScopedRSA;
-typedef crypto::ScopedOpenSSL<DSA, DSA_free> ScopedDSA;
-typedef crypto::ScopedOpenSSL<EC_KEY, EC_KEY_free> ScopedEC_KEY;
-typedef crypto::ScopedOpenSSL<EC_GROUP, EC_GROUP_free> ScopedEC_GROUP;
+typedef crypto::ScopedOpenSSL<EC_GROUP, EC_GROUP_free>::Type ScopedEC_GROUP;
// Custom RSA_METHOD that uses the platform APIs.
// Note that for now, only signing through RSA_sign() is really supported.
@@ -283,7 +280,7 @@ bool SwapBigNumPtrFromBytes(const std::vector<uint8>& new_bytes,
// IMPORTANT: The EVP_PKEY will *only* work on Android >= 4.2. For older
// platforms, use GetRsaLegacyKey() instead.
bool GetRsaPkeyWrapper(jobject private_key, EVP_PKEY* pkey) {
- ScopedRSA rsa(RSA_new());
+ crypto::ScopedRSA rsa(RSA_new());
RSA_set_method(rsa.get(), &android_rsa_method);
// HACK: RSA_size() doesn't work with custom RSA_METHODs. To ensure that
@@ -327,7 +324,7 @@ class KeystoreEngineWorkaround {
void LeakRsaEngine(EVP_PKEY* pkey) {
if (leaked_engine_)
return;
- ScopedRSA rsa(EVP_PKEY_get1_RSA(pkey));
+ crypto::ScopedRSA rsa(EVP_PKEY_get1_RSA(pkey));
if (!rsa.get() ||
!rsa.get()->engine ||
strcmp(ENGINE_get_id(rsa.get()->engine), "keystore") ||
@@ -480,7 +477,7 @@ const DSA_METHOD android_dsa_method = {
// On success, this creates a global JNI reference to the same object
// that will be owned by and destroyed with the EVP_PKEY.
bool GetDsaPkeyWrapper(jobject private_key, EVP_PKEY* pkey) {
- ScopedDSA dsa(DSA_new());
+ crypto::ScopedDSA dsa(DSA_new());
DSA_set_method(dsa.get(), &android_dsa_method);
// DSA_size() doesn't work with custom DSA_METHODs. To ensure it
@@ -649,7 +646,7 @@ const ECDSA_METHOD android_ecdsa_method = {
// is owned by and destroyed with the EVP_PKEY. I.e. the caller shall
// always free |private_key| after the call.
bool GetEcdsaPkeyWrapper(jobject private_key, EVP_PKEY* pkey) {
- ScopedEC_KEY eckey(EC_KEY_new());
+ crypto::ScopedEC_KEY eckey(EC_KEY_new());
ECDSA_set_method(eckey.get(), &android_ecdsa_method);
// To ensure that ECDSA_size() works properly, craft a custom EC_GROUP
@@ -688,7 +685,7 @@ bool GetEcdsaPkeyWrapper(jobject private_key, EVP_PKEY* pkey) {
EVP_PKEY* GetOpenSSLPrivateKeyWrapper(jobject private_key) {
// Create new empty EVP_PKEY instance.
- ScopedEVP_PKEY pkey(EVP_PKEY_new());
+ crypto::ScopedEVP_PKEY pkey(EVP_PKEY_new());
if (!pkey.get())
return NULL;

Powered by Google App Engine
This is Rietveld 408576698