| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ssl_platform_key.h" | 5 #include "net/ssl/ssl_platform_key.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <NCrypt.h> | 8 #include <NCrypt.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 NCRYPT_KEY_HANDLE key_; | 241 NCRYPT_KEY_HANDLE key_; |
| 242 SSLPrivateKey::Type type_; | 242 SSLPrivateKey::Type type_; |
| 243 size_t max_length_; | 243 size_t max_length_; |
| 244 | 244 |
| 245 DISALLOW_COPY_AND_ASSIGN(SSLPlatformKeyCNG); | 245 DISALLOW_COPY_AND_ASSIGN(SSLPlatformKeyCNG); |
| 246 }; | 246 }; |
| 247 | 247 |
| 248 } // namespace | 248 } // namespace |
| 249 | 249 |
| 250 scoped_refptr<SSLPrivateKey> FetchClientCertPrivateKey( | 250 scoped_refptr<SSLPrivateKey> FetchClientCertPrivateKey( |
| 251 X509Certificate* certificate) { | 251 const X509Certificate* certificate) { |
| 252 // Rather than query the private key for metadata, extract the public key from | 252 // Rather than query the private key for metadata, extract the public key from |
| 253 // the certificate without using Windows APIs. CAPI and CNG do not | 253 // the certificate without using Windows APIs. CAPI and CNG do not |
| 254 // consistently work depending on the system. See https://crbug.com/468345. | 254 // consistently work depending on the system. See https://crbug.com/468345. |
| 255 SSLPrivateKey::Type key_type; | 255 SSLPrivateKey::Type key_type; |
| 256 size_t max_length; | 256 size_t max_length; |
| 257 if (!GetClientCertInfo(certificate, &key_type, &max_length)) | 257 if (!GetClientCertInfo(certificate, &key_type, &max_length)) |
| 258 return nullptr; | 258 return nullptr; |
| 259 | 259 |
| 260 PCCERT_CONTEXT cert_context = certificate->os_cert_handle(); | 260 PCCERT_CONTEXT cert_context = certificate->os_cert_handle(); |
| 261 | 261 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 279 delegate.reset(new SSLPlatformKeyCNG(prov_or_key, key_type, max_length)); | 279 delegate.reset(new SSLPlatformKeyCNG(prov_or_key, key_type, max_length)); |
| 280 } else { | 280 } else { |
| 281 DCHECK(SSLPrivateKey::Type::RSA == key_type); | 281 DCHECK(SSLPrivateKey::Type::RSA == key_type); |
| 282 delegate.reset(new SSLPlatformKeyCAPI(prov_or_key, key_spec, max_length)); | 282 delegate.reset(new SSLPlatformKeyCAPI(prov_or_key, key_spec, max_length)); |
| 283 } | 283 } |
| 284 return make_scoped_refptr(new ThreadedSSLPrivateKey( | 284 return make_scoped_refptr(new ThreadedSSLPrivateKey( |
| 285 std::move(delegate), GetSSLPlatformKeyTaskRunner())); | 285 std::move(delegate), GetSSLPlatformKeyTaskRunner())); |
| 286 } | 286 } |
| 287 | 287 |
| 288 } // namespace net | 288 } // namespace net |
| OLD | NEW |