extract SHLO into separate method and test it

This commit is contained in:
Lucas Clemente
2016-04-17 00:31:30 +02:00
parent cbbf29e3d5
commit b5c7bcda18
2 changed files with 48 additions and 33 deletions

View File

@@ -10,7 +10,7 @@ import (
type mockKEX struct{}
func (*mockKEX) PublicKey() []byte {
return []byte("publickey")
return []byte("pubs-s")
}
func (*mockKEX) CalculateSharedKey(otherPublic []byte) ([]byte, error) {
return []byte("shared key"), nil
@@ -55,11 +55,11 @@ var _ = Describe("Crypto setup", func() {
})
It("generates REJ messages", func() {
response, err := cs.handleInchoateCHLO(sampleCHLO)
response, err := cs.handleInchoateCHLO([]byte("chlo"))
Expect(err).ToNot(HaveOccurred())
Expect(response).To(HavePrefix("REJ"))
Expect(response).To(ContainSubstring("certcompressed"))
Expect(response).To(ContainSubstring("publickey"))
Expect(response).To(ContainSubstring("pubs-s"))
Expect(signer.gotCHLO).To(BeTrue())
})
@@ -69,4 +69,16 @@ var _ = Describe("Crypto setup", func() {
Expect(err).ToNot(HaveOccurred())
Expect(signer.gotCHLO).To(BeFalse())
})
It("generates SHLO messages", func() {
response, err := cs.handleCHLO([]byte("chlo-data"), map[Tag][]byte{
TagPUBS: []byte("pubs-c"),
})
Expect(err).ToNot(HaveOccurred())
Expect(response).To(ContainSubstring("pubs-s")) // TODO: Should be new pubs
Expect(response).To(ContainSubstring(string(cs.nonce)))
Expect(response).To(ContainSubstring(string(protocol.SupportedVersionsAsTags)))
Expect(cs.secureAEAD).ToNot(BeNil())
Expect(cs.forwardSecureAEAD).ToNot(BeNil())
})
})