extension

package
v0.0.0-...-5e97d5f Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package extension implements the extension values in the ClientHello/ServerHello

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrALPNInvalidFormat is raised when the ALPN format is invalid
	ErrALPNInvalidFormat = &protocol.FatalError{Err: errors.New("invalid alpn format")} //nolint:goerr113

)

Functions

func ALPNProtocolSelection

func ALPNProtocolSelection(supportedProtocols, peerSupportedProtocols []string) (string, error)

ALPNProtocolSelection negotiates a shared protocol according to #3.2 of rfc7301

func Marshal

func Marshal(e []Extension) ([]byte, error)

Marshal many extensions at once

Types

type ALPN

type ALPN struct {
	ProtocolNameList []string
}

ALPN is a TLS extension for application-layer protocol negotiation within the TLS handshake.

https://tools.ietf.org/html/rfc7301

func (*ALPN) Marshal

func (a *ALPN) Marshal() ([]byte, error)

Marshal encodes the extension

func (ALPN) TypeValue

func (a ALPN) TypeValue() TypeValue

TypeValue returns the extension TypeValue

func (*ALPN) Unmarshal

func (a *ALPN) Unmarshal(data []byte) error

Unmarshal populates the extension from encoded data

type Extension

type Extension interface {
	Marshal() ([]byte, error)
	Unmarshal(data []byte) error
	TypeValue() TypeValue
}

Extension represents a single TLS extension

func Unmarshal

func Unmarshal(buf []byte) ([]Extension, error)

Unmarshal many extensions at once

type RenegotiationInfo

type RenegotiationInfo struct {
	RenegotiatedConnection uint8
}

RenegotiationInfo allows a Client/Server to communicate their renegotation support

https://tools.ietf.org/html/rfc5746

func (*RenegotiationInfo) Marshal

func (r *RenegotiationInfo) Marshal() ([]byte, error)

Marshal encodes the extension

func (RenegotiationInfo) TypeValue

func (r RenegotiationInfo) TypeValue() TypeValue

TypeValue returns the extension TypeValue

func (*RenegotiationInfo) Unmarshal

func (r *RenegotiationInfo) Unmarshal(data []byte) error

Unmarshal populates the extension from encoded data

type SRTPProtectionProfile

type SRTPProtectionProfile uint16

SRTPProtectionProfile defines the parameters and options that are in effect for the SRTP processing https://tools.ietf.org/html/rfc5764#section-4.1.2

const (
	SRTP_AES128_CM_HMAC_SHA1_80 SRTPProtectionProfile = 0x0001 // nolint
	SRTP_AES128_CM_HMAC_SHA1_32 SRTPProtectionProfile = 0x0002 // nolint
	SRTP_AEAD_AES_128_GCM       SRTPProtectionProfile = 0x0007 // nolint
	SRTP_AEAD_AES_256_GCM       SRTPProtectionProfile = 0x0008 // nolint
)

type ServerName

type ServerName struct {
	ServerName string
}

ServerName allows the client to inform the server the specific name it wishes to contact. Useful if multiple DNS names resolve to one IP

https://tools.ietf.org/html/rfc6066#section-3

func (*ServerName) Marshal

func (s *ServerName) Marshal() ([]byte, error)

Marshal encodes the extension

func (ServerName) TypeValue

func (s ServerName) TypeValue() TypeValue

TypeValue returns the extension TypeValue

func (*ServerName) Unmarshal

func (s *ServerName) Unmarshal(data []byte) error

Unmarshal populates the extension from encoded data

type SupportedEllipticCurves

type SupportedEllipticCurves struct {
	EllipticCurves []elliptic.Curve
}

SupportedEllipticCurves allows a Client/Server to communicate what curves they both support

https://tools.ietf.org/html/rfc8422#section-5.1.1

func (*SupportedEllipticCurves) Marshal

func (s *SupportedEllipticCurves) Marshal() ([]byte, error)

Marshal encodes the extension

func (SupportedEllipticCurves) TypeValue

