forked from quic-go/quic-go
use the CipherSuiteName function exposed by qtls
This function was recently added to the standard library TLS implementation.
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
|
"github.com/marten-seemann/qtls"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
@@ -16,7 +17,7 @@ var _ = Describe("Long Header AEAD", func() {
|
|||||||
for i := range cipherSuites {
|
for i := range cipherSuites {
|
||||||
cs := cipherSuites[i]
|
cs := cipherSuites[i]
|
||||||
|
|
||||||
Context(fmt.Sprintf("using %s", cipherSuiteName(cs.ID)), func() {
|
Context(fmt.Sprintf("using %s", qtls.CipherSuiteName(cs.ID)), func() {
|
||||||
getSealerAndOpener := func() (LongHeaderSealer, LongHeaderOpener) {
|
getSealerAndOpener := func() (LongHeaderSealer, LongHeaderOpener) {
|
||||||
key := make([]byte, 16)
|
key := make([]byte, 16)
|
||||||
hpKey := make([]byte, 16)
|
hpKey := make([]byte, 16)
|
||||||
|
|||||||
@@ -562,7 +562,7 @@ func (h *cryptoSetup) SetReadKey(encLevel qtls.EncryptionLevel, suite *qtls.Ciph
|
|||||||
newHeaderProtector(suite, trafficSecret, true),
|
newHeaderProtector(suite, trafficSecret, true),
|
||||||
)
|
)
|
||||||
h.mutex.Unlock()
|
h.mutex.Unlock()
|
||||||
h.logger.Debugf("Installed 0-RTT Read keys (using %s)", cipherSuiteName(suite.ID))
|
h.logger.Debugf("Installed 0-RTT Read keys (using %s)", qtls.CipherSuiteName(suite.ID))
|
||||||
return
|
return
|
||||||
case qtls.EncryptionHandshake:
|
case qtls.EncryptionHandshake:
|
||||||
h.readEncLevel = protocol.EncryptionHandshake
|
h.readEncLevel = protocol.EncryptionHandshake
|
||||||
@@ -572,12 +572,12 @@ func (h *cryptoSetup) SetReadKey(encLevel qtls.EncryptionLevel, suite *qtls.Ciph
|
|||||||
h.dropInitialKeys,
|
h.dropInitialKeys,
|
||||||
h.perspective,
|
h.perspective,
|
||||||
)
|
)
|
||||||
h.logger.Debugf("Installed Handshake Read keys (using %s)", cipherSuiteName(suite.ID))
|
h.logger.Debugf("Installed Handshake Read keys (using %s)", qtls.CipherSuiteName(suite.ID))
|
||||||
case qtls.EncryptionApplication:
|
case qtls.EncryptionApplication:
|
||||||
h.readEncLevel = protocol.Encryption1RTT
|
h.readEncLevel = protocol.Encryption1RTT
|
||||||
h.aead.SetReadKey(suite, trafficSecret)
|
h.aead.SetReadKey(suite, trafficSecret)
|
||||||
h.has1RTTOpener = true
|
h.has1RTTOpener = true
|
||||||
h.logger.Debugf("Installed 1-RTT Read keys (using %s)", cipherSuiteName(suite.ID))
|
h.logger.Debugf("Installed 1-RTT Read keys (using %s)", qtls.CipherSuiteName(suite.ID))
|
||||||
default:
|
default:
|
||||||
panic("unexpected read encryption level")
|
panic("unexpected read encryption level")
|
||||||
}
|
}
|
||||||
@@ -597,7 +597,7 @@ func (h *cryptoSetup) SetWriteKey(encLevel qtls.EncryptionLevel, suite *qtls.Cip
|
|||||||
newHeaderProtector(suite, trafficSecret, true),
|
newHeaderProtector(suite, trafficSecret, true),
|
||||||
)
|
)
|
||||||
h.mutex.Unlock()
|
h.mutex.Unlock()
|
||||||
h.logger.Debugf("Installed 0-RTT Write keys (using %s)", cipherSuiteName(suite.ID))
|
h.logger.Debugf("Installed 0-RTT Write keys (using %s)", qtls.CipherSuiteName(suite.ID))
|
||||||
return
|
return
|
||||||
case qtls.EncryptionHandshake:
|
case qtls.EncryptionHandshake:
|
||||||
h.writeEncLevel = protocol.EncryptionHandshake
|
h.writeEncLevel = protocol.EncryptionHandshake
|
||||||
@@ -607,12 +607,12 @@ func (h *cryptoSetup) SetWriteKey(encLevel qtls.EncryptionLevel, suite *qtls.Cip
|
|||||||
h.dropInitialKeys,
|
h.dropInitialKeys,
|
||||||
h.perspective,
|
h.perspective,
|
||||||
)
|
)
|
||||||
h.logger.Debugf("Installed Handshake Write keys (using %s)", cipherSuiteName(suite.ID))
|
h.logger.Debugf("Installed Handshake Write keys (using %s)", qtls.CipherSuiteName(suite.ID))
|
||||||
case qtls.EncryptionApplication:
|
case qtls.EncryptionApplication:
|
||||||
h.writeEncLevel = protocol.Encryption1RTT
|
h.writeEncLevel = protocol.Encryption1RTT
|
||||||
h.aead.SetWriteKey(suite, trafficSecret)
|
h.aead.SetWriteKey(suite, trafficSecret)
|
||||||
h.has1RTTSealer = true
|
h.has1RTTSealer = true
|
||||||
h.logger.Debugf("Installed 1-RTT Write keys (using %s)", cipherSuiteName(suite.ID))
|
h.logger.Debugf("Installed 1-RTT Write keys (using %s)", qtls.CipherSuiteName(suite.ID))
|
||||||
if h.zeroRTTSealer != nil {
|
if h.zeroRTTSealer != nil {
|
||||||
h.zeroRTTSealer = nil
|
h.zeroRTTSealer = nil
|
||||||
h.logger.Debugf("Dropping 0-RTT keys.")
|
h.logger.Debugf("Dropping 0-RTT keys.")
|
||||||
|
|||||||
@@ -129,16 +129,3 @@ func qtlsConfigToTLSConfig(config *qtls.Config) *tls.Config {
|
|||||||
CurvePreferences: config.CurvePreferences,
|
CurvePreferences: config.CurvePreferences,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func cipherSuiteName(id uint16) string {
|
|
||||||
switch id {
|
|
||||||
case qtls.TLS_AES_128_GCM_SHA256:
|
|
||||||
return "TLS_AES_128_GCM_SHA256"
|
|
||||||
case qtls.TLS_CHACHA20_POLY1305_SHA256:
|
|
||||||
return "TLS_CHACHA20_POLY1305_SHA256"
|
|
||||||
case qtls.TLS_AES_256_GCM_SHA384:
|
|
||||||
return "TLS_AES_256_GCM_SHA384"
|
|
||||||
default:
|
|
||||||
return "unknown cipher suite"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import (
|
|||||||
"github.com/lucas-clemente/quic-go/internal/congestion"
|
"github.com/lucas-clemente/quic-go/internal/congestion"
|
||||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
"github.com/lucas-clemente/quic-go/internal/utils"
|
"github.com/lucas-clemente/quic-go/internal/utils"
|
||||||
|
"github.com/marten-seemann/qtls"
|
||||||
|
|
||||||
. "github.com/onsi/ginkgo"
|
. "github.com/onsi/ginkgo"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
)
|
)
|
||||||
@@ -17,7 +19,7 @@ var _ = Describe("Updatable AEAD", func() {
|
|||||||
for i := range cipherSuites {
|
for i := range cipherSuites {
|
||||||
cs := cipherSuites[i]
|
cs := cipherSuites[i]
|
||||||
|
|
||||||
Context(fmt.Sprintf("using %s", cipherSuiteName(cs.ID)), func() {
|
Context(fmt.Sprintf("using %s", qtls.CipherSuiteName(cs.ID)), func() {
|
||||||
|
|
||||||
getPeers := func(rttStats *congestion.RTTStats) (client, server *updatableAEAD) {
|
getPeers := func(rttStats *congestion.RTTStats) (client, server *updatableAEAD) {
|
||||||
trafficSecret1 := make([]byte, 16)
|
trafficSecret1 := make([]byte, 16)
|
||||||
|
|||||||
Reference in New Issue
Block a user