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

Side by Side Diff: net/ssl/ssl_platform_key_win.cc

Issue 1422573008: Plumbing SSLPrivateKey (//net) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing un-needed forward decl. Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « net/ssl/ssl_platform_key_task_runner.cc ('k') | net/ssl/ssl_private_key.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10 matching lines...) Expand all
21 #include "base/macros.h" 21 #include "base/macros.h"
22 #include "base/sequenced_task_runner.h" 22 #include "base/sequenced_task_runner.h"
23 #include "base/stl_util.h" 23 #include "base/stl_util.h"
24 #include "base/win/windows_version.h" 24 #include "base/win/windows_version.h"
25 #include "crypto/openssl_util.h" 25 #include "crypto/openssl_util.h"
26 #include "crypto/scoped_capi_types.h" 26 #include "crypto/scoped_capi_types.h"
27 #include "crypto/wincrypt_shim.h" 27 #include "crypto/wincrypt_shim.h"
28 #include "net/base/net_errors.h" 28 #include "net/base/net_errors.h"
29 #include "net/cert/x509_certificate.h" 29 #include "net/cert/x509_certificate.h"
30 #include "net/ssl/scoped_openssl_types.h" 30 #include "net/ssl/scoped_openssl_types.h"
31 #include "net/ssl/ssl_platform_key_task_runner.h"
31 #include "net/ssl/ssl_private_key.h" 32 #include "net/ssl/ssl_private_key.h"
32 #include "net/ssl/threaded_ssl_private_key.h" 33 #include "net/ssl/threaded_ssl_private_key.h"
33 34
34 namespace net { 35 namespace net {
35 36
36 namespace { 37 namespace {
37 38
38 using NCryptFreeObjectFunc = SECURITY_STATUS(WINAPI*)(NCRYPT_HANDLE); 39 using NCryptFreeObjectFunc = SECURITY_STATUS(WINAPI*)(NCRYPT_HANDLE);
39 using NCryptSignHashFunc = SECURITY_STATUS(WINAPI*)(NCRYPT_KEY_HANDLE, // hKey 40 using NCryptSignHashFunc = SECURITY_STATUS(WINAPI*)(NCRYPT_KEY_HANDLE, // hKey
40 VOID*, // pPaddingInfo 41 VOID*, // pPaddingInfo
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 break; 317 break;
317 default: 318 default:
318 return false; 319 return false;
319 } 320 }
320 *out_max_length = EVP_PKEY_size(key.get()); 321 *out_max_length = EVP_PKEY_size(key.get());
321 return true; 322 return true;
322 } 323 }
323 324
324 } // namespace 325 } // namespace
325 326
326 scoped_ptr<SSLPrivateKey> FetchClientCertPrivateKey( 327 scoped_refptr<SSLPrivateKey> FetchClientCertPrivateKey(
327 X509Certificate* certificate, 328 X509Certificate* certificate) {
328 scoped_refptr<base::SequencedTaskRunner> task_runner) {
329 // Rather than query the private key for metadata, extract the public key from 329 // Rather than query the private key for metadata, extract the public key from
330 // the certificate without using Windows APIs. CAPI and CNG do not 330 // the certificate without using Windows APIs. CAPI and CNG do not
331 // consistently work depending on the system. See https://crbug.com/468345. 331 // consistently work depending on the system. See https://crbug.com/468345.
332 SSLPrivateKey::Type key_type; 332 SSLPrivateKey::Type key_type;
333 size_t max_length; 333 size_t max_length;
334 if (!GetKeyInfo(certificate, &key_type, &max_length)) 334 if (!GetKeyInfo(certificate, &key_type, &max_length))
335 return nullptr; 335 return nullptr;
336 336
337 PCCERT_CONTEXT cert_context = certificate->os_cert_handle(); 337 PCCERT_CONTEXT cert_context = certificate->os_cert_handle();
338 338
(...skipping 14 matching lines...) Expand all
353 // transferred. 353 // transferred.
354 CHECK_EQ(must_free, TRUE); 354 CHECK_EQ(must_free, TRUE);
355 355
356 scoped_ptr<ThreadedSSLPrivateKey::Delegate> delegate; 356 scoped_ptr<ThreadedSSLPrivateKey::Delegate> delegate;
357 if (key_spec == CERT_NCRYPT_KEY_SPEC) { 357 if (key_spec == CERT_NCRYPT_KEY_SPEC) {
358 delegate.reset(new SSLPlatformKeyCNG(prov_or_key, key_type, max_length)); 358 delegate.reset(new SSLPlatformKeyCNG(prov_or_key, key_type, max_length));
359 } else { 359 } else {
360 DCHECK(SSLPrivateKey::Type::RSA == key_type); 360 DCHECK(SSLPrivateKey::Type::RSA == key_type);
361 delegate.reset(new SSLPlatformKeyCAPI(prov_or_key, key_spec, max_length)); 361 delegate.reset(new SSLPlatformKeyCAPI(prov_or_key, key_spec, max_length));
362 } 362 }
363 return make_scoped_ptr( 363 return make_scoped_refptr(new ThreadedSSLPrivateKey(
364 new ThreadedSSLPrivateKey(delegate.Pass(), task_runner.Pass())); 364 delegate.Pass(), GetSSLPlatformKeyTaskRunner()));
365 } 365 }
366 366
367 } // namespace net 367 } // namespace net
OLDNEW
« no previous file with comments | « net/ssl/ssl_platform_key_task_runner.cc ('k') | net/ssl/ssl_private_key.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698