tlstext

package module
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2020 License: MIT Imports: 2 Imported by: 12

README

tlstext

Build 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

Documentation

Overview

Package tlstext provides simple functions VersionText and CipherSuiteText that provide the raw value to string translations.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CipherFromString added in v1.2.0

func CipherFromString(s string) uint16

CipherFromString returns the uint16 value of the cipher name or 0 if unknown

func CipherSuite

func CipherSuite(x uint16) string

CipherSuite maps a TLS Cipher Suite to a string or the hex representation if unknown

Example
fmt.Println(CipherSuite(uint16(0xc02b)))
Output:

TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256

func CipherSuiteFromConnection

func CipherSuiteFromConnection(t *tls.ConnectionState) string

CipherSuiteFromConnection returns a string representation of CipherSuite or empty string if not TLS

func Version

func Version(x uint16) string

Version maps a TLS version to a string, or the hex representation if unknown.

Example
fmt.Println(Version(uint16(0x0303)))
Output:

TLS12

func VersionFromConnection

func VersionFromConnection(t *tls.ConnectionState) string

VersionFromConnection returns a string representation of CipherSuite or empty string if not TLS

func VersionFromString added in v1.2.0

func VersionFromString(s string) uint16

VersionFromString returns the uint16 value of a TLS version string, or 0 if unknown

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL