@@ -678,20 +678,28 @@ void JSQuicSessionListener::OnQLog(const uint8_t* data, size_t len) {
678
678
&str);
679
679
}
680
680
681
- // Generates and associates a new connection ID for this QuicSession.
681
+ // Generates a new connection ID for this QuicSession.
682
682
// ngtcp2 will call this multiple times at the start of a new connection
683
683
// in order to build a pool of available CIDs.
684
684
void RandomConnectionIDStrategy::GetNewConnectionID (
685
685
QuicSession* session,
686
686
ngtcp2_cid* cid,
687
- uint8_t * token,
688
687
size_t cidlen) {
689
688
cid->datalen = cidlen;
690
689
// cidlen shouldn't ever be zero here but just in case that
691
690
// behavior changes in ngtcp2 in the future...
692
691
if (cidlen > 0 )
693
692
EntropySource (cid->data , cidlen);
694
- EntropySource (token, NGTCP2_STATELESS_RESET_TOKENLEN);
693
+ }
694
+
695
+ void CryptoStatelessResetTokenStrategy::GetNewStatelessToken (
696
+ QuicSession* session,
697
+ ngtcp2_cid* cid,
698
+ uint8_t * token,
699
+ size_t tokenlen) {
700
+ std::array<uint8_t , NGTCP2_STATELESS_RESET_TOKENLEN>* secret =
701
+ session->Socket ()->GetSessionResetSecret ();
702
+ CHECK (GenerateResetToken (token, secret->data (), secret->size (), cid));
695
703
}
696
704
697
705
// Check required capabilities were not excluded from the OpenSSL build:
@@ -1260,6 +1268,7 @@ QuicSession::QuicSession(
1260
1268
reinterpret_cast<double*>(&recovery_stats_)) {
1261
1269
PushListener (&default_listener_);
1262
1270
SetConnectionIDStrategory (&default_connection_id_strategy_);
1271
+ SetStatelessResetTokenStrategy (&default_stateless_reset_strategy_);
1263
1272
crypto_context_.reset (new QuicCryptoContext (this , ctx, side, options));
1264
1273
application_.reset (SelectApplication (this ));
1265
1274
if (rcid != nullptr )
@@ -1634,6 +1643,12 @@ void QuicSession::SetConnectionIDStrategory(ConnectionIDStrategy* strategy) {
1634
1643
connection_id_strategy_ = strategy;
1635
1644
}
1636
1645
1646
+ void QuicSession::SetStatelessResetTokenStrategy (
1647
+ StatelessResetTokenStrategy* strategy) {
1648
+ CHECK_NOT_NULL (strategy);
1649
+ stateless_reset_strategy_ = strategy;
1650
+ }
1651
+
1637
1652
// Generates and associates a new connection ID for this QuicSession.
1638
1653
// ngtcp2 will call this multiple times at the start of a new connection
1639
1654
// in order to build a pool of available CIDs.
@@ -1643,7 +1658,16 @@ int QuicSession::GetNewConnectionID(
1643
1658
size_t cidlen) {
1644
1659
DCHECK (!IsFlagSet (QUICSESSION_FLAG_DESTROYED));
1645
1660
CHECK_NOT_NULL (connection_id_strategy_);
1646
- connection_id_strategy_->GetNewConnectionID (this , cid, token, cidlen);
1661
+ connection_id_strategy_->GetNewConnectionID (
1662
+ this ,
1663
+ cid,
1664
+ cidlen);
1665
+ stateless_reset_strategy_->GetNewStatelessToken (
1666
+ this ,
1667
+ cid,
1668
+ token,
1669
+ NGTCP2_STATELESS_RESET_TOKENLEN);
1670
+
1647
1671
AssociateCID (cid);
1648
1672
return 0 ;
1649
1673
}
0 commit comments