diff --git a/.travis/script.sh b/.travis/script.sh index bcb158710..7004b42b6 100755 --- a/.travis/script.sh +++ b/.travis/script.sh @@ -13,6 +13,11 @@ fi if [ ${TESTMODE} == "unit" ]; then ginkgo -r -v -cover -randomizeAllSpecs -randomizeSuites -trace -skipPackage integrationtests,benchmark + # run internal and http3 tests with the Go race detector + # The Go race detector only works on amd64. + if [ ${TRAVIS_GOARCH} == 'amd64' ]; then + ginkgo -r -v -race -randomizeAllSpecs -randomizeSuites -trace internal http3 + fi fi if [ ${TESTMODE} == "integration" ]; then diff --git a/go.mod b/go.mod index 37e40b1ea..7da8f7698 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,6 @@ module github.com/lucas-clemente/quic-go go 1.13 require ( - github.com/alangpierce/go-forceexport v0.0.0-20160317203124-8f1d6941cd75 github.com/cheekybits/genny v1.0.0 github.com/francoispqt/gojay v1.2.13 github.com/golang/mock v1.4.0 diff --git a/go.sum b/go.sum index 7da464e78..eb0f498e6 100644 --- a/go.sum +++ b/go.sum @@ -8,8 +8,6 @@ dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1 dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU= git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/alangpierce/go-forceexport v0.0.0-20160317203124-8f1d6941cd75 h1:3ILjVyslFbc4jl1w5TWuvvslFD/nDfR2H8tVaMVLrEY= -github.com/alangpierce/go-forceexport v0.0.0-20160317203124-8f1d6941cd75/go.mod h1:uAXEEpARkRhCZfEvy/y0Jcc888f9tHCc1W7/UeEtreE= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= diff --git a/internal/handshake/crypto_setup_test.go b/internal/handshake/crypto_setup_test.go index 345363abf..ad5299c17 100644 --- a/internal/handshake/crypto_setup_test.go +++ b/internal/handshake/crypto_setup_test.go @@ -263,8 +263,6 @@ var _ = Describe("Crypto Setup TLS", func() { }) Context("doing the handshake", func() { - var testDone chan struct{} - generateCert := func() tls.Certificate { priv, err := rsa.GenerateKey(rand.Reader, 2048) Expect(err).ToNot(HaveOccurred()) @@ -284,14 +282,6 @@ var _ = Describe("Crypto Setup TLS", func() { } } - BeforeEach(func() { - testDone = make(chan struct{}) - }) - - AfterEach(func() { - close(testDone) - }) - handshake := func(client CryptoSetup, cChunkChan <-chan chunk, server CryptoSetup, sChunkChan <-chan chunk) { done := make(chan struct{}) @@ -303,7 +293,7 @@ var _ = Describe("Crypto Setup TLS", func() { server.HandleMessage(c.data, c.encLevel) case c := <-sChunkChan: client.HandleMessage(c.data, c.encLevel) - case <-testDone: // handshake complete + case <-done: // handshake complete return } } @@ -311,13 +301,13 @@ var _ = Describe("Crypto Setup TLS", func() { go func() { defer GinkgoRecover() + defer close(done) server.RunHandshake() ticket, err := server.GetSessionTicket() Expect(err).ToNot(HaveOccurred()) if ticket != nil { client.HandleMessage(ticket, protocol.Encryption1RTT) } - close(done) }() client.RunHandshake() diff --git a/internal/handshake/handshake_suite_test.go b/internal/handshake/handshake_suite_test.go index e43bccc7b..6e96343e7 100644 --- a/internal/handshake/handshake_suite_test.go +++ b/internal/handshake/handshake_suite_test.go @@ -5,8 +5,8 @@ import ( "crypto/cipher" "encoding/hex" "strings" + "unsafe" - "github.com/alangpierce/go-forceexport" "github.com/golang/mock/gomock" "github.com/marten-seemann/qtls" @@ -31,8 +31,6 @@ var _ = AfterEach(func() { mockCtrl.Finish() }) -var aeadChaCha20Poly1305 func(key, nonceMask []byte) cipher.AEAD - var cipherSuites = []*qtls.CipherSuiteTLS13{ &qtls.CipherSuiteTLS13{ ID: qtls.TLS_AES_128_GCM_SHA256, @@ -66,13 +64,25 @@ func splitHexString(s string) (slice []byte) { return } +type cipherSuiteTLS13 struct { + ID uint16 + KeyLen int + AEAD func(key, fixedNonce []byte) cipher.AEAD + Hash crypto.Hash +} + +//go:linkname cipherSuiteTLS13ByID github.com/marten-seemann/qtls.cipherSuiteTLS13ByID +func cipherSuiteTLS13ByID(id uint16) *cipherSuiteTLS13 + func init() { - if err := forceexport.GetFunc(&aeadChaCha20Poly1305, "github.com/marten-seemann/qtls.aeadChaCha20Poly1305"); err != nil { - panic(err) - } + val := cipherSuiteTLS13ByID(qtls.TLS_CHACHA20_POLY1305_SHA256) + chacha := (*cipherSuiteTLS13)(unsafe.Pointer(val)) for _, s := range cipherSuites { if s.ID == qtls.TLS_CHACHA20_POLY1305_SHA256 { - s.AEAD = aeadChaCha20Poly1305 + if s.KeyLen != chacha.KeyLen || s.Hash != chacha.Hash { + panic("invalid parameters for ChaCha20") + } + s.AEAD = chacha.AEAD } } } diff --git a/internal/handshake/tls_extension_handler_test.go b/internal/handshake/tls_extension_handler_test.go index acbca466b..819497d0a 100644 --- a/internal/handshake/tls_extension_handler_test.go +++ b/internal/handshake/tls_extension_handler_test.go @@ -84,12 +84,15 @@ var _ = Describe("TLS Extension Handler, for the server", func() { }) It("ignores extensions that are not sent with the ClientHello", func() { + done := make(chan struct{}) go func() { defer GinkgoRecover() handlerServer.ReceivedExtensions(uint8(typeFinished), chExts) + close(done) }() Consistently(handlerServer.TransportParameters()).ShouldNot(Receive()) + Eventually(done).Should(BeClosed()) }) }) }) @@ -153,12 +156,15 @@ var _ = Describe("TLS Extension Handler, for the server", func() { }) It("ignores extensions that are not sent with the EncryptedExtensions", func() { + done := make(chan struct{}) go func() { defer GinkgoRecover() handlerClient.ReceivedExtensions(uint8(typeFinished), chExts) + close(done) }() Consistently(handlerClient.TransportParameters()).ShouldNot(Receive()) + Eventually(done).Should(BeClosed()) }) }) })