#include "components/media_router/common/providers/cast/certificate/cast_cert_validator.h"
#include <stddef.h>
#include <stdint.h>
#include <algorithm>
#include <memory>
#include <string_view>
#include <utility>
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/containers/span.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/task/task_traits.h"
#include "components/media_router/common/providers/cast/certificate/cast_cert_printer.h"
#include "components/media_router/common/providers/cast/certificate/cast_cert_reader.h"
#include "components/media_router/common/providers/cast/certificate/cast_crl.h"
#include "components/media_router/common/providers/cast/certificate/cast_trust_store.h"
#include "components/media_router/common/providers/cast/certificate/switches.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_issuer_source_static.h"
#include "third_party/boringssl/src/pki/certificate_policies.h"
#include "third_party/boringssl/src/pki/common_cert_errors.h"
#include "third_party/boringssl/src/pki/input.h"
#include "third_party/boringssl/src/pki/parse_name.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"
namespace cast_certificate {
namespace {
#define RETURN_STRING_LITERAL(x) …
bssl::der::Input AudioOnlyPolicyOid() { … }
class CastPathBuilderDelegate : public bssl::SimplePathBuilderDelegate { … };
class CertVerificationContextImpl : public CertVerificationContext { … };
bool GetCommonNameFromSubject(const bssl::der::Input& subject_tlv,
std::string* common_name) { … }
void DetermineDeviceCertificatePolicy(
const bssl::CertPathBuilderResultPath* result_path,
CastDeviceCertPolicy* policy) { … }
[[nodiscard]] bool CheckTargetCertificate(
const bssl::ParsedCertificate* cert,
std::unique_ptr<CertVerificationContext>* context) { … }
bssl::ParseCertificateOptions GetCertParsingOptions() { … }
CastCertError MapToCastError(const bssl::CertPathBuilder::Result& result) { … }
}
CastCertError VerifyDeviceCert(
const std::vector<std::string>& certs,
const base::Time& time,
std::unique_ptr<CertVerificationContext>* context,
CastDeviceCertPolicy* policy,
const CastCRL* crl,
const CastCRL* fallback_crl,
CRLPolicy crl_policy) { … }
CastCertError VerifyDeviceCertUsingCustomTrustStore(
const std::vector<std::string>& certs,
const base::Time& time,
std::unique_ptr<CertVerificationContext>* context,
CastDeviceCertPolicy* policy,
const CastCRL* crl,
const CastCRL* fallback_crl,
CRLPolicy crl_policy,
bssl::TrustStore* trust_store) { … }
std::string CastCertErrorToString(CastCertError error) { … }
}