@ -97,6 +97,11 @@ type ShimConfiguration struct {
// HalfRTTTickets is the number of half-RTT tickets the client should
// expect before half-RTT data when testing 0-RTT.
HalfRTTTickets int
// AllCurves is the list of all curve code points supported by the shim.
// This is currently used to control tests that enable all curves but may
// automatically disable tests in the future.
AllCurves [ ] int
}
// Setup shimConfig defaults aligning with BoringSSL.
@ -253,6 +258,14 @@ func initCertificates() {
garbageCertificate . PrivateKey = rsaCertificate . PrivateKey
}
func flagInts ( flagName string , vals [ ] int ) [ ] string {
ret := make ( [ ] string , 0 , 2 * len ( vals ) )
for _ , val := range vals {
ret = append ( ret , flagName , strconv . Itoa ( val ) )
}
return ret
}
func useDebugger ( ) bool {
return * useGDB || * useLLDB || * useRR || * waitForDebugger
}
@ -9982,11 +9995,13 @@ func addSignatureAlgorithmTests() {
fakeSigAlg2 ,
} ,
} ,
flags : [ ] string {
"-cert-file" , path . Join ( * resourceDir , getShimCertificate ( alg . cert ) ) ,
"-key-file" , path . Join ( * resourceDir , getShimKey ( alg . cert ) ) ,
"-enable-all-curves" ,
} ,
flags : append (
[ ] string {
"-cert-file" , path . Join ( * resourceDir , getShimCertificate ( alg . cert ) ) ,
"-key-file" , path . Join ( * resourceDir , getShimKey ( alg . cert ) ) ,
} ,
flagInts ( "-curves" , shimConfig . AllCurves ) ... ,
) ,
shouldFail : shouldFail ,
expectedError : signError ,
expectedLocalError : signLocalError ,
@ -10004,12 +10019,14 @@ func addSignatureAlgorithmTests() {
MaxVersion : ver . version ,
VerifySignatureAlgorithms : allAlgorithms ,
} ,
flags : [ ] string {
"-cert-file" , path . Join ( * resourceDir , getShimCertificate ( alg . cert ) ) ,
"-key-file" , path . Join ( * resourceDir , getShimKey ( alg . cert ) ) ,
"-enable-all-curves" ,
"-signing-prefs" , strconv . Itoa ( int ( alg . id ) ) ,
} ,
flags : append (
[ ] string {
"-cert-file" , path . Join ( * resourceDir , getShimCertificate ( alg . cert ) ) ,
"-key-file" , path . Join ( * resourceDir , getShimKey ( alg . cert ) ) ,
"-signing-prefs" , strconv . Itoa ( int ( alg . id ) ) ,
} ,
flagInts ( "-curves" , shimConfig . AllCurves ) ... ,
) ,
expectations : connectionExpectations {
peerSignatureAlgorithm : alg . id ,
} ,
@ -10046,12 +10063,14 @@ func addSignatureAlgorithmTests() {
IgnorePeerSignatureAlgorithmPreferences : shouldFail ,
} ,
} ,
flags : [ ] string {
"-expect-peer-signature-algorithm" , strconv . Itoa ( int ( alg . id ) ) ,
"-enable-all-curves" ,
// The algorithm may be disabled by default, so explicitly enable it.
"-verify-prefs" , strconv . Itoa ( int ( alg . id ) ) ,
} ,
flags : append (
[ ] string {
"-expect-peer-signature-algorithm" , strconv . Itoa ( int ( alg . id ) ) ,
// The algorithm may be disabled by default, so explicitly enable it.
"-verify-prefs" , strconv . Itoa ( int ( alg . id ) ) ,
} ,
flagInts ( "-curves" , shimConfig . AllCurves ) ... ,
) ,
// Resume the session to assert the peer signature
// algorithm is reported on both handshakes.
resumeSession : ! shouldFail ,
@ -10077,10 +10096,10 @@ func addSignatureAlgorithmTests() {
IgnorePeerSignatureAlgorithmPreferences : rejectByDefault ,
} ,
} ,
flags : [ ] string {
"-expect-peer-signature-algorithm" , strconv . Itoa ( int ( alg . id ) ) ,
"-enable-all-curves" ,
} ,
flags : append (
[ ] string { "-expect-peer-signature-algorithm" , strconv . Itoa ( int ( alg . id ) ) } ,
flagInts ( "-curves" , shimConfig . AllCurves ) ... ,
) ,
// Resume the session to assert the peer signature
// algorithm is reported on both handshakes.
resumeSession : ! rejectByDefault ,
@ -10103,11 +10122,11 @@ func addSignatureAlgorithmTests() {
InvalidSignature : true ,
} ,
} ,
flags : [ ] string {
"-enable-all-curves" ,
flags : append (
// The algorithm may be disabled by default, so explicitly enable it.
"-verify-prefs" , strconv . Itoa ( int ( alg . id ) ) ,
} ,
[ ] string { "-verify-prefs" , strconv . Itoa ( int ( alg . id ) ) } ,
flagInts ( "-curves" , shimConfig . AllCurves ) ... ,
) ,
shouldFail : true ,
expectedError : ":BAD_SIGNATURE:" ,
}
@ -11491,10 +11510,10 @@ func addCurveTests() {
} ,
CurvePreferences : [ ] CurveID { curve . id } ,
} ,
flags : [ ] string {
"-enable-all-curves" ,
"-expect-curve-id" , strconv . Itoa ( int ( curve . id ) ) ,
} ,
flags : append (
[ ] string { "-expect-curve-id" , strconv . Itoa ( int ( curve . id ) ) } ,
flagInts ( "-curves" , shimConfig . AllCurves ) ... ,
) ,
expectations : connectionExpectations {
curveID : curve . id ,
} ,
@ -11511,10 +11530,10 @@ func addCurveTests() {
} ,
CurvePreferences : [ ] CurveID { curve . id } ,
} ,
flags : [ ] string {
"-enable-all-curves" ,
"-expect-curve-id" , strconv . Itoa ( int ( curve . id ) ) ,
} ,
flags : append (
[ ] string { "-expect-curve-id" , strconv . Itoa ( int ( curve . id ) ) } ,
flagInts ( "-curves" , shimConfig . AllCurves ) ... ,
) ,
expectations : connectionExpectations {
curveID : curve . id ,
} ,
@ -11535,7 +11554,7 @@ func addCurveTests() {
SendCompressedCoordinates : true ,
} ,
} ,
flags : [ ] string { "-enable-all-curves" } ,
flags : flagInts ( "-curves" , shimConfig . AllCurves ) ,
shouldFail : true ,
expectedError : ":BAD_ECPOINT:" ,
} )
@ -11554,7 +11573,7 @@ func addCurveTests() {
SendCompressedCoordinates : true ,
} ,
} ,
flags : [ ] string { "-enable-all-curves" } ,
flags : flagInts ( "-curves" , shimConfig . AllCurves ) ,
shouldFail : true ,
expectedError : ":BAD_ECPOINT:" ,
} )
@ -16760,6 +16779,25 @@ func main() {
* resourceDir = path . Clean ( * resourceDir )
initCertificates ( )
if len ( * shimConfigFile ) != 0 {
encoded , err := ioutil . ReadFile ( * shimConfigFile )
if err != nil {
fmt . Fprintf ( os . Stderr , "Couldn't read config file %q: %s\n" , * shimConfigFile , err )
os . Exit ( 1 )
}
if err := json . Unmarshal ( encoded , & shimConfig ) ; err != nil {
fmt . Fprintf ( os . Stderr , "Couldn't decode config file %q: %s\n" , * shimConfigFile , err )
os . Exit ( 1 )
}
}
if shimConfig . AllCurves == nil {
for _ , curve := range testCurves {
shimConfig . AllCurves = append ( shimConfig . AllCurves , int ( curve . id ) )
}
}
addBasicTests ( )
addCipherSuiteTests ( )
addBadECDSASignatureTests ( )
@ -16817,19 +16855,6 @@ func main() {
testChan := make ( chan * testCase , numWorkers )
doneChan := make ( chan * testresult . Results )
if len ( * shimConfigFile ) != 0 {
encoded , err := ioutil . ReadFile ( * shimConfigFile )
if err != nil {
fmt . Fprintf ( os . Stderr , "Couldn't read config file %q: %s\n" , * shimConfigFile , err )
os . Exit ( 1 )
}
if err := json . Unmarshal ( encoded , & shimConfig ) ; err != nil {
fmt . Fprintf ( os . Stderr , "Couldn't decode config file %q: %s\n" , * shimConfigFile , err )
os . Exit ( 1 )
}
}
go statusPrinter ( doneChan , statusChan , len ( testCases ) )
for i := 0 ; i < numWorkers ; i ++ {