Move per-cipher-suite tests into a separate function.

The loop is getting a little deeply nested and hard to read.

Change-Id: I3a99fba54c2f352850b83aef91ab72d5d9aabfb8
Reviewed-on: https://boringssl-review.googlesource.com/12685
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
This commit is contained in:
David Benjamin 2016-12-10 13:33:05 -05:00 committed by CQ bot account: commit-bot@chromium.org
parent db5bd72152
commit aa01204175

View File

@ -1054,12 +1054,14 @@ func runTest(test *testCase, shimPath string, mallocNumToFail int64) error {
return nil
}
var tlsVersions = []struct {
type tlsVersion struct {
name string
version uint16
flag string
hasDTLS bool
}{
}
var tlsVersions = []tlsVersion{
{"SSL3", VersionSSL30, "-no-ssl3", false},
{"TLS1", VersionTLS10, "-no-tls1", true},
{"TLS11", VersionTLS11, "-no-tls11", false},
@ -1067,10 +1069,12 @@ var tlsVersions = []struct {
{"TLS13", VersionTLS13, "-no-tls13", false},
}
var testCipherSuites = []struct {
type testCipherSuite struct {
name string
id uint16
}{
}
var testCipherSuites = []testCipherSuite{
{"3DES-SHA", TLS_RSA_WITH_3DES_EDE_CBC_SHA},
{"AES128-GCM", TLS_RSA_WITH_AES_128_GCM_SHA256},
{"AES128-SHA", TLS_RSA_WITH_AES_128_CBC_SHA},
@ -2431,13 +2435,18 @@ func addBasicTests() {
})
}
func addCipherSuiteTests() {
const bogusCipher = 0xfe00
for _, suite := range testCipherSuites {
func addTestForCipherSuite(suite testCipherSuite, ver tlsVersion, protocol protocol) {
const psk = "12345"
const pskIdentity = "luggage combo"
var prefix string
if protocol == dtls {
if !ver.hasDTLS {
return
}
prefix = "D"
}
var cert Certificate
var certFile string
var keyFile string
@ -2467,16 +2476,6 @@ func addCipherSuiteTests() {
flags = append(flags, "-cipher", suite.name)
}
for _, ver := range tlsVersions {
for _, protocol := range []protocol{tls, dtls} {
var prefix string
if protocol == dtls {
if !ver.hasDTLS {
continue
}
prefix = "D"
}
var shouldServerFail, shouldClientFail bool
if hasComponent(suite.name, "ECDHE") && ver.version == VersionSSL30 {
// BoringSSL clients accept ECDHE on SSLv3, but
@ -2518,7 +2517,6 @@ func addCipherSuiteTests() {
testCases = append(testCases, testCase{
testType: serverTest,
protocol: protocol,
name: prefix + ver.name + "-" + suite.name + "-server",
config: Config{
MinVersion: ver.version,
@ -2606,6 +2604,15 @@ func addCipherSuiteTests() {
})
}
}
func addCipherSuiteTests() {
const bogusCipher = 0xfe00
for _, suite := range testCipherSuites {
for _, ver := range tlsVersions {
for _, protocol := range []protocol{tls, dtls} {
addTestForCipherSuite(suite, ver, protocol)
}
}
}