From 6bf42558f3c0b87aa8ffa6384c73d151f63a562f Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Fri, 5 Jul 2019 10:36:53 +0700 Subject: [PATCH] receive the encryption level for key updates from qtls --- go.mod | 2 +- go.sum | 4 ++-- internal/handshake/crypto_setup.go | 16 ++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index dac16695e..a7deda13c 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/golang/mock v1.2.0 github.com/golang/protobuf v1.3.0 github.com/marten-seemann/qpack v0.1.0 - github.com/marten-seemann/qtls v0.2.4 + github.com/marten-seemann/qtls v0.3.0 github.com/onsi/ginkgo v1.7.0 github.com/onsi/gomega v1.4.3 golang.org/x/crypto v0.0.0-20190228161510-8dd112bcdc25 diff --git a/go.sum b/go.sum index ec82effc3..c36cc1f19 100644 --- a/go.sum +++ b/go.sum @@ -12,8 +12,8 @@ github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/marten-seemann/qpack v0.1.0 h1:/0M7lkda/6mus9B8u34Asqm8ZhHAAt9Ho0vniNuVSVg= github.com/marten-seemann/qpack v0.1.0/go.mod h1:LFt1NU/Ptjip0C2CPkhimBz5CGE3WGDAUWqna+CNTrI= -github.com/marten-seemann/qtls v0.2.4 h1:mCJ6i1jAqcsm9XODrSGvXECodoAb1STta+TkxJCwCnE= -github.com/marten-seemann/qtls v0.2.4/go.mod h1:xzjG7avBwGGbdZ8dTGxlBnLArsVKLvwmjgmPuiQEcYk= +github.com/marten-seemann/qtls v0.3.0 h1:jewioNbXlqAprZpfDu8VXq/dYwu2EFgCLQjbVGNqHBw= +github.com/marten-seemann/qtls v0.3.0/go.mod h1:xzjG7avBwGGbdZ8dTGxlBnLArsVKLvwmjgmPuiQEcYk= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= diff --git a/internal/handshake/crypto_setup.go b/internal/handshake/crypto_setup.go index ef14753ab..a91891300 100644 --- a/internal/handshake/crypto_setup.go +++ b/internal/handshake/crypto_setup.go @@ -478,17 +478,17 @@ func (h *cryptoSetup) ReadHandshakeMessage() ([]byte, error) { return msg, nil } -func (h *cryptoSetup) SetReadKey(suite *qtls.CipherSuite, trafficSecret []byte) { +func (h *cryptoSetup) SetReadKey(encLevel qtls.EncryptionLevel, suite *qtls.CipherSuite, trafficSecret []byte) { h.mutex.Lock() - switch h.readEncLevel { - case protocol.EncryptionInitial: + switch encLevel { + case qtls.EncryptionHandshake: h.readEncLevel = protocol.EncryptionHandshake h.handshakeOpener = newLongHeaderOpener( createAEAD(suite, trafficSecret), createHeaderProtector(suite, trafficSecret), ) h.logger.Debugf("Installed Handshake Read keys") - case protocol.EncryptionHandshake: + case qtls.EncryptionApplication: h.readEncLevel = protocol.Encryption1RTT h.aead.SetReadKey(suite, trafficSecret) h.has1RTTOpener = true @@ -500,17 +500,17 @@ func (h *cryptoSetup) SetReadKey(suite *qtls.CipherSuite, trafficSecret []byte) h.receivedReadKey <- struct{}{} } -func (h *cryptoSetup) SetWriteKey(suite *qtls.CipherSuite, trafficSecret []byte) { +func (h *cryptoSetup) SetWriteKey(encLevel qtls.EncryptionLevel, suite *qtls.CipherSuite, trafficSecret []byte) { h.mutex.Lock() - switch h.writeEncLevel { - case protocol.EncryptionInitial: + switch encLevel { + case qtls.EncryptionHandshake: h.writeEncLevel = protocol.EncryptionHandshake h.handshakeSealer = newLongHeaderSealer( createAEAD(suite, trafficSecret), createHeaderProtector(suite, trafficSecret), ) h.logger.Debugf("Installed Handshake Write keys") - case protocol.EncryptionHandshake: + case qtls.EncryptionApplication: h.writeEncLevel = protocol.Encryption1RTT h.aead.SetWriteKey(suite, trafficSecret) h.has1RTTSealer = true