Add code path to store application states in TlsClientHandshaker.
gfe-relnote: unused code. not protected.
PiperOrigin-RevId: 306324193
Change-Id: I1aaefba94f765247c3da8d7a050c70705861faf5
diff --git a/quic/core/crypto/quic_crypto_client_config.h b/quic/core/crypto/quic_crypto_client_config.h
index 99ed31a..e83156e 100644
--- a/quic/core/crypto/quic_crypto_client_config.h
+++ b/quic/core/crypto/quic_crypto_client_config.h
@@ -30,6 +30,9 @@
class ProofVerifyDetails;
class QuicRandom;
+// A custom data that represents application-specific settings.
+// In HTTP/3 for example, it includes the encoded SETTINGS.
+using ApplicationState = std::vector<uint8_t>;
// QuicResumptionState stores the state a client needs for performing connection
// resumption.
struct QUIC_EXPORT_PRIVATE QuicResumptionState {
@@ -48,7 +51,7 @@
// should be empty. |application_state| contains serialized state that the
// client received from the server at the application layer that the client
// needs to remember when performing a 0-RTT handshake.
- std::vector<uint8_t>* application_state;
+ ApplicationState* application_state;
};
// SessionCache is an interface for managing storing and retrieving
diff --git a/quic/core/quic_crypto_client_handshaker.h b/quic/core/quic_crypto_client_handshaker.h
index 8c33ee9..ed8ddc7 100644
--- a/quic/core/quic_crypto_client_handshaker.h
+++ b/quic/core/quic_crypto_client_handshaker.h
@@ -12,6 +12,7 @@
#include "net/third_party/quiche/src/quic/core/quic_crypto_client_stream.h"
#include "net/third_party/quiche/src/quic/core/quic_server_id.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
+#include "net/third_party/quiche/src/common/platform/api/quiche_logging.h"
namespace quic {
@@ -51,6 +52,10 @@
size_t BufferSizeLimitForLevel(EncryptionLevel level) const override;
void OnOneRttPacketAcknowledged() override {}
void OnHandshakeDoneReceived() override;
+ void OnApplicationState(
+ std::unique_ptr<ApplicationState> /*application_state*/) override {
+ QUICHE_NOTREACHED();
+ }
// From QuicCryptoHandshaker
void OnHandshakeMessage(const CryptoHandshakeMessage& message) override;
diff --git a/quic/core/quic_crypto_client_stream.cc b/quic/core/quic_crypto_client_stream.cc
index 62990c1..538d828 100644
--- a/quic/core/quic_crypto_client_stream.cc
+++ b/quic/core/quic_crypto_client_stream.cc
@@ -11,6 +11,7 @@
#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h"
#include "net/third_party/quiche/src/quic/core/crypto/crypto_utils.h"
#include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h"
+#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_client_config.h"
#include "net/third_party/quiche/src/quic/core/quic_crypto_client_handshaker.h"
#include "net/third_party/quiche/src/quic/core/quic_packets.h"
#include "net/third_party/quiche/src/quic/core/quic_session.h"
@@ -115,4 +116,9 @@
handshaker_->OnHandshakeDoneReceived();
}
+void QuicCryptoClientStream::OnApplicationState(
+ std::unique_ptr<ApplicationState> application_state) {
+ handshaker_->OnApplicationState(std::move(application_state));
+}
+
} // namespace quic
diff --git a/quic/core/quic_crypto_client_stream.h b/quic/core/quic_crypto_client_stream.h
index 5af0a66..a66dcba 100644
--- a/quic/core/quic_crypto_client_stream.h
+++ b/quic/core/quic_crypto_client_stream.h
@@ -16,6 +16,7 @@
#include "net/third_party/quiche/src/quic/core/quic_crypto_stream.h"
#include "net/third_party/quiche/src/quic/core/quic_server_id.h"
#include "net/third_party/quiche/src/quic/core/quic_session.h"
+#include "net/third_party/quiche/src/quic/core/quic_versions.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
namespace quic {
@@ -58,6 +59,9 @@
// client. Does not count update messages that were received prior
// to handshake confirmation.
virtual int num_scup_messages_received() const = 0;
+
+ virtual void OnApplicationState(
+ std::unique_ptr<ApplicationState> application_state) = 0;
};
class QUIC_EXPORT_PRIVATE QuicCryptoClientStream
@@ -150,6 +154,10 @@
// Called when handshake done has been received.
virtual void OnHandshakeDoneReceived() = 0;
+
+ // Called when application state is received.
+ virtual void OnApplicationState(
+ std::unique_ptr<ApplicationState> application_state) = 0;
};
// ProofHandler is an interface that handles callbacks from the crypto
@@ -202,6 +210,9 @@
HandshakeState GetHandshakeState() const override;
size_t BufferSizeLimitForLevel(EncryptionLevel level) const override;
+ void OnApplicationState(
+ std::unique_ptr<ApplicationState> application_state) override;
+
std::string chlo_hash() const;
protected:
diff --git a/quic/core/tls_client_handshaker.cc b/quic/core/tls_client_handshaker.cc
index 6740fbd..09b9097 100644
--- a/quic/core/tls_client_handshaker.cc
+++ b/quic/core/tls_client_handshaker.cc
@@ -8,6 +8,7 @@
#include <string>
#include "third_party/boringssl/src/include/openssl/ssl.h"
+#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_client_config.h"
#include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h"
#include "net/third_party/quiche/src/quic/core/crypto/transport_parameters.h"
#include "net/third_party/quiche/src/quic/core/quic_session.h"
@@ -504,4 +505,9 @@
TlsHandshaker::WriteMessage(level, data);
}
+void TlsClientHandshaker::OnApplicationState(
+ std::unique_ptr<ApplicationState> application_state) {
+ received_application_state_ = std::move(application_state);
+}
+
} // namespace quic
diff --git a/quic/core/tls_client_handshaker.h b/quic/core/tls_client_handshaker.h
index 5dab631..6e29544 100644
--- a/quic/core/tls_client_handshaker.h
+++ b/quic/core/tls_client_handshaker.h
@@ -5,11 +5,13 @@
#ifndef QUICHE_QUIC_CORE_TLS_CLIENT_HANDSHAKER_H_
#define QUICHE_QUIC_CORE_TLS_CLIENT_HANDSHAKER_H_
+#include <cstdint>
#include <memory>
#include <string>
#include "third_party/boringssl/src/include/openssl/ssl.h"
#include "net/third_party/quiche/src/quic/core/crypto/proof_verifier.h"
+#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_client_config.h"
#include "net/third_party/quiche/src/quic/core/crypto/tls_client_connection.h"
#include "net/third_party/quiche/src/quic/core/crypto/transport_parameters.h"
#include "net/third_party/quiche/src/quic/core/quic_crypto_client_stream.h"
@@ -65,6 +67,9 @@
void WriteMessage(EncryptionLevel level,
quiche::QuicheStringPiece data) override;
+ void OnApplicationState(
+ std::unique_ptr<ApplicationState> application_state) override;
+
void AllowEmptyAlpnForTests() { allow_empty_alpn_for_tests_ = true; }
protected:
@@ -160,6 +165,7 @@
TlsClientConnection tls_connection_;
std::unique_ptr<TransportParameters> received_transport_params_ = nullptr;
+ std::unique_ptr<ApplicationState> received_application_state_ = nullptr;
};
} // namespace quic