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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 if (!CryptAcquireCertificatePrivateKey(cert_context, flags, nullptr, | 344 if (!CryptAcquireCertificatePrivateKey(cert_context, flags, nullptr, |
345 &prov_or_key, &key_spec, &must_free)) { | 345 &prov_or_key, &key_spec, &must_free)) { |
346 PLOG(WARNING) << "Could not acquire private key"; | 346 PLOG(WARNING) << "Could not acquire private key"; |
347 return nullptr; | 347 return nullptr; |
348 } | 348 } |
349 | 349 |
350 // Should never get a cached handle back - ownership must always be | 350 // Should never get a cached handle back - ownership must always be |
351 // transferred. | 351 // transferred. |
352 CHECK_EQ(must_free, TRUE); | 352 CHECK_EQ(must_free, TRUE); |
353 | 353 |
354 scoped_ptr<ThreadedSSLPrivateKey::Delegate> delegate; | 354 std::unique_ptr<ThreadedSSLPrivateKey::Delegate> delegate; |
355 if (key_spec == CERT_NCRYPT_KEY_SPEC) { | 355 if (key_spec == CERT_NCRYPT_KEY_SPEC) { |
356 delegate.reset(new SSLPlatformKeyCNG(prov_or_key, key_type, max_length)); | 356 delegate.reset(new SSLPlatformKeyCNG(prov_or_key, key_type, max_length)); |
357 } else { | 357 } else { |
358 DCHECK(SSLPrivateKey::Type::RSA == key_type); | 358 DCHECK(SSLPrivateKey::Type::RSA == key_type); |
359 delegate.reset(new SSLPlatformKeyCAPI(prov_or_key, key_spec, max_length)); | 359 delegate.reset(new SSLPlatformKeyCAPI(prov_or_key, key_spec, max_length)); |
360 } | 360 } |
361 return make_scoped_refptr(new ThreadedSSLPrivateKey( | 361 return make_scoped_refptr(new ThreadedSSLPrivateKey( |
362 std::move(delegate), GetSSLPlatformKeyTaskRunner())); | 362 std::move(delegate), GetSSLPlatformKeyTaskRunner())); |
363 } | 363 } |
364 | 364 |
365 } // namespace net | 365 } // namespace net |
OLD | NEW |