cast_crl.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Copyright 2016 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 COMPONENTS_CAST_CERTIFICATE_CAST_CRL_H_
  5. #define COMPONENTS_CAST_CERTIFICATE_CAST_CRL_H_
  6. #include <memory>
  7. #include <string>
  8. #include "base/compiler_specific.h"
  9. #include "base/memory/ref_counted.h"
  10. #include "base/time/time.h"
  11. #include "net/cert/pki/parsed_certificate.h"
  12. namespace net {
  13. class TrustStore;
  14. }
  15. namespace cast_certificate {
  16. // This class represents the CRL information parsed from the binary proto.
  17. class CastCRL {
  18. public:
  19. virtual ~CastCRL() {}
  20. // Verifies the revocation status of a cast device certificate given a chain
  21. // of X.509 certificates.
  22. //
  23. // Inputs:
  24. // * |trusted_chain| the chain of verified certificates, including trust
  25. // anchor.
  26. //
  27. // * |time| is the unix timestamp to use for determining if the certificate
  28. // is revoked.
  29. //
  30. // Output:
  31. // Returns true if no certificate in the chain was revoked.
  32. virtual bool CheckRevocation(const net::ParsedCertificateList& trusted_chain,
  33. const base::Time& time) const = 0;
  34. };
  35. // Parses and verifies the CRL used to verify the revocation status of
  36. // Cast device certificates, using the built-in Cast CRL trust anchors.
  37. //
  38. // Inputs:
  39. // * |crl_proto| is a serialized cast_certificate.CrlBundle proto.
  40. // * |time| is the unix timestamp to use for determining if the CRL is valid.
  41. //
  42. // Output:
  43. // Returns the CRL object if success, nullptr otherwise.
  44. std::unique_ptr<CastCRL> ParseAndVerifyCRL(const std::string& crl_proto,
  45. const base::Time& time);
  46. // This is an overloaded version of ParseAndVerifyCRL that allows
  47. // the input of a custom TrustStore.
  48. //
  49. // For production use pass |trust_store| as nullptr to use the production trust
  50. // store.
  51. std::unique_ptr<CastCRL> ParseAndVerifyCRLUsingCustomTrustStore(
  52. const std::string& crl_proto,
  53. const base::Time& time,
  54. net::TrustStore* trust_store);
  55. } // namespace cast_certificate
  56. #endif // COMPONENTS_CAST_CERTIFICATE_CAST_CRL_H_