improve inchoate CHLO recognition

This commit is contained in:
Lucas Clemente
2016-04-19 13:37:59 +02:00
parent 9076990cd7
commit 4e1942a76e
2 changed files with 28 additions and 4 deletions

View File

@@ -138,18 +138,30 @@ var _ = Describe("Crypto setup", func() {
It("handles long handshake", func() {
WriteHandshakeMessage(&stream.dataToRead, TagCHLO, map[Tag][]byte{})
WriteHandshakeMessage(&stream.dataToRead, TagCHLO, map[Tag][]byte{TagSCID: scfg.ID})
WriteHandshakeMessage(&stream.dataToRead, TagCHLO, map[Tag][]byte{TagSCID: scfg.ID, TagSNO: cs.nonce})
cs.HandleCryptoStream()
Expect(stream.dataWritten.Bytes()).To(HavePrefix("REJ"))
Expect(stream.dataWritten.Bytes()).To(ContainSubstring("SHLO"))
})
It("handles 0-RTT handshake", func() {
WriteHandshakeMessage(&stream.dataToRead, TagCHLO, map[Tag][]byte{TagSCID: scfg.ID})
WriteHandshakeMessage(&stream.dataToRead, TagCHLO, map[Tag][]byte{TagSCID: scfg.ID, TagSNO: cs.nonce})
cs.HandleCryptoStream()
Expect(stream.dataWritten.Bytes()).To(HavePrefix("SHLO"))
Expect(stream.dataWritten.Bytes()).ToNot(ContainSubstring("REJ"))
})
It("recognizes inchoate CHLOs missing SCID", func() {
Expect(cs.isInchoateCHLO(map[Tag][]byte{TagSNO: cs.nonce})).To(BeTrue())
})
It("recognizes inchoate CHLOs missing SNO", func() {
Expect(cs.isInchoateCHLO(map[Tag][]byte{TagSCID: scfg.ID})).To(BeTrue())
})
It("recognizes proper CHLOs", func() {
Expect(cs.isInchoateCHLO(map[Tag][]byte{TagSCID: scfg.ID, TagSNO: cs.nonce})).To(BeFalse())
})
})
Context("escalating crypto", func() {