Commit f044c1b9 authored by Ryan Hamilton's avatar Ryan Hamilton Committed by Commit Bot

Use a std::unique_ptr<ProofVerifyContext> instead of a raw pointer in the...

Use a std::unique_ptr<ProofVerifyContext> instead of a raw pointer in the QuicCryptoClientStream constructor.

Merge internal change: 203836768

Change-Id: I80e3cefd998af739fd4baa0a6df79034da407613
Reviewed-on: https://chromium-review.googlesource.com/1147492Reviewed-by: default avatarZhongyi Shi <zhongyi@chromium.org>
Commit-Queue: Ryan Hamilton <rch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577348}
parent 71c6fdf9
...@@ -109,9 +109,9 @@ std::unique_ptr<quic::ProofVerifier> ProofVerifierForTesting() { ...@@ -109,9 +109,9 @@ std::unique_ptr<quic::ProofVerifier> ProofVerifierForTesting() {
std::make_unique<net::DefaultCTPolicyEnforcer>(), "quic-root.pem"); std::make_unique<net::DefaultCTPolicyEnforcer>(), "quic-root.pem");
} }
quic::ProofVerifyContext* ProofVerifyContextForTesting() { std::unique_ptr<quic::ProofVerifyContext> ProofVerifyContextForTesting() {
return new net::ProofVerifyContextChromium(/*cert_verify_flags=*/0, return std::make_unique<net::ProofVerifyContextChromium>(
net::NetLogWithSource()); /*cert_verify_flags=*/0, net::NetLogWithSource());
} }
} // namespace crypto_test_utils } // namespace crypto_test_utils
......
...@@ -21,7 +21,7 @@ class DefaultCryptoStreamFactory : public QuicCryptoClientStreamFactory { ...@@ -21,7 +21,7 @@ class DefaultCryptoStreamFactory : public QuicCryptoClientStreamFactory {
std::unique_ptr<quic::ProofVerifyContext> proof_verify_context, std::unique_ptr<quic::ProofVerifyContext> proof_verify_context,
quic::QuicCryptoClientConfig* crypto_config) override { quic::QuicCryptoClientConfig* crypto_config) override {
return new quic::QuicCryptoClientStream(server_id, session, return new quic::QuicCryptoClientStream(server_id, session,
proof_verify_context.release(), std::move(proof_verify_context),
crypto_config, session); crypto_config, session);
} }
}; };
......
...@@ -77,7 +77,7 @@ QuicCryptoClientHandshaker::QuicCryptoClientHandshaker( ...@@ -77,7 +77,7 @@ QuicCryptoClientHandshaker::QuicCryptoClientHandshaker(
const QuicServerId& server_id, const QuicServerId& server_id,
QuicCryptoClientStream* stream, QuicCryptoClientStream* stream,
QuicSession* session, QuicSession* session,
ProofVerifyContext* verify_context, std::unique_ptr<ProofVerifyContext> verify_context,
QuicCryptoClientConfig* crypto_config, QuicCryptoClientConfig* crypto_config,
QuicCryptoClientStream::ProofHandler* proof_handler) QuicCryptoClientStream::ProofHandler* proof_handler)
: QuicCryptoHandshaker(stream, session), : QuicCryptoHandshaker(stream, session),
...@@ -91,7 +91,7 @@ QuicCryptoClientHandshaker::QuicCryptoClientHandshaker( ...@@ -91,7 +91,7 @@ QuicCryptoClientHandshaker::QuicCryptoClientHandshaker(
channel_id_sent_(false), channel_id_sent_(false),
channel_id_source_callback_run_(false), channel_id_source_callback_run_(false),
channel_id_source_callback_(nullptr), channel_id_source_callback_(nullptr),
verify_context_(verify_context), verify_context_(std::move(verify_context)),
proof_verify_callback_(nullptr), proof_verify_callback_(nullptr),
proof_handler_(proof_handler), proof_handler_(proof_handler),
verify_ok_(false), verify_ok_(false),
......
...@@ -29,7 +29,7 @@ class QUIC_EXPORT_PRIVATE QuicCryptoClientHandshaker ...@@ -29,7 +29,7 @@ class QUIC_EXPORT_PRIVATE QuicCryptoClientHandshaker
const QuicServerId& server_id, const QuicServerId& server_id,
QuicCryptoClientStream* stream, QuicCryptoClientStream* stream,
QuicSession* session, QuicSession* session,
ProofVerifyContext* verify_context, std::unique_ptr<ProofVerifyContext> verify_context,
QuicCryptoClientConfig* crypto_config, QuicCryptoClientConfig* crypto_config,
QuicCryptoClientStream::ProofHandler* proof_handler); QuicCryptoClientStream::ProofHandler* proof_handler);
......
...@@ -30,7 +30,7 @@ QuicCryptoClientStreamBase::QuicCryptoClientStreamBase(QuicSession* session) ...@@ -30,7 +30,7 @@ QuicCryptoClientStreamBase::QuicCryptoClientStreamBase(QuicSession* session)
QuicCryptoClientStream::QuicCryptoClientStream( QuicCryptoClientStream::QuicCryptoClientStream(
const QuicServerId& server_id, const QuicServerId& server_id,
QuicSession* session, QuicSession* session,
ProofVerifyContext* verify_context, std::unique_ptr<ProofVerifyContext> verify_context,
QuicCryptoClientConfig* crypto_config, QuicCryptoClientConfig* crypto_config,
ProofHandler* proof_handler) ProofHandler* proof_handler)
: QuicCryptoClientStreamBase(session) { : QuicCryptoClientStreamBase(session) {
...@@ -38,13 +38,13 @@ QuicCryptoClientStream::QuicCryptoClientStream( ...@@ -38,13 +38,13 @@ QuicCryptoClientStream::QuicCryptoClientStream(
switch (session->connection()->version().handshake_protocol) { switch (session->connection()->version().handshake_protocol) {
case PROTOCOL_QUIC_CRYPTO: case PROTOCOL_QUIC_CRYPTO:
handshaker_ = QuicMakeUnique<QuicCryptoClientHandshaker>( handshaker_ = QuicMakeUnique<QuicCryptoClientHandshaker>(
server_id, this, session, verify_context, crypto_config, server_id, this, session, std::move(verify_context), crypto_config,
proof_handler); proof_handler);
break; break;
case PROTOCOL_TLS1_3: case PROTOCOL_TLS1_3:
handshaker_ = QuicMakeUnique<TlsClientHandshaker>( handshaker_ = QuicMakeUnique<TlsClientHandshaker>(
this, session, server_id, crypto_config->proof_verifier(), this, session, server_id, crypto_config->proof_verifier(),
crypto_config->ssl_ctx(), verify_context, crypto_config->ssl_ctx(), std::move(verify_context),
crypto_config->user_agent_id()); crypto_config->user_agent_id());
break; break;
case PROTOCOL_UNSUPPORTED: case PROTOCOL_UNSUPPORTED:
......
...@@ -131,7 +131,7 @@ class QUIC_EXPORT_PRIVATE QuicCryptoClientStream ...@@ -131,7 +131,7 @@ class QUIC_EXPORT_PRIVATE QuicCryptoClientStream
QuicCryptoClientStream(const QuicServerId& server_id, QuicCryptoClientStream(const QuicServerId& server_id,
QuicSession* session, QuicSession* session,
ProofVerifyContext* verify_context, std::unique_ptr<ProofVerifyContext> verify_context,
QuicCryptoClientConfig* crypto_config, QuicCryptoClientConfig* crypto_config,
ProofHandler* proof_handler); ProofHandler* proof_handler);
......
...@@ -131,8 +131,8 @@ std::unique_ptr<QuicCryptoClientStreamBase> ...@@ -131,8 +131,8 @@ std::unique_ptr<QuicCryptoClientStreamBase>
QuicSpdyClientSession::CreateQuicCryptoStream() { QuicSpdyClientSession::CreateQuicCryptoStream() {
return QuicMakeUnique<QuicCryptoClientStream>( return QuicMakeUnique<QuicCryptoClientStream>(
server_id_, this, server_id_, this,
crypto_config_->proof_verifier()->CreateDefaultContext().release(), crypto_config_->proof_verifier()->CreateDefaultContext(), crypto_config_,
crypto_config_, this); this);
} }
bool QuicSpdyClientSession::IsAuthorized(const QuicString& authority) { bool QuicSpdyClientSession::IsAuthorized(const QuicString& authority) {
......
...@@ -37,17 +37,18 @@ void TlsClientHandshaker::ProofVerifierCallbackImpl::Cancel() { ...@@ -37,17 +37,18 @@ void TlsClientHandshaker::ProofVerifierCallbackImpl::Cancel() {
parent_ = nullptr; parent_ = nullptr;
} }
TlsClientHandshaker::TlsClientHandshaker(QuicCryptoStream* stream, TlsClientHandshaker::TlsClientHandshaker(
QuicCryptoStream* stream,
QuicSession* session, QuicSession* session,
const QuicServerId& server_id, const QuicServerId& server_id,
ProofVerifier* proof_verifier, ProofVerifier* proof_verifier,
SSL_CTX* ssl_ctx, SSL_CTX* ssl_ctx,
ProofVerifyContext* verify_context, std::unique_ptr<ProofVerifyContext> verify_context,
const QuicString& user_agent_id) const QuicString& user_agent_id)
: TlsHandshaker(stream, session, ssl_ctx), : TlsHandshaker(stream, session, ssl_ctx),
server_id_(server_id), server_id_(server_id),
proof_verifier_(proof_verifier), proof_verifier_(proof_verifier),
verify_context_(verify_context), verify_context_(std::move(verify_context)),
user_agent_id_(user_agent_id), user_agent_id_(user_agent_id),
crypto_negotiated_params_(new QuicCryptoNegotiatedParameters) {} crypto_negotiated_params_(new QuicCryptoNegotiatedParameters) {}
......
...@@ -27,8 +27,7 @@ class QUIC_EXPORT_PRIVATE TlsClientHandshaker ...@@ -27,8 +27,7 @@ class QUIC_EXPORT_PRIVATE TlsClientHandshaker
const QuicServerId& server_id, const QuicServerId& server_id,
ProofVerifier* proof_verifier, ProofVerifier* proof_verifier,
SSL_CTX* ssl_ctx, SSL_CTX* ssl_ctx,
// Takes ownership of |verify_context|. std::unique_ptr<ProofVerifyContext> verify_context,
ProofVerifyContext* verify_context,
const QuicString& user_agent_id); const QuicString& user_agent_id);
~TlsClientHandshaker() override; ~TlsClientHandshaker() override;
......
...@@ -294,8 +294,9 @@ void QuartcSession::StartCryptoHandshake() { ...@@ -294,8 +294,9 @@ void QuartcSession::StartCryptoHandshake() {
if (perspective_ == Perspective::IS_CLIENT) { if (perspective_ == Perspective::IS_CLIENT) {
QuicServerId server_id(unique_remote_server_id_, kQuicServerPort, QuicServerId server_id(unique_remote_server_id_, kQuicServerPort,
/*privacy_mode_enabled=*/false); /*privacy_mode_enabled=*/false);
QuicCryptoClientStream* crypto_stream = QuicCryptoClientStream* crypto_stream = new QuicCryptoClientStream(
new QuicCryptoClientStream(server_id, this, new ProofVerifyContext(), server_id, this,
quic_crypto_client_config_->proof_verifier()->CreateDefaultContext(),
quic_crypto_client_config_.get(), this); quic_crypto_client_config_.get(), this);
crypto_stream_.reset(crypto_stream); crypto_stream_.reset(crypto_stream);
QuicSession::Initialize(); QuicSession::Initialize();
......
...@@ -189,7 +189,7 @@ uint64_t LeafCertHashForTesting(); ...@@ -189,7 +189,7 @@ uint64_t LeafCertHashForTesting();
// Returns a |ProofVerifyContext| that must be used with the verifier // Returns a |ProofVerifyContext| that must be used with the verifier
// returned by |ProofVerifierForTesting|. // returned by |ProofVerifierForTesting|.
ProofVerifyContext* ProofVerifyContextForTesting(); std::unique_ptr<ProofVerifyContext> ProofVerifyContextForTesting();
// MockCommonCertSets returns a CommonCertSets that contains a single set with // MockCommonCertSets returns a CommonCertSets that contains a single set with
// hash |hash|, consisting of the certificate |cert| at index |index|. // hash |hash|, consisting of the certificate |cert| at index |index|.
......
...@@ -22,7 +22,7 @@ namespace quic { ...@@ -22,7 +22,7 @@ namespace quic {
MockCryptoClientStream::MockCryptoClientStream( MockCryptoClientStream::MockCryptoClientStream(
const QuicServerId& server_id, const QuicServerId& server_id,
QuicSpdyClientSessionBase* session, QuicSpdyClientSessionBase* session,
ProofVerifyContext* verify_context, std::unique_ptr<ProofVerifyContext> verify_context,
const QuicConfig& config, const QuicConfig& config,
QuicCryptoClientConfig* crypto_config, QuicCryptoClientConfig* crypto_config,
HandshakeMode handshake_mode, HandshakeMode handshake_mode,
...@@ -30,7 +30,7 @@ MockCryptoClientStream::MockCryptoClientStream( ...@@ -30,7 +30,7 @@ MockCryptoClientStream::MockCryptoClientStream(
bool use_mock_crypter) bool use_mock_crypter)
: QuicCryptoClientStream(server_id, : QuicCryptoClientStream(server_id,
session, session,
verify_context, std::move(verify_context),
crypto_config, crypto_config,
session), session),
QuicCryptoHandshaker(this, session), QuicCryptoHandshaker(this, session),
......
...@@ -48,7 +48,7 @@ class MockCryptoClientStream : public QuicCryptoClientStream, ...@@ -48,7 +48,7 @@ class MockCryptoClientStream : public QuicCryptoClientStream,
MockCryptoClientStream( MockCryptoClientStream(
const QuicServerId& server_id, const QuicServerId& server_id,
QuicSpdyClientSessionBase* session, QuicSpdyClientSessionBase* session,
ProofVerifyContext* verify_context, std::unique_ptr<ProofVerifyContext> verify_context,
const QuicConfig& config, const QuicConfig& config,
QuicCryptoClientConfig* crypto_config, QuicCryptoClientConfig* crypto_config,
HandshakeMode handshake_mode, HandshakeMode handshake_mode,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment