From 95c69563dc5422c3b3cd3a0bf435944a7530a12d Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Wed, 29 Jun 2016 18:15:03 -0400 Subject: [PATCH] Add version tolerance tests for DTLS. Also move them with the other version negotiation tests. Change-Id: I8ea5777c131f8ab618de3c6d02038e802bd34dd0 Reviewed-on: https://boringssl-review.googlesource.com/8550 Reviewed-by: David Benjamin --- ssl/test/runner/runner.go | 102 ++++++++++++++++++++++++++------------ 1 file changed, 71 insertions(+), 31 deletions(-) diff --git a/ssl/test/runner/runner.go b/ssl/test/runner/runner.go index be88af6e..7596485e 100644 --- a/ssl/test/runner/runner.go +++ b/ssl/test/runner/runner.go @@ -1378,37 +1378,6 @@ func addBasicTests() { }, expectedVersion: VersionTLS13, }, - { - testType: serverTest, - name: "MinorVersionTolerance", - config: Config{ - Bugs: ProtocolBugs{ - SendClientVersion: 0x03ff, - }, - }, - expectedVersion: VersionTLS13, - }, - { - testType: serverTest, - name: "MajorVersionTolerance", - config: Config{ - Bugs: ProtocolBugs{ - SendClientVersion: 0x0400, - }, - }, - expectedVersion: VersionTLS13, - }, - { - testType: serverTest, - name: "VersionTooLow", - config: Config{ - Bugs: ProtocolBugs{ - SendClientVersion: 0x0200, - }, - }, - shouldFail: true, - expectedError: ":UNSUPPORTED_PROTOCOL:", - }, { testType: serverTest, name: "HttpGET", @@ -3668,6 +3637,77 @@ func addVersionNegotiationTests() { } } } + + // Test for version tolerance. + testCases = append(testCases, testCase{ + testType: serverTest, + name: "MinorVersionTolerance", + config: Config{ + Bugs: ProtocolBugs{ + SendClientVersion: 0x03ff, + }, + }, + expectedVersion: VersionTLS13, + }) + testCases = append(testCases, testCase{ + testType: serverTest, + name: "MajorVersionTolerance", + config: Config{ + Bugs: ProtocolBugs{ + SendClientVersion: 0x0400, + }, + }, + expectedVersion: VersionTLS13, + }) + testCases = append(testCases, testCase{ + protocol: dtls, + testType: serverTest, + name: "MinorVersionTolerance-DTLS", + config: Config{ + Bugs: ProtocolBugs{ + SendClientVersion: 0x03ff, + }, + }, + expectedVersion: VersionTLS12, + }) + testCases = append(testCases, testCase{ + protocol: dtls, + testType: serverTest, + name: "MajorVersionTolerance-DTLS", + config: Config{ + Bugs: ProtocolBugs{ + SendClientVersion: 0x0400, + }, + }, + expectedVersion: VersionTLS12, + }) + + // Test that versions below 3.0 are rejected. + testCases = append(testCases, testCase{ + testType: serverTest, + name: "VersionTooLow", + config: Config{ + Bugs: ProtocolBugs{ + SendClientVersion: 0x0200, + }, + }, + shouldFail: true, + expectedError: ":UNSUPPORTED_PROTOCOL:", + }) + testCases = append(testCases, testCase{ + protocol: dtls, + testType: serverTest, + name: "VersionTooLow-DTLS", + config: Config{ + Bugs: ProtocolBugs{ + // 0x0201 is the lowest version expressable in + // DTLS. + SendClientVersion: 0x0201, + }, + }, + shouldFail: true, + expectedError: ":UNSUPPORTED_PROTOCOL:", + }) } func addMinimumVersionTests() {