#include "cast/common/certificate/boringssl_trust_store.h"
#include <openssl/asn1.h>
#include <openssl/evp.h>
#include <openssl/mem.h>
#include <openssl/ossl_typ.h>
#include <openssl/x509.h>
#include <openssl/x509v3.h>
#include <time.h>
#include <chrono>
#include <memory>
#include <string>
#include <string_view>
#include <utility>
#include "cast/common/certificate/boringssl_parsed_certificate.h"
#include "cast/common/certificate/boringssl_util.h"
#include "cast/common/certificate/date_time.h"
#include "util/crypto/pem_helpers.h"
#include "util/osp_logging.h"
#include "util/stringprintf.h"
namespace openscreen::cast {
namespace {
#include "cast/common/certificate/cast_root_ca_cert_der-inc.h"
#include "cast/common/certificate/eureka_root_ca_der-inc.h"
#include "cast/common/certificate/cast_crl_root_ca_cert_der-inc.h"
template <size_t N>
bssl::UniquePtr<X509> MakeTrustAnchor(const uint8_t (&data)[N]) { … }
inline bssl::UniquePtr<X509> MakeTrustAnchor(const std::vector<uint8_t>& data) { … }
constexpr static int32_t kMinRsaModulusLengthBits = …;
struct CertPathStep { … };
enum KeyUsageBits { … };
bool CertInPath(X509_NAME* name,
const std::vector<CertPathStep>& steps,
uint32_t start,
uint32_t stop) { … }
bssl::UniquePtr<BASIC_CONSTRAINTS> GetConstraints(X509* issuer) { … }
Error::Code VerifyCertTime(X509* cert, const DateTime& time) { … }
bool VerifyPublicKeyLength(EVP_PKEY* public_key) { … }
bssl::UniquePtr<ASN1_BIT_STRING> GetKeyUsage(X509* cert) { … }
Error::Code VerifyCertificateChain(const std::vector<CertPathStep>& path,
uint32_t step_index,
const DateTime& time) { … }
X509* ParseX509Der(const std::string& der) { … }
}
std::unique_ptr<TrustStore> TrustStore::CreateInstanceFromPemFile(
std::string_view file_path) { … }
std::unique_ptr<TrustStore> TrustStore::CreateInstanceForTest(
const std::vector<uint8_t>& trust_anchor_der) { … }
std::unique_ptr<TrustStore> CastTrustStore::Create() { … }
std::unique_ptr<TrustStore> CastCRLTrustStore::Create() { … }
BoringSSLTrustStore::BoringSSLTrustStore() { … }
BoringSSLTrustStore::BoringSSLTrustStore(
const std::vector<uint8_t>& trust_anchor_der) { … }
BoringSSLTrustStore::BoringSSLTrustStore(
std::vector<bssl::UniquePtr<X509>> certs)
: … { … }
BoringSSLTrustStore::~BoringSSLTrustStore() = default;
ErrorOr<BoringSSLTrustStore::CertificatePathResult>
BoringSSLTrustStore::FindCertificatePath(
const std::vector<std::string>& der_certs,
const DateTime& time) { … }
}