1313
1414#include < ngtcp2/ngtcp2.h>
1515#include < ngtcp2/ngtcp2_crypto.h>
16+ #include < nghttp3/nghttp3.h> // NGHTTP3_ALPN_H3
1617#include < openssl/bio.h>
1718#include < openssl/err.h>
1819#include < openssl/evp.h>
@@ -231,7 +232,6 @@ std::unique_ptr<QuicPacket> GenerateRetryPacket(
231232 cid.set_length (kScidLen );
232233
233234 size_t pktlen = tokenlen + (2 * NGTCP2_MAX_CIDLEN) + scid.length () + 8 ;
234- CHECK_LE (pktlen, NGTCP2_MAX_PKT_SIZE);
235235
236236 auto packet = QuicPacket::Create (" retry" , pktlen);
237237 ssize_t nwrite =
@@ -258,23 +258,23 @@ std::unique_ptr<QuicPacket> GenerateRetryPacket(
258258// is successful, ocid will be updated to the original connection ID encoded
259259// in the encrypted token.
260260bool InvalidRetryToken (
261- const ngtcp2_pkt_hd& hd ,
261+ const ngtcp2_vec& token ,
262262 const SocketAddress& addr,
263263 QuicCID* ocid,
264264 const uint8_t * token_secret,
265265 uint64_t verification_expiration) {
266266
267- if (hd. tokenlen < kTokenRandLen )
267+ if (token. len < kTokenRandLen )
268268 return true ;
269269
270270 ngtcp2_crypto_ctx ctx;
271271 ngtcp2_crypto_ctx_initial (&ctx);
272272
273273 size_t ivlen = ngtcp2_crypto_packet_protection_ivlen (&ctx.aead );
274274
275- size_t ciphertextlen = hd. tokenlen - kTokenRandLen ;
276- const uint8_t * ciphertext = hd. token ;
277- const uint8_t * rand_data = hd. token + ciphertextlen;
275+ size_t ciphertextlen = token. len - kTokenRandLen ;
276+ const uint8_t * ciphertext = token. base ;
277+ const uint8_t * rand_data = token. base + ciphertextlen;
278278
279279 uint8_t token_key[kCryptoTokenKeylen ];
280280 uint8_t token_iv[kCryptoTokenIvlen ];
@@ -559,10 +559,10 @@ Local<Value> GetALPNProtocol(const QuicSession& session) {
559559 QuicCryptoContext* ctx = session.crypto_context ();
560560 Environment* env = session.env ();
561561 std::string alpn = ctx->selected_alpn ();
562- // This supposed to be `NGTCP2_ALPN_H3 + 1`
562+ // This supposed to be `NGHTTP3_ALPN_H3 + 1`
563563 // Details see https://github.com/nodejs/node/issues/33959
564- if (alpn == &NGTCP2_ALPN_H3 [1 ]) {
565- return env->quic_alpn_string ();
564+ if (alpn == &NGHTTP3_ALPN_H3 [1 ]) {
565+ return env->http3_alpn_string ();
566566 } else {
567567 return ToV8Value (
568568 env->context (),
@@ -800,6 +800,7 @@ void InitializeTLS(QuicSession* session, const crypto::SSLPointer& ssl) {
800800 UNREACHABLE ();
801801 }
802802
803+ ngtcp2_conn_set_tls_native_handle (session->connection (), ssl.get ());
803804 SetTransportParams (session, ssl);
804805}
805806
@@ -859,33 +860,6 @@ void InitializeSecureContext(
859860 SSL_CTX_set_quic_method (**sc, &quic_method);
860861}
861862
862- bool DeriveAndInstallInitialKey (
863- const QuicSession& session,
864- const QuicCID& dcid) {
865- uint8_t initial_secret[NGTCP2_CRYPTO_INITIAL_SECRETLEN];
866- uint8_t rx_secret[NGTCP2_CRYPTO_INITIAL_SECRETLEN];
867- uint8_t tx_secret[NGTCP2_CRYPTO_INITIAL_SECRETLEN];
868- uint8_t rx_key[NGTCP2_CRYPTO_INITIAL_KEYLEN];
869- uint8_t tx_key[NGTCP2_CRYPTO_INITIAL_KEYLEN];
870- uint8_t rx_hp[NGTCP2_CRYPTO_INITIAL_KEYLEN];
871- uint8_t tx_hp[NGTCP2_CRYPTO_INITIAL_KEYLEN];
872- uint8_t rx_iv[NGTCP2_CRYPTO_INITIAL_IVLEN];
873- uint8_t tx_iv[NGTCP2_CRYPTO_INITIAL_IVLEN];
874- return NGTCP2_OK (ngtcp2_crypto_derive_and_install_initial_key (
875- session.connection (),
876- rx_secret,
877- tx_secret,
878- initial_secret,
879- rx_key,
880- rx_iv,
881- rx_hp,
882- tx_key,
883- tx_iv,
884- tx_hp,
885- dcid.cid (),
886- session.crypto_context ()->side ()));
887- }
888-
889863ngtcp2_crypto_level from_ossl_level (OSSL_ENCRYPTION_LEVEL ossl_level) {
890864 switch (ossl_level) {
891865 case ssl_encryption_initial:
0 commit comments