Skip to content

Commit 2044f6f

Browse files
m00874241deadprogram
m00874241
authored andcommitted
Added VersionTLS constants and VersionName(version uint16) method that turns it into a string, copied from big go
1 parent d55a89f commit 2044f6f

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/crypto/tls/common.go

+31
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,37 @@ import (
1717
"time"
1818
)
1919

20+
const (
21+
VersionTLS10 = 0x0301
22+
VersionTLS11 = 0x0302
23+
VersionTLS12 = 0x0303
24+
VersionTLS13 = 0x0304
25+
26+
// Deprecated: SSLv3 is cryptographically broken, and is no longer
27+
// supported by this package. See golang.org/issue/32716.
28+
VersionSSL30 = 0x0300
29+
)
30+
31+
// VersionName returns the name for the provided TLS version number
32+
// (e.g. "TLS 1.3"), or a fallback representation of the value if the
33+
// version is not implemented by this package.
34+
func VersionName(version uint16) string {
35+
switch version {
36+
case VersionSSL30:
37+
return "SSLv3"
38+
case VersionTLS10:
39+
return "TLS 1.0"
40+
case VersionTLS11:
41+
return "TLS 1.1"
42+
case VersionTLS12:
43+
return "TLS 1.2"
44+
case VersionTLS13:
45+
return "TLS 1.3"
46+
default:
47+
return fmt.Sprintf("0x%04X", version)
48+
}
49+
}
50+
2051
// CurveID is the type of a TLS identifier for an elliptic curve. See
2152
// https://www.iana.org/assignments/tls-parameters/tls-parameters.xml#tls-parameters-8.
2253
//

0 commit comments

Comments
 (0)