ssl_platform_key_win.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. #ifndef NET_SSL_SSL_PLATFORM_KEY_WIN_H_
  5. #define NET_SSL_SSL_PLATFORM_KEY_WIN_H_
  6. #include <windows.h>
  7. // Must be after windows.h.
  8. #include <NCrypt.h>
  9. #include "base/memory/ref_counted.h"
  10. #include "base/win/wincrypt_shim.h"
  11. #include "crypto/scoped_capi_types.h"
  12. #include "net/base/net_export.h"
  13. namespace net {
  14. class SSLPrivateKey;
  15. class X509Certificate;
  16. // Returns an SSLPrivateKey backed by the platform private key for
  17. // |cert_context| which must correspond to |certificate|.
  18. scoped_refptr<SSLPrivateKey> FetchClientCertPrivateKey(
  19. const X509Certificate* certificate,
  20. PCCERT_CONTEXT cert_context);
  21. // Returns an SSLPrivateKey backed by |prov| and |key_spec|, which must
  22. // correspond to |certificate|'s public key.
  23. NET_EXPORT_PRIVATE scoped_refptr<SSLPrivateKey> WrapCAPIPrivateKey(
  24. const X509Certificate* certificate,
  25. crypto::ScopedHCRYPTPROV prov,
  26. DWORD key_spec);
  27. // Returns an SSLPrivateKey backed by |key|, which must correspond to
  28. // |certificate|'s public key, or nullptr on error. Takes ownership of |key| in
  29. // both cases.
  30. NET_EXPORT_PRIVATE scoped_refptr<SSLPrivateKey> WrapCNGPrivateKey(
  31. const X509Certificate* certificate,
  32. NCRYPT_KEY_HANDLE key);
  33. } // namespace net
  34. #endif // NET_SSL_SSL_PLATFORM_KEY_WIN_H_