1// +build go1.13,!js 2 3package e2e 4 5import ( 6 "context" 7 "crypto/ed25519" 8 "crypto/rand" 9 "crypto/tls" 10 "testing" 11 "time" 12 13 "github.com/pion/dtls/v2" 14 "github.com/pion/dtls/v2/pkg/crypto/selfsign" 15 "github.com/pion/transport/test" 16) 17 18// ED25519 is not supported in Go 1.12 crypto/x509. 19// Once Go 1.12 is deprecated, move this test to e2e_test.go. 20 21func testPionE2ESimpleED25519(t *testing.T, server, client func(*comm)) { 22 lim := test.TimeOut(time.Second * 30) 23 defer lim.Stop() 24 25 report := test.CheckRoutines(t) 26 defer report() 27 28 for _, cipherSuite := range []dtls.CipherSuiteID{ 29 dtls.TLS_ECDHE_ECDSA_WITH_AES_128_CCM, 30 dtls.TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8, 31 dtls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, 32 dtls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, 33 } { 34 cipherSuite := cipherSuite 35 t.Run(cipherSuite.String(), func(t *testing.T) { 36 ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) 37 defer cancel() 38 39 _, key, err := ed25519.GenerateKey(rand.Reader) 40 if err != nil { 41 t.Fatal(err) 42 } 43 cert, err := selfsign.SelfSign(key) 44 if err != nil { 45 t.Fatal(err) 46 } 47 48 cfg := &dtls.Config{ 49 Certificates: []tls.Certificate{cert}, 50 CipherSuites: []dtls.CipherSuiteID{cipherSuite}, 51 InsecureSkipVerify: true, 52 } 53 serverPort := randomPort(t) 54 comm := newComm(ctx, cfg, cfg, serverPort, server, client) 55 comm.assert(t) 56 }) 57 } 58} 59 60func TestPionE2ESimpleED25519(t *testing.T) { 61 testPionE2ESimpleED25519(t, serverPion, clientPion) 62} 63