| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_CAST_CERTIFICATE_CAST_CRL_H_ | 5 #ifndef COMPONENTS_CAST_CERTIFICATE_CAST_CRL_H_ |
| 6 #define COMPONENTS_CAST_CERTIFICATE_CAST_CRL_H_ | 6 #define COMPONENTS_CAST_CERTIFICATE_CAST_CRL_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "net/cert/internal/parsed_certificate.h" | 15 #include "net/cert/internal/parsed_certificate.h" |
| 16 | 16 |
| 17 namespace net { | 17 namespace net { |
| 18 class TrustStore; | 18 class TrustStore; |
| 19 struct CertPath; |
| 19 } | 20 } |
| 20 | 21 |
| 21 namespace cast_certificate { | 22 namespace cast_certificate { |
| 22 | 23 |
| 23 // This class represents the CRL information parsed from the binary proto. | 24 // This class represents the CRL information parsed from the binary proto. |
| 24 class CastCRL { | 25 class CastCRL { |
| 25 public: | 26 public: |
| 26 virtual ~CastCRL(){}; | 27 virtual ~CastCRL(){}; |
| 27 | 28 |
| 28 // Verifies the revocation status of a cast device certificate given a chain | 29 // Verifies the revocation status of a cast device certificate given a chain |
| 29 // of X.509 certificates. | 30 // of X.509 certificates. |
| 30 // | 31 // |
| 31 // Inputs: | 32 // Inputs: |
| 32 // * |certs| is the verified chain of X.509 certificates: | 33 // * |chain| the chain of verified certificates, including trust anchor. |
| 33 // * |certs[0]| is the target certificate (i.e. the device certificate). | |
| 34 // * |certs[i]| is the certificate that issued certs[i-1]. | |
| 35 // * |certs.back()| is assumed to be a trusted root. | |
| 36 // | 34 // |
| 37 // * |time| is the unix timestamp to use for determining if the certificate | 35 // * |time| is the unix timestamp to use for determining if the certificate |
| 38 // is revoked. | 36 // is revoked. |
| 39 // | 37 // |
| 40 // Output: | 38 // Output: |
| 41 // Returns true if no certificate in the chain was revoked. | 39 // Returns true if no certificate in the chain was revoked. |
| 42 virtual bool CheckRevocation(const net::ParsedCertificateList& certs, | 40 virtual bool CheckRevocation(const net::CertPath& chain, |
| 43 const base::Time& time) const = 0; | 41 const base::Time& time) const = 0; |
| 44 }; | 42 }; |
| 45 | 43 |
| 46 // Parses and verifies the CRL used to verify the revocation status of | 44 // Parses and verifies the CRL used to verify the revocation status of |
| 47 // Cast device certificates, using the built-in Cast CRL trust anchors. | 45 // Cast device certificates, using the built-in Cast CRL trust anchors. |
| 48 // | 46 // |
| 49 // Inputs: | 47 // Inputs: |
| 50 // * |crl_proto| is a serialized cast_certificate.CrlBundle proto. | 48 // * |crl_proto| is a serialized cast_certificate.CrlBundle proto. |
| 51 // * |time| is the unix timestamp to use for determining if the CRL is valid. | 49 // * |time| is the unix timestamp to use for determining if the CRL is valid. |
| 52 // | 50 // |
| 53 // Output: | 51 // Output: |
| 54 // Returns the CRL object if success, nullptr otherwise. | 52 // Returns the CRL object if success, nullptr otherwise. |
| 55 std::unique_ptr<CastCRL> ParseAndVerifyCRL(const std::string& crl_proto, | 53 std::unique_ptr<CastCRL> ParseAndVerifyCRL(const std::string& crl_proto, |
| 56 const base::Time& time); | 54 const base::Time& time); |
| 57 | 55 |
| 58 // Exposed only for testing, not for use in production code. | 56 // Exposed only for testing, not for use in production code. |
| 59 // | 57 // |
| 60 // This is an overloaded version of ParseAndVerifyCRL that allows | 58 // This is an overloaded version of ParseAndVerifyCRL that allows |
| 61 // the input of a custom TrustStore. | 59 // the input of a custom TrustStore. |
| 62 std::unique_ptr<CastCRL> ParseAndVerifyCRLForTest(const std::string& crl_proto, | 60 std::unique_ptr<CastCRL> ParseAndVerifyCRLForTest(const std::string& crl_proto, |
| 63 const base::Time& time, | 61 const base::Time& time, |
| 64 net::TrustStore* trust_store); | 62 net::TrustStore* trust_store); |
| 65 | 63 |
| 66 } // namespace cast_certificate | 64 } // namespace cast_certificate |
| 67 | 65 |
| 68 #endif // COMPONENTS_CAST_CERTIFICATE_CAST_CRL_H_ | 66 #endif // COMPONENTS_CAST_CERTIFICATE_CAST_CRL_H_ |
| OLD | NEW |