tlslib

package module
v0.0.0-...-9f1833e Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidTLSMsgType            = errors.New("invalid_tls_msg_type")
	ErrVersionReadFailed            = errors.New("version_read_failed")
	ErrRandomReadFailed             = errors.New("random_read_failed")
	ErrSessionIDReadFailed          = errors.New("session_id_read_failed")
	ErrCipherSuitesReadFailed       = errors.New("cipher_suites_read_failed")
	ErrCipherSuiteParseFailed       = errors.New("cipher_suite_parse_failed")
	ErrCompressionMethodsReadFailed = errors.New("compression_methods_read_failed")
	ErrCompressionMethodParseFailed = errors.New("compression_method_parse_failed")
	ErrExtensionsReadFailed         = errors.New("extensions_read_failed")
	ErrExtensionParseFailed         = errors.New("extension_parse_failed")

	ErrServerHelloReadFailed = errors.New("server_hello_read_failed")
	ErrInvalidServerHello    = errors.New("invalid_server_hello")
	ErrIncompleteServerHello = errors.New("incomplete_server_hello")

	ErrClientHelloReadFailed = errors.New("client_hello_read_failed")
	ErrInvalidClientHello    = errors.New("invalid_client_hello")
	ErrIncompleteClientHello = errors.New("incomplete_client_hello")
)
View Source
var CipherSuites = map[uint16]struct {
	Name   string
	Grease bool

}{}/* 366 elements not displayed */
View Source
var ClientHelloKey = contextKeyType(0)
View Source
var Extensions = map[uint16]struct {
	Name      string
	Reserved  bool
	Grease    bool
	Private   bool
	Reference string

}{}/* 332 elements not displayed */

Functions

func ConnContext

func ConnContext(ctx context.Context, conn net.Conn) context.Context

func JA3Fingerprint

func JA3Fingerprint(ja3string string) string

func JA3String

func JA3String(version ProtocolVersion, cipherSuites []CipherSuite, extensionList []Extension) string

func NewListener

func NewListener(inner net.Listener) net.Listener

Types

type ALPNData

type ALPNData struct {
	Raw       []byte   `json:"raw"`
	Valid     bool     `json:"valid"`
	Protocols []string `json:"protocols"`
}

type CipherSuite

type CipherSuite struct {
	Code   [2]uint8 `json:"code"`
	Name   string   `json:"name,omitempty"`
	Grease bool     `json:"grease,omitempty"`
}

func MakeCipherSuite

func MakeCipherSuite(code uint16) CipherSuite

func (CipherSuite) CodeUint16

func (c CipherSuite) CodeUint16() uint16

type ClientHelloInfo

type ClientHelloInfo struct {
	Raw []byte `json:"raw"`

	Version            ProtocolVersion     `json:"version"`
	Random             []byte              `json:"random"`
	SessionID          []byte              `json:"session_id"`
	CipherSuites       []CipherSuite       `json:"cipher_suites"`
	CompressionMethods []CompressionMethod `json:"compression_methods"`
	Extensions         []Extension         `json:"extensions"`

	Info struct {
		ServerName     *string  `json:"server_name"`
		SCTs           bool     `json:"scts"`
		Protocols      []string `json:"protocols"`
		JA3String      string   `json:"ja3_string"`
		JA3Fingerprint string   `json:"ja3_fingerprint"`
	} `json:"info"`
}

func UnmarshalClientHello

func UnmarshalClientHello(handshakeBytes []byte) (*ClientHelloInfo, error)

type CompressionMethod

type CompressionMethod uint8

func (CompressionMethod) MarshalJSON

func (m CompressionMethod) MarshalJSON() ([]byte, error)

type Conn

type Conn struct {
	net.Conn
	ClientHello []byte
	// contains filtered or unexported fields
}

func NewConn

func NewConn(conn net.Conn) (*Conn, error)

func (*Conn) Read

func (conn *Conn) Read(p []byte) (int, error)

type ECPointFormatsData

type ECPointFormatsData struct {
	Raw     []byte   `json:"raw"`
	Valid   bool     `json:"valid"`
	Formats []uint16 `json:"formats"`
}

RFC 8422

type EmptyExtensionData

type EmptyExtensionData struct {
	Raw   []byte `json:"raw"`
	Valid bool   `json:"valid"`
}

type Extension

type Extension struct {
	Type    uint16        `json:"type"`
	Name    string        `json:"name,omitempty"`
	Grease  bool          `json:"grease,omitempty"`
	Private bool          `json:"private,omitempty"`
	Data    ExtensionData `json:"data"`
}

type ExtensionData

type ExtensionData interface{}

func ParseALPNData

func ParseALPNData(raw []byte) ExtensionData

func ParseECPointFormatsData

func ParseECPointFormatsData(rawData []byte) ExtensionData

func ParseEmptyExtensionData

func ParseEmptyExtensionData(data []byte) ExtensionData

func ParseServerNameData

func ParseServerNameData(raw []byte) ExtensionData

func ParseSupportedGroupsData

func ParseSupportedGroupsData(rawData []byte) ExtensionData

func ParseUnknownExtensionData

func ParseUnknownExtensionData(data []byte) ExtensionData

type HandshakeReader

type HandshakeReader struct {
	// contains filtered or unexported fields
}

func NewHandshakeReader

func NewHandshakeReader(reader io.Reader) *HandshakeReader

func (*HandshakeReader) Read

func (r *HandshakeReader) Read(p []byte) (int, error)

func (*HandshakeReader) ReadMessage

func (reader *HandshakeReader) ReadMessage() ([]byte, error)

type ProtocolVersion

type ProtocolVersion uint16

func (ProtocolVersion) Hi

func (v ProtocolVersion) Hi() uint8

func (ProtocolVersion) Lo

func (v ProtocolVersion) Lo() uint8

func (ProtocolVersion) MarshalJSON

func (v ProtocolVersion) MarshalJSON() ([]byte, error)

type ServerHelloInfo

type ServerHelloInfo struct {
	Raw []byte `json:"raw"`

	Version            ProtocolVersion     `json:"version"`
	Random             []byte              `json:"random"`
	SessionID          []byte              `json:"session_id"`
	CipherSuites       []CipherSuite       `json:"cipher_suites"`
	CompressionMethods []CompressionMethod `json:"compression_methods"`
	Extensions         []Extension         `json:"extensions"`

	Info struct {
		SCTs           bool     `json:"scts"`
		Protocols      []string `json:"protocols"`
		JA3String      string   `json:"ja3_string"`
		JA3Fingerprint string   `json:"ja3_fingerprint"`
	} `json:"info"`
}

func UnmarshalServerHello

func UnmarshalServerHello(handshakeBytes []byte) (*ServerHelloInfo, error)

type ServerNameData

type ServerNameData struct {
	Raw      []byte `json:"raw"`
	Valid    bool   `json:"valid"`
	HostName string `json:"host_name"`
}

server_name - RFC 6066, Section 3

type SupportedGroupsData

type SupportedGroupsData struct {
	Raw    []byte   `json:"raw"`
	Valid  bool     `json:"valid"`
	Groups []uint16 `json:"groups"`
}

RFC 8422 TODO: provide info about groups beyond just the code (name, grease status, etc.)

type UnknownExtensionData

type UnknownExtensionData struct {
	Raw []byte `json:"raw"`
}

Jump to

Keyboard shortcuts

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