Skip to content

Commit

Permalink
qtls: remove unneeded type alias for the tls.QUICEncryptionLevel (#4220)
Browse files Browse the repository at this point in the history
* qtls: remove unneeded type alias for the tls.QUICEncryptionLevel

* handshake: make cryptoSetup.WriteRecord private
  • Loading branch information
marten-seemann committed Dec 29, 2023
1 parent a937959 commit d6e3f32
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
14 changes: 7 additions & 7 deletions internal/handshake/crypto_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func (h *cryptoSetup) handleEvent(ev tls.QUICEvent) (done bool, err error) {
h.rejected0RTT()
return false, nil
case tls.QUICWriteData:
h.WriteRecord(ev.Level, ev.Data)
h.writeRecord(ev.Level, ev.Data)
return false, nil
case tls.QUICHandshakeDone:
h.handshakeComplete()
Expand Down Expand Up @@ -490,7 +490,7 @@ func (h *cryptoSetup) SetWriteKey(el tls.QUICEncryptionLevel, suiteID uint16, tr
h.mutex.Lock()
//nolint:exhaustive // The TLS stack doesn't export Initial keys.
switch el {
case qtls.QUICEncryptionLevelEarly:
case tls.QUICEncryptionLevelEarly:
if h.perspective == protocol.PerspectiveServer {
panic("Received 0-RTT write key for the server")
}
Expand Down Expand Up @@ -539,15 +539,15 @@ func (h *cryptoSetup) SetWriteKey(el tls.QUICEncryptionLevel, suiteID uint16, tr
}
}

// WriteRecord is called when TLS writes data
func (h *cryptoSetup) WriteRecord(encLevel qtls.QUICEncryptionLevel, p []byte) {
// writeRecord is called when TLS writes data
func (h *cryptoSetup) writeRecord(encLevel tls.QUICEncryptionLevel, p []byte) {
//nolint:exhaustive // handshake records can only be written for Initial and Handshake.
switch encLevel {
case qtls.QUICEncryptionLevelInitial:
case tls.QUICEncryptionLevelInitial:
h.events = append(h.events, Event{Kind: EventWriteInitialData, Data: p})
case qtls.QUICEncryptionLevelHandshake:
case tls.QUICEncryptionLevelHandshake:
h.events = append(h.events, Event{Kind: EventWriteHandshakeData, Data: p})
case qtls.QUICEncryptionLevelApplication:
case tls.QUICEncryptionLevelApplication:
panic("unexpected write")
default:
panic(fmt.Sprintf("unexpected write encryption level: %s", encLevel))
Expand Down
11 changes: 0 additions & 11 deletions internal/qtls/qtls.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,6 @@ import (
"github.com/quic-go/quic-go/internal/protocol"
)

type (
QUICEncryptionLevel = tls.QUICEncryptionLevel
)

const (
QUICEncryptionLevelInitial = tls.QUICEncryptionLevelInitial
QUICEncryptionLevelEarly = tls.QUICEncryptionLevelEarly
QUICEncryptionLevelHandshake = tls.QUICEncryptionLevelHandshake
QUICEncryptionLevelApplication = tls.QUICEncryptionLevelApplication
)

func SetupConfigForServer(qconf *tls.QUICConfig, _ bool, getData func() []byte, handleSessionTicket func([]byte, bool) bool) {
conf := qconf.TLSConfig

Expand Down

0 comments on commit d6e3f32

Please sign in to comment.