include source address token, server config id and server nonce in CHLO

This commit is contained in:
Marten Seemann
2016-11-10 22:30:27 +07:00
parent 0b8c883b71
commit 39e7591756
2 changed files with 38 additions and 0 deletions

View File

@@ -170,6 +170,18 @@ func (h *cryptoSetupClient) getTags() map[Tag][]byte {
binary.LittleEndian.PutUint32(versionTag, protocol.VersionNumberToTag(h.version))
tags[TagVER] = versionTag
if len(h.stk) > 0 {
tags[TagSTK] = h.stk
}
if len(h.sno) > 0 {
tags[TagSNO] = h.sno
}
if h.serverConfig != nil {
tags[TagSCID] = h.serverConfig.ID
}
return tags
}

View File

@@ -106,6 +106,32 @@ var _ = Describe("Crypto setup", func() {
Expect(tags[TagPDMD]).To(Equal([]byte("X509")))
Expect(tags[TagVER]).To(Equal([]byte("Q036")))
})
It("includes the server config id, if available", func() {
id := []byte("foobar")
cs.serverConfig = &serverConfigClient{ID: id}
tags := cs.getTags()
Expect(tags[TagSCID]).To(Equal(id))
})
It("includes the source address token, if available", func() {
cs.stk = []byte("sourceaddresstoken")
tags := cs.getTags()
Expect(tags[TagSTK]).To(Equal(cs.stk))
})
It("includes the server nonce, if available", func() {
cs.sno = []byte("foobar")
tags := cs.getTags()
Expect(tags[TagSNO]).To(Equal(cs.sno))
})
It("doesn't include optional values, if not available", func() {
tags := cs.getTags()
Expect(tags).ToNot(HaveKey(TagSCID))
Expect(tags).ToNot(HaveKey(TagSNO))
Expect(tags).ToNot(HaveKey(TagSTK))
})
})
Context("Diversification Nonces", func() {