introduce a type for the stateless reset key (#3621)

This commit is contained in:
Marten Seemann 2022-11-16 16:11:25 -06:00 committed by GitHub
parent b8447041bb
commit 8d496ebb5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 35 additions and 27 deletions

View file

@ -105,7 +105,7 @@ var receiveBufferWarningOnce sync.Once
func newPacketHandlerMap(
c net.PacketConn,
connIDLen int,
statelessResetKey []byte,
statelessResetKey *StatelessResetKey,
tracer logging.Tracer,
logger utils.Logger,
) (packetHandlerManager, error) {
@ -132,11 +132,13 @@ func newPacketHandlerMap(
deleteRetiredConnsAfter: protocol.RetiredConnectionIDDeleteTimeout,
zeroRTTQueueDuration: protocol.Max0RTTQueueingDuration,
closeQueue: make(chan closePacket, 4),
statelessResetEnabled: len(statelessResetKey) > 0,
statelessResetHasher: hmac.New(sha256.New, statelessResetKey),
statelessResetEnabled: statelessResetKey != nil,
tracer: tracer,
logger: logger,
}
if m.statelessResetEnabled {
m.statelessResetHasher = hmac.New(sha256.New, statelessResetKey[:])
}
go m.listen()
go m.runCloseQueue()