@ -19032,6 +19032,197 @@ func addHintMismatchTests() {
}
}
func addCompliancePolicyTests ( ) {
for _ , protocol := range [ ] protocol { tls , quic } {
for _ , suite := range testCipherSuites {
var isFIPSCipherSuite bool
switch suite . id {
case TLS_AES_128_GCM_SHA256 ,
TLS_AES_256_GCM_SHA384 ,
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 ,
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 ,
TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 ,
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 :
isFIPSCipherSuite = true
}
var certFile string
var keyFile string
var certs [ ] Certificate
if hasComponent ( suite . name , "ECDSA" ) {
certFile = ecdsaP256CertificateFile
keyFile = ecdsaP256KeyFile
certs = [ ] Certificate { ecdsaP256Certificate }
} else {
certFile = rsaCertificateFile
keyFile = rsaKeyFile
certs = [ ] Certificate { rsaCertificate }
}
maxVersion := uint16 ( VersionTLS13 )
if ! isTLS13Suite ( suite . name ) {
if protocol == quic {
continue
}
maxVersion = VersionTLS12
}
testCases = append ( testCases , testCase {
testType : serverTest ,
protocol : protocol ,
name : "Compliance-fips202205-" + protocol . String ( ) + "-Server-" + suite . name ,
config : Config {
MinVersion : VersionTLS12 ,
MaxVersion : maxVersion ,
CipherSuites : [ ] uint16 { suite . id } ,
} ,
certFile : certFile ,
keyFile : keyFile ,
flags : [ ] string {
"-fips-202205" ,
} ,
shouldFail : ! isFIPSCipherSuite ,
} )
testCases = append ( testCases , testCase {
testType : clientTest ,
protocol : protocol ,
name : "Compliance-fips202205-" + protocol . String ( ) + "-Client-" + suite . name ,
config : Config {
MinVersion : VersionTLS12 ,
MaxVersion : maxVersion ,
CipherSuites : [ ] uint16 { suite . id } ,
Certificates : certs ,
} ,
flags : [ ] string {
"-fips-202205" ,
} ,
shouldFail : ! isFIPSCipherSuite ,
} )
}
// Check that a TLS 1.3 client won't accept ChaCha20 even if the server
// picks it without it being in the client's cipher list.
testCases = append ( testCases , testCase {
testType : clientTest ,
protocol : protocol ,
name : "Compliance-fips202205-" + protocol . String ( ) + "-Client-ReallyWontAcceptChaCha" ,
config : Config {
MinVersion : VersionTLS12 ,
MaxVersion : maxVersion ,
Bugs : ProtocolBugs {
SendCipherSuite : TLS_CHACHA20_POLY1305_SHA256 ,
} ,
} ,
flags : [ ] string {
"-fips-202205" ,
} ,
shouldFail : true ,
expectedError : ":WRONG_CIPHER_RETURNED:" ,
} )
for _ , curve := range testCurves {
var isFIPSCurve bool
switch curve . id {
case CurveP256 , CurveP384 :
isFIPSCurve = true
}
testCases = append ( testCases , testCase {
testType : serverTest ,
protocol : protocol ,
name : "Compliance-fips202205-" + protocol . String ( ) + "-Server-" + curve . name ,
config : Config {
MinVersion : VersionTLS12 ,
MaxVersion : VersionTLS13 ,
CurvePreferences : [ ] CurveID { curve . id } ,
} ,
flags : [ ] string {
"-fips-202205" ,
} ,
shouldFail : ! isFIPSCurve ,
} )
testCases = append ( testCases , testCase {
testType : clientTest ,
protocol : protocol ,
name : "Compliance-fips202205-" + protocol . String ( ) + "-Client-" + curve . name ,
config : Config {
MinVersion : VersionTLS12 ,
MaxVersion : VersionTLS13 ,
CurvePreferences : [ ] CurveID { curve . id } ,
} ,
flags : [ ] string {
"-fips-202205" ,
} ,
shouldFail : ! isFIPSCurve ,
} )
}
for _ , sigalg := range testSignatureAlgorithms {
var isFIPSSigAlg bool
switch sigalg . id {
case signatureRSAPKCS1WithSHA256 ,
signatureRSAPKCS1WithSHA384 ,
signatureRSAPKCS1WithSHA512 ,
signatureECDSAWithP256AndSHA256 ,
signatureECDSAWithP384AndSHA384 ,
signatureRSAPSSWithSHA256 ,
signatureRSAPSSWithSHA384 ,
signatureRSAPSSWithSHA512 :
isFIPSSigAlg = true
}
if sigalg . cert == testCertECDSAP224 {
// This can work in TLS 1.2, but not with TLS 1.3.
// For consistency it's not permitted in FIPS mode.
isFIPSSigAlg = false
}
maxVersion := uint16 ( VersionTLS13 )
if hasComponent ( sigalg . name , "PKCS1" ) {
if protocol == quic {
continue
}
maxVersion = VersionTLS12
}
testCases = append ( testCases , testCase {
testType : serverTest ,
protocol : protocol ,
name : "Compliance-fips202205-" + protocol . String ( ) + "-Server-" + sigalg . name ,
config : Config {
MinVersion : VersionTLS12 ,
MaxVersion : maxVersion ,
VerifySignatureAlgorithms : [ ] signatureAlgorithm { sigalg . id } ,
} ,
flags : [ ] string {
"-fips-202205" ,
"-cert-file" , path . Join ( * resourceDir , getShimCertificate ( sigalg . cert ) ) ,
"-key-file" , path . Join ( * resourceDir , getShimKey ( sigalg . cert ) ) ,
} ,
shouldFail : ! isFIPSSigAlg ,
} )
testCases = append ( testCases , testCase {
testType : clientTest ,
protocol : protocol ,
name : "Compliance-fips202205-" + protocol . String ( ) + "-Client-" + sigalg . name ,
config : Config {
MinVersion : VersionTLS12 ,
MaxVersion : maxVersion ,
SignSignatureAlgorithms : [ ] signatureAlgorithm { sigalg . id } ,
Certificates : [ ] Certificate { getRunnerCertificate ( sigalg . cert ) } ,
} ,
flags : [ ] string {
"-fips-202205" ,
} ,
shouldFail : ! isFIPSSigAlg ,
} )
}
}
}
func worker ( statusChan chan statusMsg , c chan * testCase , shimPath string , wg * sync . WaitGroup ) {
defer wg . Done ( )
@ -19274,6 +19465,7 @@ func main() {
addDelegatedCredentialTests ( )
addEncryptedClientHelloTests ( )
addHintMismatchTests ( )
addCompliancePolicyTests ( )
toAppend , err := convertToSplitHandshakeTests ( testCases )
if err != nil {