forked from quic-go/quic-go
reject unencrypted SHLOs
This commit is contained in:
@@ -36,6 +36,8 @@ type cryptoSetupClient struct {
|
|||||||
clientHelloCounter int
|
clientHelloCounter int
|
||||||
serverVerified bool // has the certificate chain and the proof already been verified
|
serverVerified bool // has the certificate chain and the proof already been verified
|
||||||
keyDerivation KeyDerivationFunction
|
keyDerivation KeyDerivationFunction
|
||||||
|
|
||||||
|
receivedSecurePacket bool
|
||||||
secureAEAD crypto.AEAD
|
secureAEAD crypto.AEAD
|
||||||
forwardSecureAEAD crypto.AEAD
|
forwardSecureAEAD crypto.AEAD
|
||||||
}
|
}
|
||||||
@@ -175,6 +177,10 @@ func (h *cryptoSetupClient) handleREJMessage(cryptoData map[Tag][]byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *cryptoSetupClient) handleSHLOMessage(cryptoData map[Tag][]byte) error {
|
func (h *cryptoSetupClient) handleSHLOMessage(cryptoData map[Tag][]byte) error {
|
||||||
|
if !h.receivedSecurePacket {
|
||||||
|
return qerr.Error(qerr.CryptoEncryptionLevelIncorrect, "unencrypted SHLO message")
|
||||||
|
}
|
||||||
|
|
||||||
serverPubs, ok := cryptoData[TagPUBS]
|
serverPubs, ok := cryptoData[TagPUBS]
|
||||||
if !ok {
|
if !ok {
|
||||||
return qerr.Error(qerr.CryptoMessageParameterNotFound, "PUBS")
|
return qerr.Error(qerr.CryptoMessageParameterNotFound, "PUBS")
|
||||||
@@ -219,13 +225,18 @@ func (h *cryptoSetupClient) Open(dst, src []byte, packetNumber protocol.PacketNu
|
|||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if h.secureAEAD != nil {
|
if h.secureAEAD != nil {
|
||||||
data, err := h.secureAEAD.Open(dst, src, packetNumber, associatedData)
|
data, err := h.secureAEAD.Open(dst, src, packetNumber, associatedData)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
h.receivedSecurePacket = true
|
||||||
return data, nil
|
return data, nil
|
||||||
}
|
}
|
||||||
|
if h.receivedSecurePacket {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (&crypto.NullAEAD{}).Open(dst, src, packetNumber, associatedData)
|
return (&crypto.NullAEAD{}).Open(dst, src, packetNumber, associatedData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -342,6 +342,13 @@ var _ = Describe("Crypto setup", func() {
|
|||||||
kex: kex,
|
kex: kex,
|
||||||
}
|
}
|
||||||
cs.serverConfig = serverConfig
|
cs.serverConfig = serverConfig
|
||||||
|
cs.receivedSecurePacket = true
|
||||||
|
})
|
||||||
|
|
||||||
|
It("rejects unencrypted SHLOs", func() {
|
||||||
|
cs.receivedSecurePacket = false
|
||||||
|
err := cs.handleSHLOMessage(tagMap)
|
||||||
|
Expect(err).To(MatchError(qerr.Error(qerr.CryptoEncryptionLevelIncorrect, "unencrypted SHLO message")))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("rejects SHLOs without a PUBS", func() {
|
It("rejects SHLOs without a PUBS", func() {
|
||||||
|
|||||||
Reference in New Issue
Block a user