func (s SupportedEllipticCurves) TypeValue() TypeValue

TypeValue returns the extension TypeValue

func (*SupportedEllipticCurves) Unmarshal

func (s *SupportedEllipticCurves) Unmarshal(data []byte) error

Unmarshal populates the extension from encoded data

type SupportedPointFormats

type SupportedPointFormats struct {
	PointFormats []elliptic.CurvePointFormat
}

SupportedPointFormats allows a Client/Server to negotiate the EllipticCurvePointFormats

https://tools.ietf.org/html/rfc4492#section-5.1.2

func (*SupportedPointFormats) Marshal

func (s *SupportedPointFormats) Marshal() ([]byte, error)

Marshal encodes the extension

func (SupportedPointFormats) TypeValue

func (s SupportedPointFormats) TypeValue() TypeValue

TypeValue returns the extension TypeValue

func (*SupportedPointFormats) Unmarshal

func (s *SupportedPointFormats) Unmarshal(data []byte) error

Unmarshal populates the extension from encoded data

type SupportedSignatureAlgorithms

type SupportedSignatureAlgorithms struct {
	SignatureHashAlgorithms []signaturehash.Algorithm
}

SupportedSignatureAlgorithms allows a Client/Server to negotiate what SignatureHash Algorithms they both support

https://tools.ietf.org/html/rfc5246#section-7.4.1.4.1

func (*SupportedSignatureAlgorithms) Marshal

func (s *SupportedSignatureAlgorithms) Marshal() ([]byte, error)

Marshal encodes the extension

func (SupportedSignatureAlgorithms) TypeValue

TypeValue returns the extension TypeValue

func (*SupportedSignatureAlgorithms) Unmarshal

func (s *SupportedSignatureAlgorithms) Unmarshal(data []byte) error

Unmarshal populates the extension from encoded data

type TypeValue

type TypeValue uint16

TypeValue is the 2 byte value for a TLS Extension as registered in the IANA

https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml

const (
	ServerNameTypeValue                   TypeValue = 0
	SupportedEllipticCurvesTypeValue      TypeValue = 10
	SupportedPointFormatsTypeValue        TypeValue = 11
	SupportedSignatureAlgorithmsTypeValue TypeValue = 13
	UseSRTPTypeValue                      TypeValue = 14
	ALPNTypeValue                         TypeValue = 16
	UseExtendedMasterSecretTypeValue      TypeValue = 23
	RenegotiationInfoTypeValue            TypeValue = 65281
)

TypeValue constants

type UseExtendedMasterSecret

type UseExtendedMasterSecret struct {
	Supported bool
}

UseExtendedMasterSecret defines a TLS extension that contextually binds the master secret to a log of the full handshake that computes it, thus preventing MITM attacks.

func (*UseExtendedMasterSecret) Marshal

func (u *UseExtendedMasterSecret) Marshal() ([]byte, error)

Marshal encodes the extension

func (UseExtendedMasterSecret) TypeValue

func (u UseExtendedMasterSecret) TypeValue() TypeValue

TypeValue returns the extension TypeValue

func (*UseExtendedMasterSecret) Unmarshal

func (u *UseExtendedMasterSecret) Unmarshal(data []byte) error

Unmarshal populates the extension from encoded data

type UseSRTP

type UseSRTP struct {
	ProtectionProfiles []SRTPProtectionProfile
}

UseSRTP allows a Client/Server to negotiate what SRTPProtectionProfiles they both support

https://tools.ietf.org/html/rfc8422

func (*UseSRTP) Marshal

func (u *UseSRTP) Marshal() ([]byte, error)

Marshal encodes the extension

func (UseSRTP) TypeValue

func (u UseSRTP) TypeValue() TypeValue

TypeValue returns the extension TypeValue

func (*UseSRTP) Unmarshal

func (u *UseSRTP) Unmarshal(data []byte) error

Unmarshal populates the extension from encoded data

Jump to

Keyboard shortcuts

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