From 1c633159a75f5231733953c2eadc8a5c852e962a Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Thu, 2 Apr 2015 20:19:11 -0400 Subject: [PATCH] Add negative False Start tests. Extend the False Start tests to optionally send an alert (thus avoiding deadlock) before waiting for the out-of-order app data. Based on whether the peer shuts off the connection before or after sending app data, we can determine whether the peer False Started by observing purely external effects. Change-Id: I8b9fecc29668e0b0c34b5fd19d0f239545011bae Reviewed-on: https://boringssl-review.googlesource.com/4213 Reviewed-by: Adam Langley --- ssl/test/runner/common.go | 7 +++ ssl/test/runner/handshake_server.go | 5 +- ssl/test/runner/runner.go | 74 +++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 1 deletion(-) diff --git a/ssl/test/runner/common.go b/ssl/test/runner/common.go index 73aeb825..df0db4d0 100644 --- a/ssl/test/runner/common.go +++ b/ssl/test/runner/common.go @@ -506,6 +506,13 @@ type ProtocolBugs struct { // from the peer. ExpectFalseStart bool + // AlertBeforeFalseStartTest, if non-zero, causes the server to, on full + // handshakes, send an alert just before reading the application data + // record to test False Start. This can be used in a negative False + // Start test to determine whether the peer processed the alert (and + // closed the connection) before or after sending app data. + AlertBeforeFalseStartTest alert + // SSL3RSAKeyExchange causes the client to always send an RSA // ClientKeyExchange message without the two-byte length // prefix, as if it were SSL3. diff --git a/ssl/test/runner/handshake_server.go b/ssl/test/runner/handshake_server.go index 5db04879..cf9d1ca2 100644 --- a/ssl/test/runner/handshake_server.go +++ b/ssl/test/runner/handshake_server.go @@ -97,9 +97,12 @@ func (c *Conn) serverHandshake() error { if err := hs.readFinished(isResume); err != nil { return err } + if c.config.Bugs.AlertBeforeFalseStartTest != 0 { + c.sendAlert(c.config.Bugs.AlertBeforeFalseStartTest) + } if c.config.Bugs.ExpectFalseStart { if err := c.readRecord(recordTypeApplicationData); err != nil { - return err + return fmt.Errorf("tls: peer did not false start: %s", err) } } if err := hs.sendSessionTicket(); err != nil { diff --git a/ssl/test/runner/runner.go b/ssl/test/runner/runner.go index 0d207705..b328c156 100644 --- a/ssl/test/runner/runner.go +++ b/ssl/test/runner/runner.go @@ -952,6 +952,80 @@ var testCases = []testCase{ shouldFail: true, expectedError: ":DIGEST_CHECK_FAILED:", }, + { + name: "NoFalseStart-NoALPN", + config: Config{ + CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, + Bugs: ProtocolBugs{ + ExpectFalseStart: true, + AlertBeforeFalseStartTest: alertAccessDenied, + }, + }, + flags: []string{ + "-false-start", + }, + shimWritesFirst: true, + shouldFail: true, + expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", + expectedLocalError: "tls: peer did not false start: EOF", + }, + { + name: "NoFalseStart-NoAEAD", + config: Config{ + CipherSuites: []uint16{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA}, + NextProtos: []string{"foo"}, + Bugs: ProtocolBugs{ + ExpectFalseStart: true, + AlertBeforeFalseStartTest: alertAccessDenied, + }, + }, + flags: []string{ + "-false-start", + "-advertise-alpn", "\x03foo", + }, + shimWritesFirst: true, + shouldFail: true, + expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", + expectedLocalError: "tls: peer did not false start: EOF", + }, + { + name: "NoFalseStart-RSA", + config: Config{ + CipherSuites: []uint16{TLS_RSA_WITH_AES_128_GCM_SHA256}, + NextProtos: []string{"foo"}, + Bugs: ProtocolBugs{ + ExpectFalseStart: true, + AlertBeforeFalseStartTest: alertAccessDenied, + }, + }, + flags: []string{ + "-false-start", + "-advertise-alpn", "\x03foo", + }, + shimWritesFirst: true, + shouldFail: true, + expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", + expectedLocalError: "tls: peer did not false start: EOF", + }, + { + name: "NoFalseStart-DHE_RSA", + config: Config{ + CipherSuites: []uint16{TLS_DHE_RSA_WITH_AES_128_GCM_SHA256}, + NextProtos: []string{"foo"}, + Bugs: ProtocolBugs{ + ExpectFalseStart: true, + AlertBeforeFalseStartTest: alertAccessDenied, + }, + }, + flags: []string{ + "-false-start", + "-advertise-alpn", "\x03foo", + }, + shimWritesFirst: true, + shouldFail: true, + expectedError: ":TLSV1_ALERT_ACCESS_DENIED:", + expectedLocalError: "tls: peer did not false start: EOF", + }, } func doExchange(test *testCase, config *Config, conn net.Conn, messageLen int, isResume bool) error {