avoid unnecessary initializations of heaper protectors on key updates

This commit is contained in:
Marten Seemann
2019-06-13 14:32:22 +08:00
parent ca8b7ddeef
commit 4e1f18e833
3 changed files with 23 additions and 11 deletions

View File

@@ -476,7 +476,10 @@ func (h *cryptoSetup) SetReadKey(suite *qtls.CipherSuite, trafficSecret []byte)
switch h.readEncLevel {
case protocol.EncryptionInitial:
h.readEncLevel = protocol.EncryptionHandshake
h.handshakeOpener = newLongHeaderOpener(createAEAD(suite, trafficSecret))
h.handshakeOpener = newLongHeaderOpener(
createAEAD(suite, trafficSecret),
createHeaderProtector(suite, trafficSecret),
)
h.logger.Debugf("Installed Handshake Read keys")
case protocol.EncryptionHandshake:
h.readEncLevel = protocol.Encryption1RTT
@@ -495,7 +498,10 @@ func (h *cryptoSetup) SetWriteKey(suite *qtls.CipherSuite, trafficSecret []byte)
switch h.writeEncLevel {
case protocol.EncryptionInitial:
h.writeEncLevel = protocol.EncryptionHandshake
h.handshakeSealer = newLongHeaderSealer(createAEAD(suite, trafficSecret))
h.handshakeSealer = newLongHeaderSealer(
createAEAD(suite, trafficSecret),
createHeaderProtector(suite, trafficSecret),
)
h.logger.Debugf("Installed Handshake Write keys")
case protocol.EncryptionHandshake:
h.writeEncLevel = protocol.Encryption1RTT