Skip to content

Simple mapping of TLS Versions and Cipher Suites to strings, in golang

License

Notifications You must be signed in to change notification settings

signalsciences/tlstext

Repository files navigation

tlstext

Actions Status Go Report Card GoDoc Coverage license

simple mapping of TLS Versions and Cipher Suites to strings

The Go TLS cipher suites and TLS versions are untyped or are uint16 and without a string representation. This also means the tool stringer can not be used.

This package provides simple functions tlstxt.Version and tlstext.CipherSuite that provide the raw value to string translations.

This intentionally does not use the constants in tls/cipher_suites.go since they are dependent on the version of Go used.

The values are generated directly from the IANA assignments

## Examples

Get string name from binary TLS version:

fmt.Println(tlstext.Version(uint16(0x0303)))


Output:

TLS12


Get cipher suite name:

fmt.Println(tlstext.CipherSuite(uint16(0xc02b)))


Output:

TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256