@ -518,12 +518,6 @@ type connectionExpectations struct {
// channelID controls whether the connection should have negotiated a
// channelID controls whether the connection should have negotiated a
// Channel ID with channelIDKey.
// Channel ID with channelIDKey.
channelID bool
channelID bool
// tokenBinding controls whether the connection should have negotiated Token
// Binding.
tokenBinding bool
// tokenBindingParam is the Token Binding parameter that should have been
// negotiated (if tokenBinding is true).
tokenBindingParam uint8
// nextProto controls whether the connection should negotiate a next
// nextProto controls whether the connection should negotiate a next
// protocol via NPN or ALPN.
// protocol via NPN or ALPN.
nextProto string
nextProto string
@ -907,17 +901,6 @@ func doExchange(test *testCase, config *Config, conn net.Conn, isResume bool, tr
return fmt . Errorf ( "channel ID unexpectedly negotiated" )
return fmt . Errorf ( "channel ID unexpectedly negotiated" )
}
}
if expectations . tokenBinding {
if ! connState . TokenBindingNegotiated {
return errors . New ( "no Token Binding negotiated" )
}
if connState . TokenBindingParam != expectations . tokenBindingParam {
return fmt . Errorf ( "expected param %02x, but got %02x" , expectations . tokenBindingParam , connState . TokenBindingParam )
}
} else if connState . TokenBindingNegotiated {
return errors . New ( "Token Binding unexpectedly negotiated" )
}
if expected := expectations . nextProto ; expected != "" {
if expected := expectations . nextProto ; expected != "" {
if actual := connState . NegotiatedProtocol ; actual != expected {
if actual := connState . NegotiatedProtocol ; actual != expected {
return fmt . Errorf ( "next proto mismatch: got %s, wanted %s" , actual , expected )
return fmt . Errorf ( "next proto mismatch: got %s, wanted %s" , actual , expected )
@ -7697,411 +7680,6 @@ func addExtensionTests() {
} )
} )
}
}
// Test Token Binding.
if protocol != dtls {
const maxTokenBindingVersion = 16
const minTokenBindingVersion = 13
testCases = append ( testCases , testCase {
protocol : protocol ,
testType : serverTest ,
name : "TokenBinding-Server-" + suffix ,
config : Config {
MinVersion : ver . version ,
MaxVersion : ver . version ,
TokenBindingParams : [ ] byte { 0 , 1 , 2 } ,
TokenBindingVersion : maxTokenBindingVersion ,
} ,
expectations : connectionExpectations {
tokenBinding : true ,
tokenBindingParam : 2 ,
} ,
flags : [ ] string {
"-token-binding-params" ,
base64 . StdEncoding . EncodeToString ( [ ] byte { 2 , 1 , 0 } ) ,
"-expect-token-binding-param" ,
"2" ,
} ,
} )
testCases = append ( testCases , testCase {
protocol : protocol ,
testType : serverTest ,
name : "TokenBinding-Server-UnsupportedParam-" + suffix ,
config : Config {
MinVersion : ver . version ,
MaxVersion : ver . version ,
TokenBindingParams : [ ] byte { 3 } ,
TokenBindingVersion : maxTokenBindingVersion ,
} ,
flags : [ ] string {
"-token-binding-params" ,
base64 . StdEncoding . EncodeToString ( [ ] byte { 2 , 1 , 0 } ) ,
} ,
} )
testCases = append ( testCases , testCase {
protocol : protocol ,
testType : serverTest ,
name : "TokenBinding-Server-OldVersion-" + suffix ,
config : Config {
MinVersion : ver . version ,
MaxVersion : ver . version ,
TokenBindingParams : [ ] byte { 0 , 1 , 2 } ,
TokenBindingVersion : minTokenBindingVersion - 1 ,
} ,
flags : [ ] string {
"-token-binding-params" ,
base64 . StdEncoding . EncodeToString ( [ ] byte { 2 , 1 , 0 } ) ,
} ,
} )
testCases = append ( testCases , testCase {
protocol : protocol ,
testType : serverTest ,
name : "TokenBinding-Server-NewVersion-" + suffix ,
config : Config {
MinVersion : ver . version ,
MaxVersion : ver . version ,
TokenBindingParams : [ ] byte { 0 , 1 , 2 } ,
TokenBindingVersion : maxTokenBindingVersion + 1 ,
} ,
expectations : connectionExpectations {
tokenBinding : true ,
tokenBindingParam : 2 ,
} ,
flags : [ ] string {
"-token-binding-params" ,
base64 . StdEncoding . EncodeToString ( [ ] byte { 2 , 1 , 0 } ) ,
"-expect-token-binding-param" ,
"2" ,
} ,
} )
testCases = append ( testCases , testCase {
protocol : protocol ,
testType : serverTest ,
name : "TokenBinding-Server-NoParams-" + suffix ,
config : Config {
MinVersion : ver . version ,
MaxVersion : ver . version ,
TokenBindingParams : [ ] byte { } ,
TokenBindingVersion : maxTokenBindingVersion ,
} ,
flags : [ ] string {
"-token-binding-params" ,
base64 . StdEncoding . EncodeToString ( [ ] byte { 2 , 1 , 0 } ) ,
} ,
shouldFail : true ,
expectedError : ":ERROR_PARSING_EXTENSION:" ,
} )
testCases = append ( testCases , testCase {
protocol : protocol ,
testType : serverTest ,
name : "TokenBinding-Server-RepeatedParam" + suffix ,
config : Config {
MinVersion : ver . version ,
MaxVersion : ver . version ,
TokenBindingParams : [ ] byte { 0 , 1 , 2 , 2 } ,
TokenBindingVersion : maxTokenBindingVersion ,
} ,
expectations : connectionExpectations {
tokenBinding : true ,
tokenBindingParam : 2 ,
} ,
flags : [ ] string {
"-token-binding-params" ,
base64 . StdEncoding . EncodeToString ( [ ] byte { 2 , 1 , 0 } ) ,
"-expect-token-binding-param" ,
"2" ,
} ,
} )
testCases = append ( testCases , testCase {
protocol : protocol ,
testType : clientTest ,
name : "TokenBinding-Client-" + suffix ,
config : Config {
MinVersion : ver . version ,
MaxVersion : ver . version ,
TokenBindingParams : [ ] byte { 2 } ,
TokenBindingVersion : maxTokenBindingVersion ,
ExpectTokenBindingParams : [ ] byte { 0 , 1 , 2 } ,
} ,
flags : [ ] string {
"-token-binding-params" ,
base64 . StdEncoding . EncodeToString ( [ ] byte { 0 , 1 , 2 } ) ,
"-expect-token-binding-param" ,
"2" ,
} ,
} )
testCases = append ( testCases , testCase {
protocol : protocol ,
testType : clientTest ,
name : "TokenBinding-Client-Unexpected-" + suffix ,
config : Config {
MinVersion : ver . version ,
MaxVersion : ver . version ,
TokenBindingParams : [ ] byte { 2 } ,
TokenBindingVersion : maxTokenBindingVersion ,
} ,
shouldFail : true ,
expectedError : ":UNEXPECTED_EXTENSION:" ,
} )
testCases = append ( testCases , testCase {
protocol : protocol ,
testType : clientTest ,
name : "TokenBinding-Client-ExtraParams-" + suffix ,
config : Config {
MinVersion : ver . version ,
MaxVersion : ver . version ,
TokenBindingParams : [ ] byte { 2 , 1 } ,
TokenBindingVersion : maxTokenBindingVersion ,
ExpectTokenBindingParams : [ ] byte { 0 , 1 , 2 } ,
} ,
flags : [ ] string {
"-token-binding-params" ,
base64 . StdEncoding . EncodeToString ( [ ] byte { 0 , 1 , 2 } ) ,
"-expect-token-binding-param" ,
"2" ,
} ,
shouldFail : true ,
expectedError : ":ERROR_PARSING_EXTENSION:" ,
} )
testCases = append ( testCases , testCase {
protocol : protocol ,
testType : clientTest ,
name : "TokenBinding-Client-NoParams-" + suffix ,
config : Config {
MinVersion : ver . version ,
MaxVersion : ver . version ,
TokenBindingParams : [ ] byte { } ,
TokenBindingVersion : maxTokenBindingVersion ,
ExpectTokenBindingParams : [ ] byte { 0 , 1 , 2 } ,
} ,
flags : [ ] string {
"-token-binding-params" ,
base64 . StdEncoding . EncodeToString ( [ ] byte { 0 , 1 , 2 } ) ,
"-expect-token-binding-param" ,
"2" ,
} ,
shouldFail : true ,
expectedError : ":ERROR_PARSING_EXTENSION:" ,
} )
testCases = append ( testCases , testCase {
protocol : protocol ,
testType : clientTest ,
name : "TokenBinding-Client-WrongParam-" + suffix ,
config : Config {
MinVersion : ver . version ,
MaxVersion : ver . version ,
TokenBindingParams : [ ] byte { 3 } ,
TokenBindingVersion : maxTokenBindingVersion ,
ExpectTokenBindingParams : [ ] byte { 0 , 1 , 2 } ,
} ,
flags : [ ] string {
"-token-binding-params" ,
base64 . StdEncoding . EncodeToString ( [ ] byte { 0 , 1 , 2 } ) ,
"-expect-token-binding-param" ,
"2" ,
} ,
shouldFail : true ,
expectedError : ":ERROR_PARSING_EXTENSION:" ,
} )
testCases = append ( testCases , testCase {
protocol : protocol ,
testType : clientTest ,
name : "TokenBinding-Client-OldVersion-" + suffix ,
config : Config {
MinVersion : ver . version ,
MaxVersion : ver . version ,
TokenBindingParams : [ ] byte { 2 } ,
TokenBindingVersion : minTokenBindingVersion - 1 ,
ExpectTokenBindingParams : [ ] byte { 0 , 1 , 2 } ,
} ,
flags : [ ] string {
"-token-binding-params" ,
base64 . StdEncoding . EncodeToString ( [ ] byte { 0 , 1 , 2 } ) ,
} ,
} )
testCases = append ( testCases , testCase {
protocol : protocol ,
testType : clientTest ,
name : "TokenBinding-Client-MinVersion-" + suffix ,
config : Config {
MinVersion : ver . version ,
MaxVersion : ver . version ,
TokenBindingParams : [ ] byte { 2 } ,
TokenBindingVersion : minTokenBindingVersion ,
ExpectTokenBindingParams : [ ] byte { 0 , 1 , 2 } ,
} ,
flags : [ ] string {
"-token-binding-params" ,
base64 . StdEncoding . EncodeToString ( [ ] byte { 0 , 1 , 2 } ) ,
"-expect-token-binding-param" ,
"2" ,
} ,
} )
testCases = append ( testCases , testCase {
protocol : protocol ,
testType : clientTest ,
name : "TokenBinding-Client-VersionTooNew-" + suffix ,
config : Config {
MinVersion : ver . version ,
MaxVersion : ver . version ,
TokenBindingParams : [ ] byte { 2 } ,
TokenBindingVersion : maxTokenBindingVersion + 1 ,
ExpectTokenBindingParams : [ ] byte { 0 , 1 , 2 } ,
} ,
flags : [ ] string {
"-token-binding-params" ,
base64 . StdEncoding . EncodeToString ( [ ] byte { 0 , 1 , 2 } ) ,
} ,
shouldFail : true ,
expectedError : "ERROR_PARSING_EXTENSION" ,
} )
if ver . version < VersionTLS13 {
testCases = append ( testCases , testCase {
protocol : protocol ,
testType : clientTest ,
name : "TokenBinding-Client-NoEMS-" + suffix ,
config : Config {
MinVersion : ver . version ,
MaxVersion : ver . version ,
TokenBindingParams : [ ] byte { 2 } ,
TokenBindingVersion : maxTokenBindingVersion ,
ExpectTokenBindingParams : [ ] byte { 2 , 1 , 0 } ,
Bugs : ProtocolBugs {
NoExtendedMasterSecret : true ,
} ,
} ,
flags : [ ] string {
"-token-binding-params" ,
base64 . StdEncoding . EncodeToString ( [ ] byte { 2 , 1 , 0 } ) ,
} ,
shouldFail : true ,
expectedError : ":NEGOTIATED_TB_WITHOUT_EMS_OR_RI:" ,
} )
testCases = append ( testCases , testCase {
protocol : protocol ,
testType : serverTest ,
name : "TokenBinding-Server-NoEMS-" + suffix ,
config : Config {
MinVersion : ver . version ,
MaxVersion : ver . version ,
TokenBindingParams : [ ] byte { 0 , 1 , 2 } ,
TokenBindingVersion : maxTokenBindingVersion ,
Bugs : ProtocolBugs {
NoExtendedMasterSecret : true ,
} ,
} ,
flags : [ ] string {
"-token-binding-params" ,
base64 . StdEncoding . EncodeToString ( [ ] byte { 2 , 1 , 0 } ) ,
} ,
shouldFail : true ,
expectedError : ":NEGOTIATED_TB_WITHOUT_EMS_OR_RI:" ,
} )
testCases = append ( testCases , testCase {
protocol : protocol ,
testType : clientTest ,
name : "TokenBinding-Client-NoRI-" + suffix ,
config : Config {
MinVersion : ver . version ,
MaxVersion : ver . version ,
TokenBindingParams : [ ] byte { 2 } ,
TokenBindingVersion : maxTokenBindingVersion ,
ExpectTokenBindingParams : [ ] byte { 2 , 1 , 0 } ,
Bugs : ProtocolBugs {
NoRenegotiationInfo : true ,
} ,
} ,
flags : [ ] string {
"-token-binding-params" ,
base64 . StdEncoding . EncodeToString ( [ ] byte { 2 , 1 , 0 } ) ,
} ,
shouldFail : true ,
expectedError : ":NEGOTIATED_TB_WITHOUT_EMS_OR_RI:" ,
} )
testCases = append ( testCases , testCase {
protocol : protocol ,
testType : serverTest ,
name : "TokenBinding-Server-NoRI-" + suffix ,
config : Config {
MinVersion : ver . version ,
MaxVersion : ver . version ,
TokenBindingParams : [ ] byte { 0 , 1 , 2 } ,
TokenBindingVersion : maxTokenBindingVersion ,
Bugs : ProtocolBugs {
NoRenegotiationInfo : true ,
} ,
} ,
flags : [ ] string {
"-token-binding-params" ,
base64 . StdEncoding . EncodeToString ( [ ] byte { 2 , 1 , 0 } ) ,
} ,
shouldFail : true ,
expectedError : ":NEGOTIATED_TB_WITHOUT_EMS_OR_RI:" ,
} )
} else {
testCases = append ( testCases , testCase {
protocol : protocol ,
testType : clientTest ,
name : "TokenBinding-WithEarlyDataFails-" + suffix ,
config : Config {
MinVersion : ver . version ,
MaxVersion : ver . version ,
TokenBindingParams : [ ] byte { 2 } ,
TokenBindingVersion : maxTokenBindingVersion ,
ExpectTokenBindingParams : [ ] byte { 2 , 1 , 0 } ,
} ,
resumeSession : true ,
earlyData : true ,
flags : [ ] string {
"-token-binding-params" ,
base64 . StdEncoding . EncodeToString ( [ ] byte { 2 , 1 , 0 } ) ,
} ,
shouldFail : true ,
expectedError : ":UNEXPECTED_EXTENSION_ON_EARLY_DATA:" ,
} )
testCases = append ( testCases , testCase {
protocol : protocol ,
testType : serverTest ,
name : "TokenBinding-EarlyDataRejected-" + suffix ,
config : Config {
MinVersion : ver . version ,
MaxVersion : ver . version ,
TokenBindingParams : [ ] byte { 0 , 1 , 2 } ,
TokenBindingVersion : maxTokenBindingVersion ,
} ,
resumeSession : true ,
earlyData : true ,
expectEarlyDataRejected : true ,
expectations : connectionExpectations {
tokenBinding : true ,
tokenBindingParam : 2 ,
} ,
flags : [ ] string {
"-token-binding-params" ,
base64 . StdEncoding . EncodeToString ( [ ] byte { 2 , 1 , 0 } ) ,
"-on-retry-expect-early-data-reason" , "token_binding" ,
} ,
} )
}
}
// Test QUIC transport params
// Test QUIC transport params
if protocol == quic {
if protocol == quic {
// Client sends params
// Client sends params