ssl_platform_key_util.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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
  3. // found in the LICENSE file.
  4. #ifndef NET_SSL_SSL_PLATFORM_KEY_UTIL_H_
  5. #define NET_SSL_SSL_PLATFORM_KEY_UTIL_H_
  6. #include <stddef.h>
  7. #include <stdint.h>
  8. #include <vector>
  9. #include "base/containers/span.h"
  10. #include "base/memory/ref_counted.h"
  11. #include "base/task/single_thread_task_runner.h"
  12. #include "net/base/net_export.h"
  13. #include "third_party/abseil-cpp/absl/types/optional.h"
  14. #include "third_party/boringssl/src/include/openssl/base.h"
  15. namespace net {
  16. class X509Certificate;
  17. // Returns a task runner to serialize all private key operations on a single
  18. // background thread to avoid problems with buggy smartcards. Its underlying
  19. // Thread is non-joinable and as such provides
  20. // TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN semantics.
  21. NET_EXPORT_PRIVATE scoped_refptr<base::SingleThreadTaskRunner>
  22. GetSSLPlatformKeyTaskRunner();
  23. // Returns the public key of |certificate| as an |EVP_PKEY| or nullptr on error.
  24. bssl::UniquePtr<EVP_PKEY> GetClientCertPublicKey(
  25. const X509Certificate* certificate);
  26. // Determines the key type and maximum signature length of |certificate|'s
  27. // public key. |*out_type| will be set to one of the |EVP_PKEY_*| values from
  28. // BoringSSL.
  29. NET_EXPORT_PRIVATE bool GetClientCertInfo(const X509Certificate* certificate,
  30. int* out_type,
  31. size_t* out_max_length);
  32. // Returns the encoded form of |digest| for use with RSA-PSS with |pubkey|,
  33. // using |md| as the hash function and MGF-1 function, and the digest size of
  34. // |md| as the salt length.
  35. absl::optional<std::vector<uint8_t>> AddPSSPadding(
  36. EVP_PKEY* pubkey,
  37. const EVP_MD* md,
  38. base::span<const uint8_t> digest);
  39. } // namespace net
  40. #endif // NET_SSL_SSL_PLATFORM_KEY_UTIL_H_