From bef1b2555e87ec38cbc77bee6763527a0895ce46 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Wed, 27 Nov 2019 11:09:47 -0800 Subject: [PATCH] quic: use const refs for QuicCID passing PR-URL: https://github.com/nodejs/quic/pull/205 Reviewed-By: Anna Henningsen --- src/node_quic_session.cc | 3 +-- src/node_quic_session.h | 12 ++++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/node_quic_session.cc b/src/node_quic_session.cc index eb962ff2d6..df707902e8 100644 --- a/src/node_quic_session.cc +++ b/src/node_quic_session.cc @@ -963,8 +963,7 @@ void QuicSession::AddToSocket(QuicSocket* socket) { switch (crypto_context_->Side()) { case NGTCP2_CRYPTO_SIDE_SERVER: { - QuicCID rcid(rcid_); - socket->AssociateCID(rcid, scid); + socket->AssociateCID(QuicCID(rcid_), scid); if (pscid_.datalen) socket->AssociateCID(QuicCID(pscid_), scid); diff --git a/src/node_quic_session.h b/src/node_quic_session.h index 76587f3fa3..ea23918331 100644 --- a/src/node_quic_session.h +++ b/src/node_quic_session.h @@ -164,16 +164,23 @@ enum QuicSessionState : int { IDX_QUIC_SESSION_STATE_COUNT }; +// The QuicCryptoContext class encapsulates all of the crypto/TLS +// handshake details on behalf of a QuicSession. class QuicCryptoContext : public MemoryRetainer { public: SSL* operator*() { return ssl_.get(); } uint64_t Cancel(); + // Outgoing crypto data must be retained in memory until it is + // explicitly acknowledged. void AcknowledgeCryptoData(ngtcp2_crypto_level level, size_t datalen); + // Enables openssl's TLS tracing mechanism void EnableTrace(); + // Returns the server's prepared OCSP response for transmission. This + // is not used by client QuicSession instances. std::string GetOCSPResponse(); ngtcp2_crypto_level GetReadCryptoLevel(); @@ -184,6 +191,7 @@ class QuicCryptoContext : public MemoryRetainer { return options_ & option; } + // Emits a single keylog line to the JavaScript layer void Keylog(const char* line); int OnClientHello(); @@ -204,12 +212,15 @@ class QuicCryptoContext : public MemoryRetainer { int OnTLSStatus(); + // Receives and processes TLS handshake details int Receive( ngtcp2_crypto_level crypto_level, uint64_t offset, const uint8_t* data, size_t datalen); + // Resumes the TLS handshake following a client hello or + // OCSP callback void ResumeHandshake(); void SetOption(uint32_t option, bool on = true) { @@ -235,6 +246,7 @@ class QuicCryptoContext : public MemoryRetainer { size_t datalen); bool InitiateKeyUpdate(); + bool KeyUpdate( uint8_t* rx_key, uint8_t* rx_iv,