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

Unified Diff: crypto/ec_private_key_nss.cc

Issue 1408813002: Remove crypto::ECPrivateKey::IsSupported. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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: crypto/ec_private_key_nss.cc
diff --git a/crypto/ec_private_key_nss.cc b/crypto/ec_private_key_nss.cc
index 5092010c939b5f734f7c608e1e2ec3c0a35e17c3..5f8a4e6c7841328bed79b776157df2cea6170165 100644
--- a/crypto/ec_private_key_nss.cc
+++ b/crypto/ec_private_key_nss.cc
@@ -15,7 +15,6 @@ extern "C" {
#include <pk11pub.h>
#include <secmod.h>
-#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "crypto/nss_util.h"
@@ -25,34 +24,6 @@ extern "C" {
namespace {
-PK11SlotInfo* GetTempKeySlot() {
- return PK11_GetInternalSlot();
-}
-
-class EllipticCurveSupportChecker {
- public:
- EllipticCurveSupportChecker() {
- // NOTE: we can do this check here only because we use the NSS internal
- // slot. If we support other slots in the future, checking whether they
- // support ECDSA may block NSS, and the value may also change as devices are
- // inserted/removed, so we would need to re-check on every use.
- crypto::EnsureNSSInit();
- crypto::ScopedPK11Slot slot(GetTempKeySlot());
- supported_ = PK11_DoesMechanism(slot.get(), CKM_EC_KEY_PAIR_GEN) &&
- PK11_DoesMechanism(slot.get(), CKM_ECDSA);
- }
-
- bool Supported() {
- return supported_;
- }
-
- private:
- bool supported_;
-};
-
-static base::LazyInstance<EllipticCurveSupportChecker>::Leaky
- g_elliptic_curve_supported = LAZY_INSTANCE_INITIALIZER;
-
// Copied from rsa_private_key_nss.cc.
static bool ReadAttribute(SECKEYPrivateKey* key,
CK_ATTRIBUTE_TYPE type,
@@ -82,15 +53,10 @@ ECPrivateKey::~ECPrivateKey() {
}
// static
-bool ECPrivateKey::IsSupported() {
- return g_elliptic_curve_supported.Get().Supported();
-}
-
-// static
ECPrivateKey* ECPrivateKey::Create() {
EnsureNSSInit();
- ScopedPK11Slot slot(GetTempKeySlot());
+ ScopedPK11Slot slot(PK11_GetInternalSlot());
if (!slot)
return nullptr;
@@ -140,7 +106,7 @@ ECPrivateKey* ECPrivateKey::CreateFromEncryptedPrivateKeyInfo(
const std::vector<uint8>& subject_public_key_info) {
EnsureNSSInit();
- ScopedPK11Slot slot(GetTempKeySlot());
+ ScopedPK11Slot slot(PK11_GetInternalSlot());
if (!slot)
return nullptr;

Powered by Google App Engine
This is Rietveld 408576698