forked from quic-go/quic-go
@@ -258,6 +258,11 @@ func (h *CryptoSetup) handleCHLO(sni string, data []byte, cryptoData map[Tag][]b
|
|||||||
return nil, qerr.Error(qerr.CryptoNoSupport, "Unsupported AEAD or KEXS")
|
return nil, qerr.Error(qerr.CryptoNoSupport, "Unsupported AEAD or KEXS")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kexs := cryptoData[TagKEXS]
|
||||||
|
if !bytes.Equal(kexs, []byte("C255")) {
|
||||||
|
return nil, qerr.Error(qerr.CryptoNoSupport, "Unsupported AEAD or KEXS")
|
||||||
|
}
|
||||||
|
|
||||||
h.secureAEAD, err = h.keyDerivation(
|
h.secureAEAD, err = h.keyDerivation(
|
||||||
false,
|
false,
|
||||||
sharedSecret,
|
sharedSecret,
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ var _ = Describe("Crypto setup", func() {
|
|||||||
ip net.IP
|
ip net.IP
|
||||||
validSTK []byte
|
validSTK []byte
|
||||||
aead []byte
|
aead []byte
|
||||||
|
kexs []byte
|
||||||
)
|
)
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
@@ -160,6 +161,7 @@ var _ = Describe("Crypto setup", func() {
|
|||||||
scfg, err = NewServerConfig(kex, signer)
|
scfg, err = NewServerConfig(kex, signer)
|
||||||
nonce32 = make([]byte, 32)
|
nonce32 = make([]byte, 32)
|
||||||
aead = []byte("AESG")
|
aead = []byte("AESG")
|
||||||
|
kexs = []byte("C255")
|
||||||
copy(nonce32[4:12], scfg.obit) // set the OBIT value at the right position
|
copy(nonce32[4:12], scfg.obit) // set the OBIT value at the right position
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
scfg.stkSource = &mockStkSource{}
|
scfg.stkSource = &mockStkSource{}
|
||||||
@@ -232,6 +234,7 @@ var _ = Describe("Crypto setup", func() {
|
|||||||
TagPUBS: []byte("pubs-c"),
|
TagPUBS: []byte("pubs-c"),
|
||||||
TagNONC: nonce32,
|
TagNONC: nonce32,
|
||||||
TagAEAD: aead,
|
TagAEAD: aead,
|
||||||
|
TagKEXS: kexs,
|
||||||
})
|
})
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(response).To(HavePrefix("SHLO"))
|
Expect(response).To(HavePrefix("SHLO"))
|
||||||
@@ -258,6 +261,7 @@ var _ = Describe("Crypto setup", func() {
|
|||||||
TagNONC: nonce32,
|
TagNONC: nonce32,
|
||||||
TagSTK: validSTK,
|
TagSTK: validSTK,
|
||||||
TagAEAD: aead,
|
TagAEAD: aead,
|
||||||
|
TagKEXS: kexs,
|
||||||
TagPUBS: nil,
|
TagPUBS: nil,
|
||||||
})
|
})
|
||||||
err := cs.HandleCryptoStream()
|
err := cs.HandleCryptoStream()
|
||||||
@@ -299,6 +303,7 @@ var _ = Describe("Crypto setup", func() {
|
|||||||
TagNONC: nonce32,
|
TagNONC: nonce32,
|
||||||
TagSTK: validSTK,
|
TagSTK: validSTK,
|
||||||
TagAEAD: aead,
|
TagAEAD: aead,
|
||||||
|
TagKEXS: kexs,
|
||||||
TagPUBS: nil,
|
TagPUBS: nil,
|
||||||
})
|
})
|
||||||
err := cs.HandleCryptoStream()
|
err := cs.HandleCryptoStream()
|
||||||
@@ -343,6 +348,7 @@ var _ = Describe("Crypto setup", func() {
|
|||||||
TagPUBS: []byte("pubs"),
|
TagPUBS: []byte("pubs"),
|
||||||
TagNONC: nonce32,
|
TagNONC: nonce32,
|
||||||
TagSTK: validSTK,
|
TagSTK: validSTK,
|
||||||
|
TagKEXS: kexs,
|
||||||
})
|
})
|
||||||
err := cs.HandleCryptoStream()
|
err := cs.HandleCryptoStream()
|
||||||
Expect(err).To(MatchError(qerr.Error(qerr.CryptoNoSupport, "Unsupported AEAD or KEXS")))
|
Expect(err).To(MatchError(qerr.Error(qerr.CryptoNoSupport, "Unsupported AEAD or KEXS")))
|
||||||
@@ -356,6 +362,34 @@ var _ = Describe("Crypto setup", func() {
|
|||||||
TagNONC: nonce32,
|
TagNONC: nonce32,
|
||||||
TagSTK: validSTK,
|
TagSTK: validSTK,
|
||||||
TagAEAD: []byte("wrong"),
|
TagAEAD: []byte("wrong"),
|
||||||
|
TagKEXS: kexs,
|
||||||
|
})
|
||||||
|
err := cs.HandleCryptoStream()
|
||||||
|
Expect(err).To(MatchError(qerr.Error(qerr.CryptoNoSupport, "Unsupported AEAD or KEXS")))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("errors if the KEXS tag is missing", func() {
|
||||||
|
WriteHandshakeMessage(&stream.dataToRead, TagCHLO, map[Tag][]byte{
|
||||||
|
TagSCID: scfg.ID,
|
||||||
|
TagSNI: []byte("quic.clemente.io"),
|
||||||
|
TagPUBS: []byte("pubs"),
|
||||||
|
TagNONC: nonce32,
|
||||||
|
TagSTK: validSTK,
|
||||||
|
TagAEAD: aead,
|
||||||
|
})
|
||||||
|
err := cs.HandleCryptoStream()
|
||||||
|
Expect(err).To(MatchError(qerr.Error(qerr.CryptoNoSupport, "Unsupported AEAD or KEXS")))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("errors if the KEXS tag has the wrong value", func() {
|
||||||
|
WriteHandshakeMessage(&stream.dataToRead, TagCHLO, map[Tag][]byte{
|
||||||
|
TagSCID: scfg.ID,
|
||||||
|
TagSNI: []byte("quic.clemente.io"),
|
||||||
|
TagPUBS: []byte("pubs"),
|
||||||
|
TagNONC: nonce32,
|
||||||
|
TagSTK: validSTK,
|
||||||
|
TagAEAD: aead,
|
||||||
|
TagKEXS: []byte("wrong"),
|
||||||
})
|
})
|
||||||
err := cs.HandleCryptoStream()
|
err := cs.HandleCryptoStream()
|
||||||
Expect(err).To(MatchError(qerr.Error(qerr.CryptoNoSupport, "Unsupported AEAD or KEXS")))
|
Expect(err).To(MatchError(qerr.Error(qerr.CryptoNoSupport, "Unsupported AEAD or KEXS")))
|
||||||
@@ -398,6 +432,7 @@ var _ = Describe("Crypto setup", func() {
|
|||||||
TagPUBS: []byte("pubs-c"),
|
TagPUBS: []byte("pubs-c"),
|
||||||
TagNONC: nonce32,
|
TagNONC: nonce32,
|
||||||
TagAEAD: aead,
|
TagAEAD: aead,
|
||||||
|
TagKEXS: kexs,
|
||||||
})
|
})
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user