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

Unified Diff: net/base/openssl_private_key_store_memory.cc

Issue 12220104: Wire up SSL client authentication for OpenSSL/Android through the net/ stack (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: git cl try Created 7 years, 10 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
« no previous file with comments | « net/base/openssl_private_key_store_android.cc ('k') | net/base/test_data_directory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/openssl_private_key_store_memory.cc
diff --git a/net/base/openssl_memory_private_key_store.cc b/net/base/openssl_private_key_store_memory.cc
similarity index 56%
rename from net/base/openssl_memory_private_key_store.cc
rename to net/base/openssl_private_key_store_memory.cc
index 92716f236e1d341edc1f392bdcaa40bd44c0f726..0913e460bd2ab0263fd016a075dfacf19dfcd947 100644
--- a/net/base/openssl_memory_private_key_store.cc
+++ b/net/base/openssl_private_key_store_memory.cc
@@ -4,28 +4,30 @@
// Defines an in-memory private key store, primarily used for testing.
-#include <openssl/evp.h>
-
#include "net/base/openssl_private_key_store.h"
+#include <openssl/evp.h>
+
#include "base/logging.h"
#include "base/memory/singleton.h"
#include "base/synchronization/lock.h"
-#include "net/base/x509_certificate.h"
namespace net {
namespace {
-class OpenSSLMemoryKeyStore : public OpenSSLPrivateKeyStore {
+// A small in-memory store for public/private key pairs held in
+// a single EVP_PKEY object. This is intentionally distinct from
+// net::SSLClientKeyStore.
+class MemoryKeyPairStore {
public:
- OpenSSLMemoryKeyStore() {}
+ MemoryKeyPairStore() {}
- static OpenSSLMemoryKeyStore* GetInstance() {
- return Singleton<OpenSSLMemoryKeyStore>::get();
+ static MemoryKeyPairStore* GetInstance() {
+ return Singleton<MemoryKeyPairStore>::get();
}
- virtual ~OpenSSLMemoryKeyStore() {
+ ~MemoryKeyPairStore() {
base::AutoLock lock(lock_);
for (std::vector<EVP_PKEY*>::iterator it = keys_.begin();
it != keys_.end(); ++it) {
@@ -33,35 +35,39 @@ class OpenSSLMemoryKeyStore : public OpenSSLPrivateKeyStore {
}
}
- virtual bool StorePrivateKey(const GURL& url, EVP_PKEY* pkey) {
+ bool StoreKeyPair(EVP_PKEY* pkey) {
CRYPTO_add(&pkey->references, 1, CRYPTO_LOCK_EVP_PKEY);
base::AutoLock lock(lock_);
keys_.push_back(pkey);
return true;
}
- virtual EVP_PKEY* FetchPrivateKey(EVP_PKEY* pkey) {
+ bool HasPrivateKey(EVP_PKEY* pkey) {
base::AutoLock lock(lock_);
for (std::vector<EVP_PKEY*>::iterator it = keys_.begin();
it != keys_.end(); ++it) {
if (EVP_PKEY_cmp(*it, pkey) == 1)
- return *it;
+ return true;
}
- return NULL;
+ return false;
}
private:
std::vector<EVP_PKEY*> keys_;
base::Lock lock_;
- DISALLOW_COPY_AND_ASSIGN(OpenSSLMemoryKeyStore);
+ DISALLOW_COPY_AND_ASSIGN(MemoryKeyPairStore);
};
} // namespace
-// static
-OpenSSLPrivateKeyStore* OpenSSLPrivateKeyStore::GetInstance() {
- return OpenSSLMemoryKeyStore::GetInstance();
+bool OpenSSLPrivateKeyStore::StoreKeyPair(const GURL& url,
+ EVP_PKEY* pkey) {
+ return MemoryKeyPairStore::GetInstance()->StoreKeyPair(pkey);
+}
+
+bool OpenSSLPrivateKeyStore::HasPrivateKey(EVP_PKEY* pub_key) {
+ return MemoryKeyPairStore::GetInstance()->HasPrivateKey(pub_key);
}
} // namespace net
« no previous file with comments | « net/base/openssl_private_key_store_android.cc ('k') | net/base/test_data_directory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698