uquic/internal/handshake/handshake_suite_test.go
2019-09-07 11:36:50 +07:00

76 lines
1.5 KiB
Go

package handshake
import (
"crypto"
"crypto/cipher"
"github.com/alangpierce/go-forceexport"
"github.com/golang/mock/gomock"
"github.com/marten-seemann/qtls"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestHandshake(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Handshake Suite")
}
var mockCtrl *gomock.Controller
var _ = BeforeEach(func() {
mockCtrl = gomock.NewController(GinkgoT())
})
var _ = AfterEach(func() {
mockCtrl.Finish()
})
var aeadChaCha20Poly1305 func(key, nonceMask []byte) cipher.AEAD
var cipherSuites = []struct {
name string
suite *qtls.CipherSuiteTLS13
}{
{
name: "TLS_AES_128_GCM_SHA256",
suite: &qtls.CipherSuiteTLS13{
ID: qtls.TLS_AES_128_GCM_SHA256,
KeyLen: 16,
AEAD: qtls.AEADAESGCMTLS13,
Hash: crypto.SHA256,
},
},
{
name: "TLS_AES_256_GCM_SHA384",
suite: &qtls.CipherSuiteTLS13{
ID: qtls.TLS_AES_256_GCM_SHA384,
KeyLen: 32,
AEAD: qtls.AEADAESGCMTLS13,
Hash: crypto.SHA384,
},
},
{
name: "TLS_CHACHA20_POLY1305_SHA256",
suite: &qtls.CipherSuiteTLS13{
ID: qtls.TLS_CHACHA20_POLY1305_SHA256,
KeyLen: 32,
AEAD: nil, // will be set by init
Hash: crypto.SHA256,
},
},
}
func init() {
if err := forceexport.GetFunc(&aeadChaCha20Poly1305, "github.com/marten-seemann/qtls.aeadChaCha20Poly1305"); err != nil {
panic(err)
}
for _, s := range cipherSuites {
if s.suite.ID == qtls.TLS_CHACHA20_POLY1305_SHA256 {
s.suite.AEAD = aeadChaCha20Poly1305
}
}
}