Test that warning alerts are ignored.

Partly inspired by the new state exposed in
dc3da93899, stress this codepath by spamming our
poor shim with warning alerts.

Change-Id: I876c6e52911b6eb57493cf3e1782b37ea96d01f8
Reviewed-on: https://boringssl-review.googlesource.com/4112
Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
David Benjamin
2015-03-25 15:25:28 +00:00
committed by Adam Langley
parent 0570923ed2
commit 340d5ed295
3 changed files with 28 additions and 0 deletions
+4
View File
@@ -679,6 +679,10 @@ type ProtocolBugs struct {
// IgnorePeerSignatureAlgorithmPreferences, if true, causes the peer's
// signature algorithm preferences to be ignored.
IgnorePeerSignatureAlgorithmPreferences bool
// SendWarningAlerts, if non-zero, causes every record to be prefaced by
// a warning alert.
SendWarningAlerts alert
}
func (c *Config) serverInit() {
+7
View File
@@ -829,6 +829,13 @@ func (c *Conn) writeV2Record(data []byte) (n int, err error) {
// to the connection and updates the record layer state.
// c.out.Mutex <= L.
func (c *Conn) writeRecord(typ recordType, data []byte) (n int, err error) {
if typ != recordTypeAlert && c.config.Bugs.SendWarningAlerts != 0 {
alert := make([]byte, 2)
alert[0] = alertLevelWarning
alert[1] = byte(c.config.Bugs.SendWarningAlerts)
c.writeRecord(recordTypeAlert, alert)
}
if c.isDTLS {
return c.dtlsWriteRecord(typ, data)
}
+17
View File
@@ -904,6 +904,23 @@ var testCases = []testCase{
shouldFail: true,
expectedError: ":WRONG_CIPHER_RETURNED:",
},
{
name: "SendWarningAlerts",
config: Config{
Bugs: ProtocolBugs{
SendWarningAlerts: alertAccessDenied,
},
},
},
{
protocol: dtls,
name: "SendWarningAlerts-DTLS",
config: Config{
Bugs: ProtocolBugs{
SendWarningAlerts: alertAccessDenied,
},
},
},
}
func doExchange(test *testCase, config *Config, conn net.Conn, messageLen int, isResume bool) error {