#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/media_router/common/providers/cast/certificate/cast_crl.h"
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include "base/build_time.h"
#include "base/containers/span.h"
#include "base/logging.h"
#include "base/memory/singleton.h"
#include "base/time/time.h"
#include "components/media_router/common/providers/cast/certificate/cast_fallback_crl.h"
#include "crypto/sha2.h"
#include "net/cert/time_conversions.h"
#include "net/cert/x509_util.h"
#include "third_party/boringssl/src/include/openssl/bytestring.h"
#include "third_party/boringssl/src/include/openssl/digest.h"
#include "third_party/boringssl/src/include/openssl/evp.h"
#include "third_party/boringssl/src/pki/cert_errors.h"
#include "third_party/boringssl/src/pki/input.h"
#include "third_party/boringssl/src/pki/parse_certificate.h"
#include "third_party/boringssl/src/pki/parse_values.h"
#include "third_party/boringssl/src/pki/parsed_certificate.h"
#include "third_party/boringssl/src/pki/path_builder.h"
#include "third_party/boringssl/src/pki/simple_path_builder_delegate.h"
#include "third_party/boringssl/src/pki/trust_store_in_memory.h"
#include "third_party/boringssl/src/pki/verify_certificate_chain.h"
#include "third_party/openscreen/src/cast/common/certificate/proto/revocation.pb.h"
namespace cast_certificate {
Crl;
CrlBundle;
TbsCrl;
namespace {
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
constexpr char kFakeHashForFuzzing[] = "fake_hash_code";
#endif
enum CrlVersion { … };
#include "components/media_router/common/providers/cast/certificate/cast_crl_root_ca_cert_der-inc.h"
constexpr static int kFallbackCrlValidityInSeconds = …;
class CastCRLTrustStore { … };
bool ConvertTimeSeconds(uint64_t seconds,
bssl::der::GeneralizedTime* generalized_time) { … }
bool VerifyCRL(const Crl& crl,
const TbsCrl& tbs_crl,
const base::Time& time,
bssl::TrustStore* trust_store,
bssl::der::GeneralizedTime* overall_not_after,
bool is_fallback_crl) { … }
class CastCRLImpl : public CastCRL { … };
CastCRLImpl::CastCRLImpl(const TbsCrl& tbs_crl,
const bssl::der::GeneralizedTime& overall_not_after) { … }
CastCRLImpl::~CastCRLImpl() { … }
bool CastCRLImpl::CheckRevocation(
const bssl::ParsedCertificateList& trusted_chain,
const base::Time& time) const { … }
}
std::unique_ptr<CastCRL> ParseAndVerifyCRL(const std::string& crl_proto,
const base::Time& time,
const bool is_fallback_crl) { … }
std::unique_ptr<CastCRL> ParseAndVerifyCRLUsingCustomTrustStore(
const std::string& crl_proto,
const base::Time& time,
bssl::TrustStore* trust_store,
const bool is_fallback_crl) { … }
std::unique_ptr<CastCRL> ParseAndVerifyFallbackCRLUsingCustomTrustStore(
const base::Time& time,
bssl::TrustStore* trust_store) { … }
}