config

package
v4.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package config contains internal handshake configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterCipherSuitesForCertificate

func FilterCipherSuitesForCertificate(
	cert *tls.Certificate,
	cipherSuites []cryptosuite.Suite,
) []cryptosuite.Suite

func NormalizeProtocolVersionRange

func NormalizeProtocolVersionRange(
	minVersion, maxVersion protocol.Version,
) (protocol.Version, protocol.Version)

NormalizeProtocolVersionRange constrains the version range to supported DTLS versions.

func SelectVersion

func SelectVersion(
	remote []protocol.Version,
	minVersion, maxVersion protocol.Version,
) (protocol.Version, bool)

SelectVersion picks the highest-preference version from remote that is within the local [minVersion, maxVersion] range.

func SupportedVersionsRange

func SupportedVersionsRange(minVersion, maxVersion protocol.Version) []protocol.Version

SupportedVersionsRange returns the supported DTLS versions from maxVersion down to minVersion, in preference order (newest first). Only DTLS 1.2 and 1.3 are emitted.

func SupportsCertificate

func SupportsCertificate(acceptableCAs [][]byte, c *tls.Certificate) error

Types

type CertificateRequestInfo

type CertificateRequestInfo struct {
	CertificateTypes []clientcertificate.Type
	AcceptableCAs    [][]byte
	SignatureSchemes []signaturehash.Algorithm
	Version          protocol.Version
}

func (*CertificateRequestInfo) SupportsCertificate

func (cri *CertificateRequestInfo) SupportsCertificate(certificate *tls.Certificate) error

type CipherSuite

type CipherSuite = cryptosuite.Suite

type ClientAuthType

type ClientAuthType int
const (
	NoClientCert ClientAuthType = iota
	RequestClientCert
	RequireAnyClientCert
	VerifyClientCertIfGiven
	RequireAndVerifyClientCert
)

type ClientHelloInfo

type ClientHelloInfo struct {
	ServerName        string
	CipherSuites      []cryptosuite.ID
	RandomBytes       [handshake.RandomBytesLength]byte
	Hello             *handshake.MessageClientHello
	HelloRetryRequest bool
	Context           func() context.Context
	Conn              net.Conn
}

type ExtendedMasterSecretType

type ExtendedMasterSecretType int
const (
	RequestExtendedMasterSecret ExtendedMasterSecretType = iota
	RequireExtendedMasterSecret
	DisableExtendedMasterSecret
)

type HandshakeConfig

type HandshakeConfig struct {
	// ECHConfigList enables initial-offer construction internally.
	ECHConfigList      []byte
	ECHKeys            []ech.Key
	GetECHKeys         func(*ClientHelloInfo) ([]ech.Key, error)
	ECHRejectionVerify func(internalstate.Active) error
	PSKIdentityLimit   int
	// SelectPSK returns the selected offer index, key, and hash, or a nil key if none match.
	SelectPSK                     func(identities [][]byte) (index int, key []byte, hash crypto.Hash, err error)
	GetPSKs                       func() ([]internalstate.PSK, error)
	LocalPSKCallback              func([]byte) ([]byte, error)
	LocalPSKIdentityHint          []byte
	LocalCipherSuites             []CipherSuite
	LocalSignatureSchemes         []signaturehash.Algorithm
	LocalCertSignatureSchemes     []signaturehash.Algorithm
	ExtendedMasterSecret          ExtendedMasterSecretType
	LocalSRTPProtectionProfiles   []SRTPProtectionProfile
	LocalSRTPMasterKeyIdentifier  []byte
	ServerName                    string
	SupportedProtocols            []string
	ClientAuth                    ClientAuthType
	LocalCertificates             []tls.Certificate
	InsecureSkipVerify            bool
	VerifyPeerCertificate         func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error
	VerifyConnection              func(internalstate.Active) error
	HasSessionStore               bool
	MaxEarlyDataSize              uint32
	EnableEarlyData               bool
	ClaimEarlyData                func(ticket []byte, expiresAt time.Time) (bool, error)
	GetSession                    func(key []byte) (internalstate.Session, error)
	SetSession                    func(key []byte, session internalstate.Session) error
	SetSessionTicket              func(key, id, secret, identity []byte, ticket internalstate.SessionTicket) error
	GetSessionTicket              func(key []byte, serverName string) (*internalstate.PSK, error)
	DelSession                    func(key []byte) error
	RootCAs                       *x509.CertPool
	ClientCAs                     *x509.CertPool
	InitialRetransmitInterval     time.Duration
	DisableRetransmitBackoff      bool
	EllipticCurves                []elliptic.Curve
	InsecureSkipHelloVerify       bool
	ReceiveCIDLength              int
	ConnectionIDGenerator         func() []byte
	EnableRRC                     bool
	HelloRandomBytesGenerator     func() [handshake.RandomBytesLength]byte
	Log                           logging.LeveledLogger
	KeyLogWriter                  io.Writer
	LocalGetCertificate           func(*ClientHelloInfo) (*tls.Certificate, error)
	LocalGetClientCertificate     func(*CertificateRequestInfo) (*tls.Certificate, error)
	InitialEpoch                  uint64
	ClientHelloMessageHook        func(handshake.MessageClientHello) handshake.Message
	ServerHelloMessageHook        func(handshake.MessageServerHello) handshake.Message
	CertificateRequestMessageHook func(handshake.Message) handshake.Message
	ResumeState                   internalstate.Active
	MinVersion                    protocol.Version
	MaxVersion                    protocol.Version
	TimerFactory                  func(time.Duration) Timer
	// contains filtered or unexported fields
}

func (*HandshakeConfig) GenerateConnectionID

func (c *HandshakeConfig) GenerateConnectionID() ([]byte, error)

GenerateConnectionID returns a CID matching the configured receive length.

func (*HandshakeConfig) GetCertificate

func (c *HandshakeConfig) GetCertificate(clientHelloInfo *ClientHelloInfo) (*tls.Certificate, error)

func (*HandshakeConfig) GetClientCertificate

func (c *HandshakeConfig) GetClientCertificate(cri *CertificateRequestInfo) (*tls.Certificate, error)

func (*HandshakeConfig) NewTimer

func (c *HandshakeConfig) NewTimer(d time.Duration) Timer

NewTimer returns a handshake timer.

func (*HandshakeConfig) SendServerName

func (c *HandshakeConfig) SendServerName() bool

SendServerName omits IP literals from SNI while retaining them for verification.

func (*HandshakeConfig) UsableServerCertificate

func (c *HandshakeConfig) UsableServerCertificate(raw [][]byte) bool

func (*HandshakeConfig) UsableSession

func (c *HandshakeConfig) UsableSession(session internalstate.Session, isClient bool) bool

UsableSession rejects legacy sessions and sessions belonging to another role.

Check role, negotiated parameters, and current authentication policy.

func (*HandshakeConfig) ValidateECHVersions

func (c *HandshakeConfig) ValidateECHVersions() error

ValidateECHVersions enforces the client version policy before sending an offer.

func (*HandshakeConfig) VerifyResumedConnection

func (c *HandshakeConfig) VerifyResumedConnection(state *internalstate.State12) error

VerifyResumedConnection applies current authentication policy after Finished.

func (*HandshakeConfig) WriteKeyLog

func (c *HandshakeConfig) WriteKeyLog(label string, clientRandom, secret []byte)

type SRTPProtectionProfile

type SRTPProtectionProfile = extension.SRTPProtectionProfile

type Timer

type Timer interface {
	C() <-chan time.Time
	Stop()
}

Timer is the timer surface used by the handshake state machines.

Jump to

Keyboard shortcuts

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