From 5a1c94ba7b3fb1feac121df87050441f79a56a6d Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Fri, 11 Nov 2016 20:00:26 +0700 Subject: [PATCH] send client nonce and public value after receiving the certificate chain --- handshake/crypto_setup_client.go | 6 ++++++ handshake/crypto_setup_client_test.go | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/handshake/crypto_setup_client.go b/handshake/crypto_setup_client.go index 6d123f7c2..853df8ddd 100644 --- a/handshake/crypto_setup_client.go +++ b/handshake/crypto_setup_client.go @@ -195,6 +195,12 @@ func (h *cryptoSetupClient) getTags() map[Tag][]byte { if h.serverConfig != nil { tags[TagSCID] = h.serverConfig.ID + + leafCert := h.certManager.GetLeafCert() + if leafCert != nil { + tags[TagNONC] = h.nonc + tags[TagPUBS] = h.serverConfig.kex.PublicKey() // TODO: check if 3 bytes need to be prepended + } } return tags diff --git a/handshake/crypto_setup_client_test.go b/handshake/crypto_setup_client_test.go index 6b917482a..3562a1a7c 100644 --- a/handshake/crypto_setup_client_test.go +++ b/handshake/crypto_setup_client_test.go @@ -5,6 +5,7 @@ import ( "encoding/binary" "time" + "github.com/lucas-clemente/quic-go/crypto" "github.com/lucas-clemente/quic-go/protocol" "github.com/lucas-clemente/quic-go/qerr" . "github.com/onsi/ginkgo" @@ -187,6 +188,23 @@ var _ = Describe("Crypto setup", func() { Expect(tags).ToNot(HaveKey(TagSNO)) Expect(tags).ToNot(HaveKey(TagSTK)) }) + + It("doesn't change any values after reading the certificate, if the server config is missing", func() { + tags := cs.getTags() + certManager.leafCert = []byte("leafcert") + Expect(cs.getTags()).To(Equal(tags)) + }) + + It("sends a client nonce and a public value after reading the certificate and the server config", func() { + certManager.leafCert = []byte("leafcert") + cs.nonc = []byte("client-nonce") + kex, err := crypto.NewCurve25519KEX() + Expect(err).ToNot(HaveOccurred()) + cs.serverConfig = &serverConfigClient{kex: kex} + tags := cs.getTags() + Expect(tags[TagNONC]).To(Equal(cs.nonc)) + Expect(tags[TagPUBS]).To(Equal(kex.PublicKey())) + }) }) Context("Diversification Nonces", func() {