#include "components/media_router/common/providers/cast/channel/cast_auth_util.h"
#include <vector>
#include "base/feature_list.h"
#include "base/logging.h"
#include "base/memory/singleton.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "components/media_router/common/providers/cast/certificate/cast_cert_validator.h"
#include "components/media_router/common/providers/cast/certificate/cast_crl.h"
#include "components/media_router/common/providers/cast/channel/cast_channel_enum.h"
#include "components/media_router/common/providers/cast/channel/cast_channel_metrics.h"
#include "components/media_router/common/providers/cast/channel/cast_message_util.h"
#include "crypto/random.h"
#include "net/cert/x509_certificate.h"
#include "net/cert/x509_util.h"
#include "third_party/boringssl/src/pki/parse_values.h"
#include "third_party/boringssl/src/pki/signature_algorithm.h"
namespace cast_channel {
BASE_FEATURE(…);
BASE_FEATURE(…);
BASE_FEATURE(…);
BASE_FEATURE(…);
namespace {
const char kParseErrorPrefix[] = …;
const int kMaxSelfSignedCertLifetimeInDays = …;
const int kNonceSizeInBytes = …;
long kNonceExpirationTimeInHours = …;
cast_crypto;
AuthResult ParseAuthMessage(const CastMessage& challenge_reply,
DeviceAuthMessage* auth_message) { … }
class CastNonce { … };
AuthResult MapToAuthResult(cast_certificate::CastCertError error,
cast_certificate::CRLPolicy crl_policy) { … }
}
AuthResult::AuthResult() = default;
AuthResult::AuthResult(const std::string& error_message,
ErrorType error_type,
CastChannelFlag flag)
: … { … }
AuthResult::~AuthResult() = default;
void AuthResult::CopyFlagsFrom(const AuthResult& source) { … }
AuthResult AuthResult::CreateWithParseError(const std::string& error_message,
ErrorType error_type) { … }
AuthContext AuthContext::Create() { … }
AuthContext AuthContext::CreateForTest(const std::string& nonce_data) { … }
AuthContext::AuthContext(const std::string& nonce) : … { … }
AuthContext::~AuthContext() = default;
AuthResult AuthContext::VerifySenderNonce(
const std::string& nonce_response) const { … }
AuthResult VerifyAndMapDigestAlgorithm(
openscreen::cast::proto::HashAlgorithm response_digest_algorithm,
cast_certificate::CastDigestAlgorithm* digest_algorithm) { … }
AuthResult VerifyTLSCertificate(const net::X509Certificate& peer_cert,
std::string* peer_cert_der,
const base::Time& verification_time) { … }
AuthResult AuthenticateChallengeReply(const CastMessage& challenge_reply,
const net::X509Certificate& peer_cert,
const AuthContext& auth_context) { … }
AuthResult VerifyCredentialsImpl(const AuthResponse& response,
const std::string& signature_input,
const cast_crypto::CRLPolicy& crl_policy,
bssl::TrustStore* crl_trust_store,
const base::Time& verification_time) { … }
AuthResult VerifyCredentials(const AuthResponse& response,
const std::string& signature_input) { … }
AuthResult VerifyCredentialsForTest(const AuthResponse& response,
const std::string& signature_input,
const cast_crypto::CRLPolicy& crl_policy,
bssl::TrustStore* crl_trust_store,
const base::Time& verification_time) { … }
}