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 #include "net/ssl/openssl_client_key_store.h" | 5 #include "net/ssl/openssl_client_key_store.h" |
6 | 6 |
7 #include <openssl/evp.h> | 7 #include <openssl/evp.h> |
8 #include <openssl/x509.h> | 8 #include <openssl/x509.h> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 | 100 |
101 // Get public key from certificate. | 101 // Get public key from certificate. |
102 crypto::ScopedEVP_PKEY pub_key(GetOpenSSLPublicKey(client_cert)); | 102 crypto::ScopedEVP_PKEY pub_key(GetOpenSSLPublicKey(client_cert)); |
103 if (!pub_key.get()) | 103 if (!pub_key.get()) |
104 return false; | 104 return false; |
105 | 105 |
106 AddKeyPair(pub_key.get(), private_key); | 106 AddKeyPair(pub_key.get(), private_key); |
107 return true; | 107 return true; |
108 } | 108 } |
109 | 109 |
110 bool OpenSSLClientKeyStore::FetchClientCertPrivateKey( | 110 crypto::ScopedEVP_PKEY OpenSSLClientKeyStore::FetchClientCertPrivateKey( |
111 const X509Certificate* client_cert, | 111 const X509Certificate* client_cert) { |
112 crypto::ScopedEVP_PKEY* private_key) { | |
113 if (!client_cert) | 112 if (!client_cert) |
114 return false; | 113 return crypto::ScopedEVP_PKEY(); |
Ryan Sleevi
2014/07/24 19:13:02
Random comment: This code prevents NRVO, because i
davidben
2014/07/24 21:02:25
(Tangentially, I wish we could spell those lines r
| |
115 | 114 |
116 crypto::ScopedEVP_PKEY pub_key(GetOpenSSLPublicKey(client_cert)); | 115 crypto::ScopedEVP_PKEY pub_key(GetOpenSSLPublicKey(client_cert)); |
117 if (!pub_key.get()) | 116 if (!pub_key.get()) |
118 return false; | 117 return crypto::ScopedEVP_PKEY(); |
119 | 118 |
120 int index = FindKeyPairIndex(pub_key.get()); | 119 int index = FindKeyPairIndex(pub_key.get()); |
121 if (index < 0) | 120 if (index < 0) |
122 return false; | 121 return crypto::ScopedEVP_PKEY(); |
123 | 122 |
124 private_key->reset(CopyEVP_PKEY(pairs_[index].private_key)); | 123 return crypto::ScopedEVP_PKEY(CopyEVP_PKEY(pairs_[index].private_key)); |
125 return true; | |
126 } | 124 } |
127 | 125 |
128 void OpenSSLClientKeyStore::Flush() { | 126 void OpenSSLClientKeyStore::Flush() { |
129 pairs_.clear(); | 127 pairs_.clear(); |
130 } | 128 } |
131 | 129 |
132 OpenSSLClientKeyStore* OpenSSLClientKeyStore::GetInstance() { | 130 OpenSSLClientKeyStore* OpenSSLClientKeyStore::GetInstance() { |
133 return Singleton<OpenSSLClientKeyStore>::get(); | 131 return Singleton<OpenSSLClientKeyStore>::get(); |
134 } | 132 } |
135 | 133 |
136 } // namespace net | 134 } // namespace net |
137 | 135 |
138 | 136 |
OLD | NEW |