From 2044f6fbcca48fc21733b67b666c607c26eb4e7f Mon Sep 17 00:00:00 2001 From: m00874241 Date: Fri, 24 Jan 2025 18:48:37 +0000 Subject: [PATCH] Added VersionTLS constants and VersionName(version uint16) method that turns it into a string, copied from big go --- src/crypto/tls/common.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/crypto/tls/common.go b/src/crypto/tls/common.go index caf0198e15..21a1a20f50 100644 --- a/src/crypto/tls/common.go +++ b/src/crypto/tls/common.go @@ -17,6 +17,37 @@ import ( "time" ) +const ( + VersionTLS10 = 0x0301 + VersionTLS11 = 0x0302 + VersionTLS12 = 0x0303 + VersionTLS13 = 0x0304 + + // Deprecated: SSLv3 is cryptographically broken, and is no longer + // supported by this package. See golang.org/issue/32716. + VersionSSL30 = 0x0300 +) + +// VersionName returns the name for the provided TLS version number +// (e.g. "TLS 1.3"), or a fallback representation of the value if the +// version is not implemented by this package. +func VersionName(version uint16) string { + switch version { + case VersionSSL30: + return "SSLv3" + case VersionTLS10: + return "TLS 1.0" + case VersionTLS11: + return "TLS 1.1" + case VersionTLS12: + return "TLS 1.2" + case VersionTLS13: + return "TLS 1.3" + default: + return fmt.Sprintf("0x%04X", version) + } +} + // CurveID is the type of a TLS identifier for an elliptic curve. See // https://www.iana.org/assignments/tls-parameters/tls-parameters.xml#tls-parameters-8. //