runner: Include the name of the message we failed to parse
This should make debugging easier.
Change-Id: I297e730b95a53eff2256abd6562b8eadf321b8fb
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/76287
Auto-Submit: David Benjamin <davidben@google.com>
Commit-Queue: Bob Beck <bbe@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
diff --git a/ssl/test/runner/common.go b/ssl/test/runner/common.go
index d7a1ea4..ee65687 100644
--- a/ssl/test/runner/common.go
+++ b/ssl/test/runner/common.go
@@ -91,12 +91,58 @@
typeFinished uint8 = 20
typeCertificateStatus uint8 = 22
typeKeyUpdate uint8 = 24
- typeCompressedCertificate uint8 = 25 // Not IANA assigned
+ typeCompressedCertificate uint8 = 25
typeNextProtocol uint8 = 67 // Not IANA assigned
typeChannelID uint8 = 203 // Not IANA assigned
typeMessageHash uint8 = 254
)
+func messageTypeToString(typ uint8) string {
+ switch typ {
+ case typeHelloRequest:
+ return "HelloRequest"
+ case typeClientHello:
+ return "ClientHello"
+ case typeServerHello:
+ return "ServerHello"
+ case typeHelloVerifyRequest:
+ return "HelloVerifyRequest"
+ case typeNewSessionTicket:
+ return "NewSessionTicket"
+ case typeEndOfEarlyData:
+ return "EndOfEarlyData"
+ case typeEncryptedExtensions:
+ return "EncryptedExtensions"
+ case typeCertificate:
+ return "Certificate"
+ case typeServerKeyExchange:
+ return "ServerKeyExchange"
+ case typeCertificateRequest:
+ return "CertificateRequest"
+ case typeServerHelloDone:
+ return "ServerHelloDone"
+ case typeCertificateVerify:
+ return "CertificateVerify"
+ case typeClientKeyExchange:
+ return "ClientKeyExchange"
+ case typeFinished:
+ return "Finished"
+ case typeCertificateStatus:
+ return "CertificateStatus"
+ case typeKeyUpdate:
+ return "KeyUpdate"
+ case typeCompressedCertificate:
+ return "CompressedCertificate"
+ case typeNextProtocol:
+ return "NextProtocol"
+ case typeChannelID:
+ return "ChannelID"
+ case typeMessageHash:
+ return "MessageHash"
+ }
+ return fmt.Sprintf("unknown(%d)", typ)
+}
+
// TLS compression types.
const (
compressionNone uint8 = 0
diff --git a/ssl/test/runner/conn.go b/ssl/test/runner/conn.go
index d262507..a3ca817 100644
--- a/ssl/test/runner/conn.go
+++ b/ssl/test/runner/conn.go
@@ -1447,8 +1447,9 @@
return nil, err
}
+ typ := data[0]
var m handshakeMessage
- switch data[0] {
+ switch typ {
case typeHelloRequest:
m = new(helloRequestMsg)
case typeClientHello:
@@ -1523,7 +1524,8 @@
}
if !m.unmarshal(data) {
- return nil, c.in.setErrorLocked(c.sendAlert(alertDecodeError))
+ c.sendAlert(alertDecodeError)
+ return nil, c.in.setErrorLocked(fmt.Errorf("tls: error decoding %s message", messageTypeToString(typ)))
}
return m, nil
}