OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #ifndef NET_SSL_OPENSSL_CLIENT_KEY_STORE_H_ | 5 #ifndef NET_SSL_OPENSSL_CLIENT_KEY_STORE_H_ |
6 #define NET_SSL_OPENSSL_CLIENT_KEY_STORE_H_ | 6 #define NET_SSL_OPENSSL_CLIENT_KEY_STORE_H_ |
7 | 7 |
8 #include <openssl/evp.h> | 8 #include <openssl/evp.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 // must still call EVP_PKEY_free on them. | 66 // must still call EVP_PKEY_free on them. |
67 void AddKeyPair(EVP_PKEY* pub_key, EVP_PKEY* private_key); | 67 void AddKeyPair(EVP_PKEY* pub_key, EVP_PKEY* private_key); |
68 | 68 |
69 private: | 69 private: |
70 // KeyPair is an internal class used to hold a pair of private / public | 70 // KeyPair is an internal class used to hold a pair of private / public |
71 // EVP_PKEY objects, with appropriate ownership. | 71 // EVP_PKEY objects, with appropriate ownership. |
72 class KeyPair { | 72 class KeyPair { |
73 public: | 73 public: |
74 explicit KeyPair(EVP_PKEY* pub_key, EVP_PKEY* priv_key); | 74 explicit KeyPair(EVP_PKEY* pub_key, EVP_PKEY* priv_key); |
75 KeyPair(const KeyPair& other); | 75 KeyPair(const KeyPair& other); |
76 void operator=(const KeyPair& other); | 76 // Intentionally pass by value, in order to use the copy-and-swap idiom. |
| 77 void operator=(KeyPair other); |
| 78 void swap(KeyPair& other); |
77 ~KeyPair(); | 79 ~KeyPair(); |
78 | 80 |
79 crypto::ScopedEVP_PKEY public_key; | 81 crypto::ScopedEVP_PKEY public_key; |
80 crypto::ScopedEVP_PKEY private_key; | 82 crypto::ScopedEVP_PKEY private_key; |
81 | 83 |
82 private: | 84 private: |
83 KeyPair(); // intentionally not implemented. | 85 KeyPair(); // intentionally not implemented. |
84 }; | 86 }; |
85 | 87 |
86 // Returns the index of the keypair for |public_key|. or -1 if not found. | 88 // Returns the index of the keypair for |public_key|. or -1 if not found. |
87 int FindKeyPairIndex(EVP_PKEY* public_key); | 89 int FindKeyPairIndex(EVP_PKEY* public_key); |
88 | 90 |
89 std::vector<KeyPair> pairs_; | 91 std::vector<KeyPair> pairs_; |
90 | 92 |
91 friend struct DefaultSingletonTraits<OpenSSLClientKeyStore>; | 93 friend struct DefaultSingletonTraits<OpenSSLClientKeyStore>; |
92 | 94 |
93 DISALLOW_COPY_AND_ASSIGN(OpenSSLClientKeyStore); | 95 DISALLOW_COPY_AND_ASSIGN(OpenSSLClientKeyStore); |
94 }; | 96 }; |
95 | 97 |
96 } // namespace net | 98 } // namespace net |
97 | 99 |
98 #endif // NET_SSL_OPENSSL_CLIENT_KEY_STORE_H_ | 100 #endif // NET_SSL_OPENSSL_CLIENT_KEY_STORE_H_ |
OLD | NEW |