save last sent CHLO in client CryptoSetup

This commit is contained in:
Marten Seemann
2016-11-11 18:59:27 +07:00
parent 731dd87872
commit 992678b9d7
2 changed files with 19 additions and 0 deletions

View File

@@ -26,6 +26,7 @@ type cryptoSetupClient struct {
sno []byte
nonc []byte
diversificationNonce []byte
lastSentCHLO []byte
certManager *crypto.CertManager
}
@@ -168,6 +169,9 @@ func (h *cryptoSetupClient) sendCHLO() error {
if err != nil {
return err
}
h.lastSentCHLO = b.Bytes()
return nil
}

View File

@@ -122,6 +122,21 @@ var _ = Describe("Crypto setup", func() {
Expect(cs.cryptoStream.(*mockStream).dataWritten.Len()).To(BeNumerically(">", protocol.ClientHelloMinimumSize))
})
It("saves the last sent CHLO", func() {
// send first CHLO
err := cs.sendCHLO()
Expect(err).ToNot(HaveOccurred())
Expect(cs.cryptoStream.(*mockStream).dataWritten.Bytes()).To(Equal(cs.lastSentCHLO))
cs.cryptoStream.(*mockStream).dataWritten.Reset()
firstCHLO := cs.lastSentCHLO
// send second CHLO
cs.sno = []byte("foobar")
err = cs.sendCHLO()
Expect(err).ToNot(HaveOccurred())
Expect(cs.cryptoStream.(*mockStream).dataWritten.Bytes()).To(Equal(cs.lastSentCHLO))
Expect(cs.lastSentCHLO).ToNot(Equal(firstCHLO))
})
It("has the right values for an inchoate CHLO", func() {
tags := cs.getTags()
Expect(tags).To(HaveKey(TagSNI))