• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 The Chromium Authors
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/scoped_refptr.h"
14 #include "base/win/wincrypt_shim.h"
15 #include "crypto/scoped_capi_types.h"
16 #include "crypto/scoped_cng_types.h"
17 #include "net/base/net_export.h"
18 
19 namespace net {
20 
21 class SSLPrivateKey;
22 class X509Certificate;
23 
24 // Returns an SSLPrivateKey backed by the platform private key for
25 // |cert_context| which must correspond to |certificate|.
26 scoped_refptr<SSLPrivateKey> FetchClientCertPrivateKey(
27     const X509Certificate* certificate,
28     PCCERT_CONTEXT cert_context);
29 
30 // Returns an SSLPrivateKey backed by |prov| and |key_spec|, which must
31 // correspond to |certificate|'s public key.
32 NET_EXPORT_PRIVATE scoped_refptr<SSLPrivateKey> WrapCAPIPrivateKey(
33     const X509Certificate* certificate,
34     crypto::ScopedHCRYPTPROV prov,
35     DWORD key_spec);
36 
37 // Returns an SSLPrivateKey backed by |key|, which must correspond to
38 // |certificate|'s public key, or nullptr on error.
39 NET_EXPORT_PRIVATE scoped_refptr<SSLPrivateKey> WrapCNGPrivateKey(
40     const X509Certificate* certificate,
41     crypto::ScopedNCryptKey key);
42 
43 }  // namespace net
44 
45 #endif  // NET_SSL_SSL_PLATFORM_KEY_WIN_H_
46