OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Defines an in-memory private key store, primarily used for testing. | 5 // Defines an in-memory private key store, primarily used for testing. |
6 | 6 |
7 #include <openssl/evp.h> | 7 #include <openssl/evp.h> |
8 | 8 |
9 #include "net/base/openssl_private_key_store.h" | 9 #include "net/base/openssl_private_key_store.h" |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/openssl_util.h" | 12 #include "base/openssl_util.h" |
13 #include "base/singleton.h" | 13 #include "base/singleton.h" |
| 14 #include "base/synchronization/lock.h" |
14 #include "net/base/x509_certificate.h" | 15 #include "net/base/x509_certificate.h" |
15 | 16 |
16 namespace net { | 17 namespace net { |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 class OpenSSLMemoryKeyStore : public OpenSSLPrivateKeyStore { | 21 class OpenSSLMemoryKeyStore : public OpenSSLPrivateKeyStore { |
21 public: | 22 public: |
22 OpenSSLMemoryKeyStore() {} | 23 OpenSSLMemoryKeyStore() {} |
23 | 24 |
(...skipping 21 matching lines...) Expand all Loading... |
45 for (std::vector<EVP_PKEY*>::iterator it = keys_.begin(); | 46 for (std::vector<EVP_PKEY*>::iterator it = keys_.begin(); |
46 it != keys_.end(); ++it) { | 47 it != keys_.end(); ++it) { |
47 if (EVP_PKEY_cmp(*it, pkey) == 1) | 48 if (EVP_PKEY_cmp(*it, pkey) == 1) |
48 return *it; | 49 return *it; |
49 } | 50 } |
50 return NULL; | 51 return NULL; |
51 } | 52 } |
52 | 53 |
53 private: | 54 private: |
54 std::vector<EVP_PKEY*> keys_; | 55 std::vector<EVP_PKEY*> keys_; |
55 Lock lock_; | 56 base::Lock lock_; |
56 | 57 |
57 DISALLOW_COPY_AND_ASSIGN(OpenSSLMemoryKeyStore); | 58 DISALLOW_COPY_AND_ASSIGN(OpenSSLMemoryKeyStore); |
58 }; | 59 }; |
59 | 60 |
60 } // namespace | 61 } // namespace |
61 | 62 |
62 // static | 63 // static |
63 OpenSSLPrivateKeyStore* OpenSSLPrivateKeyStore::GetInstance() { | 64 OpenSSLPrivateKeyStore* OpenSSLPrivateKeyStore::GetInstance() { |
64 return OpenSSLMemoryKeyStore::GetInstance(); | 65 return OpenSSLMemoryKeyStore::GetInstance(); |
65 } | 66 } |
66 | 67 |
67 } // namespace net | 68 } // namespace net |
68 | 69 |
OLD | NEW |