1 // Copyright 2017 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef NET_SSL_SSL_PLATFORM_KEY_WIN_H_ 6 #define NET_SSL_SSL_PLATFORM_KEY_WIN_H_ 7 8 #include <windows.h> 9 10 // Must be after windows.h. 11 #include <NCrypt.h> 12 13 #include "base/memory/ref_counted.h" 14 #include "base/win/wincrypt_shim.h" 15 #include "net/base/net_export.h" 16 17 namespace net { 18 19 class SSLPrivateKey; 20 class X509Certificate; 21 22 // Returns an SSLPrivateKey backed by the platform private key for 23 // |cert_context| which must correspond to |certificate|. 24 scoped_refptr<SSLPrivateKey> FetchClientCertPrivateKey( 25 const X509Certificate* certificate, 26 PCCERT_CONTEXT cert_context); 27 28 // Returns an SSLPrivateKey backed by |prov| and |key_spec|, which must 29 // correspond to |certificate|'s public key. Takes ownership of |prov|. 30 NET_EXPORT_PRIVATE scoped_refptr<SSLPrivateKey> WrapCAPIPrivateKey( 31 const X509Certificate* certificate, 32 HCRYPTPROV prov, 33 DWORD key_spec); 34 35 // Returns an SSLPrivateKey backed by |key|, which must correspond to 36 // |certificate|'s public key, or nullptr on error. Takes ownership of |key| in 37 // both cases. 38 NET_EXPORT_PRIVATE scoped_refptr<SSLPrivateKey> WrapCNGPrivateKey( 39 const X509Certificate* certificate, 40 NCRYPT_KEY_HANDLE key); 41 42 } // namespace net 43 44 #endif // NET_SSL_SSL_PLATFORM_KEY_WIN_H_ 45