package handshake

Import Path
	github.com/quic-go/quic-go/internal/handshake (on go.dev)

Dependency Relation
	imports 29 packages, and imported by one package


Package-Level Type Names (total 11)
/* sort by: | */
ConnectionState tls.ConnectionState CipherSuite is the cipher suite negotiated for the connection (e.g. TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_AES_128_GCM_SHA256). CurveID is the key exchange mechanism used for the connection. The name refers to elliptic curves for legacy reasons, see [CurveID]. If a legacy RSA key exchange is used, this value is zero. DidResume is true if this connection was successfully resumed from a previous session with a session ticket or similar mechanism. ECHAccepted indicates if Encrypted Client Hello was offered by the client and accepted by the server. Currently, ECH is supported only on the client side. HandshakeComplete is true if the handshake has concluded. NegotiatedProtocol is the application protocol negotiated with ALPN. NegotiatedProtocolIsMutual used to indicate a mutual NPN negotiation. Deprecated: this value is always true. OCSPResponse is a stapled Online Certificate Status Protocol (OCSP) response provided by the peer for the leaf certificate, if any. PeerCertificates are the parsed certificates sent by the peer, in the order in which they were sent. The first element is the leaf certificate that the connection is verified against. On the client side, it can't be empty. On the server side, it can be empty if Config.ClientAuth is not RequireAnyClientCert or RequireAndVerifyClientCert. PeerCertificates and its contents should not be modified. ServerName is the value of the Server Name Indication extension sent by the client. It's available both on the server and on the client side. SignedCertificateTimestamps is a list of SCTs provided by the peer through the TLS handshake for the leaf certificate, if any. TLSUnique contains the "tls-unique" channel binding value (see RFC 5929, Section 3). This value will be nil for TLS 1.3 connections and for resumed connections that don't support Extended Master Secret (RFC 7627). VerifiedChains is a list of one or more chains where the first element is PeerCertificates[0] and the last element is from Config.RootCAs (on the client side) or Config.ClientCAs (on the server side). On the client side, it's set if Config.InsecureSkipVerify is false. On the server side, it's set if Config.ClientAuth is VerifyClientCertIfGiven (and the peer provided a certificate) or RequireAndVerifyClientCert. VerifiedChains and its contents should not be modified. Version is the TLS version used by the connection (e.g. VersionTLS12). Used0RTT bool ExportKeyingMaterial returns length bytes of exported key material in a new slice as defined in RFC 5705. If context is nil, it is not used as part of the seed. If the connection was set to allow renegotiation via Config.Renegotiation, or if the connections supports neither TLS 1.3 nor Extended Master Secret, this function will return an error. Exporting key material without Extended Master Secret or TLS 1.3 was disabled in Go 1.22 due to security issues (see the Security Considerations sections of RFC 5705 and RFC 7627), but can be re-enabled with the GODEBUG setting tlsunsafeekm=1. *ConnectionState : github.com/pion/srtp/v3.KeyingMaterialExporter func CryptoSetup.ConnectionState() ConnectionState
CryptoSetup handles the handshake and protecting / unprotecting packets ( CryptoSetup) ChangeConnectionID(protocol.ConnectionID) ( CryptoSetup) Close() error ( CryptoSetup) ConnectionState() ConnectionState ( CryptoSetup) DiscardInitialKeys() ( CryptoSetup) Get0RTTOpener() (LongHeaderOpener, error) ( CryptoSetup) Get0RTTSealer() (LongHeaderSealer, error) ( CryptoSetup) Get1RTTOpener() (ShortHeaderOpener, error) ( CryptoSetup) Get1RTTSealer() (ShortHeaderSealer, error) ( CryptoSetup) GetHandshakeOpener() (LongHeaderOpener, error) ( CryptoSetup) GetHandshakeSealer() (LongHeaderSealer, error) ( CryptoSetup) GetInitialOpener() (LongHeaderOpener, error) ( CryptoSetup) GetInitialSealer() (LongHeaderSealer, error) ( CryptoSetup) GetSessionTicket() ([]byte, error) ( CryptoSetup) HandleMessage([]byte, protocol.EncryptionLevel) error ( CryptoSetup) NextEvent() Event ( CryptoSetup) SetHandshakeConfirmed() ( CryptoSetup) SetLargest1RTTAcked(protocol.PacketNumber) error ( CryptoSetup) StartHandshake(context.Context) error CryptoSetup : github.com/prometheus/common/expfmt.Closer CryptoSetup : io.Closer func NewCryptoSetupClient(connID protocol.ConnectionID, tp *wire.TransportParameters, tlsConf *tls.Config, enable0RTT bool, rttStats *utils.RTTStats, qlogger qlogwriter.Recorder, logger utils.Logger, version protocol.Version) CryptoSetup func NewCryptoSetupServer(connID protocol.ConnectionID, localAddr, remoteAddr net.Addr, tp *wire.TransportParameters, tlsConf *tls.Config, allow0RTT bool, rttStats *utils.RTTStats, qlogger qlogwriter.Recorder, logger utils.Logger, version protocol.Version) CryptoSetup
Event is a handshake event. Data []byte Kind EventKind TransportParameters *wire.TransportParameters func CryptoSetup.NextEvent() Event
EventKind is the kind of handshake event. ( EventKind) String() string EventKind : expvar.Var EventKind : fmt.Stringer const EventDiscard0RTTKeys const EventHandshakeComplete const EventNoEvent const EventReceivedReadKeys const EventReceivedTransportParameters const EventRestoredTransportParameters const EventWriteHandshakeData const EventWriteInitialData
LongHeaderOpener opens a long header packet ( LongHeaderOpener) DecodePacketNumber(wirePN protocol.PacketNumber, wirePNLen protocol.PacketNumberLen) protocol.PacketNumber ( LongHeaderOpener) DecryptHeader(sample []byte, firstByte *byte, pnBytes []byte) ( LongHeaderOpener) Open(dst, src []byte, pn protocol.PacketNumber, associatedData []byte) ([]byte, error) func NewInitialAEAD(connID protocol.ConnectionID, pers protocol.Perspective, v protocol.Version) (LongHeaderSealer, LongHeaderOpener) func CryptoSetup.Get0RTTOpener() (LongHeaderOpener, error) func CryptoSetup.GetHandshakeOpener() (LongHeaderOpener, error) func CryptoSetup.GetInitialOpener() (LongHeaderOpener, error)
LongHeaderSealer seals a long header packet ( LongHeaderSealer) EncryptHeader(sample []byte, firstByte *byte, pnBytes []byte) ( LongHeaderSealer) Overhead() int ( LongHeaderSealer) Seal(dst, src []byte, packetNumber protocol.PacketNumber, associatedData []byte) []byte ShortHeaderSealer (interface) func NewInitialAEAD(connID protocol.ConnectionID, pers protocol.Perspective, v protocol.Version) (LongHeaderSealer, LongHeaderOpener) func CryptoSetup.Get0RTTSealer() (LongHeaderSealer, error) func CryptoSetup.GetHandshakeSealer() (LongHeaderSealer, error) func CryptoSetup.GetInitialSealer() (LongHeaderSealer, error)
ShortHeaderOpener opens a short header packet ( ShortHeaderOpener) DecodePacketNumber(wirePN protocol.PacketNumber, wirePNLen protocol.PacketNumberLen) protocol.PacketNumber ( ShortHeaderOpener) DecryptHeader(sample []byte, firstByte *byte, pnBytes []byte) ( ShortHeaderOpener) Open(dst, src []byte, rcvTime monotime.Time, pn protocol.PacketNumber, kp protocol.KeyPhaseBit, associatedData []byte) ([]byte, error) func CryptoSetup.Get1RTTOpener() (ShortHeaderOpener, error)
ShortHeaderSealer seals a short header packet ( ShortHeaderSealer) EncryptHeader(sample []byte, firstByte *byte, pnBytes []byte) ( ShortHeaderSealer) KeyPhase() protocol.KeyPhaseBit ( ShortHeaderSealer) Overhead() int ( ShortHeaderSealer) Seal(dst, src []byte, packetNumber protocol.PacketNumber, associatedData []byte) []byte ShortHeaderSealer : LongHeaderSealer func CryptoSetup.Get1RTTSealer() (ShortHeaderSealer, error)
A Token is derived from the client address and can be used to verify the ownership of this address. IsRetryToken bool only set for retry tokens only set for tokens sent in NEW_TOKEN frames RetrySrcConnectionID protocol.ConnectionID SentTime time.Time ValidateRemoteAddr validates the address, but does not check expiration func (*TokenGenerator).DecodeToken(encrypted []byte) (*Token, error)
A TokenGenerator generates tokens DecodeToken decodes a token NewRetryToken generates a new token for a Retry for a given source address NewToken generates a new token to be sent in a NEW_TOKEN frame func NewTokenGenerator(key TokenProtectorKey) *TokenGenerator
TokenProtectorKey is the key used to encrypt both Retry and session resumption tokens. func NewTokenGenerator(key TokenProtectorKey) *TokenGenerator
Package-Level Functions (total 6)
GetRetryIntegrityTag calculates the integrity tag on a Retry packet
NewCryptoSetupClient creates a new crypto setup for the client
NewCryptoSetupServer creates a new crypto setup for the server
NewInitialAEAD creates a new AEAD for Initial encryption / decryption.
NewTokenGenerator initializes a new TokenGenerator
func SetKeyUpdateInterval(v uint64) (reset func())
Package-Level Variables (total 5)
ErrDecryptionFailed is returned when the AEAD fails to open the packet.
ErrKeysDropped is returned when an opener or a sealer is requested for an encryption level, but the corresponding keys have already been dropped.
ErrKeysNotYetAvailable is returned when an opener or a sealer is requested for an encryption level, but the corresponding opener has not yet been initialized This can happen when packets arrive out of order.
FirstKeyUpdateInterval is the maximum number of packets we send or receive before initiating the first key update. It's a package-level variable to allow modifying it for testing purposes.
Package-Level Constants (total 8)
EventDiscard0RTTKeys signals that the Handshake keys were discarded.
EventHandshakeComplete signals that the TLS handshake was completed.
EventNoEvent signals that there are no new handshake events
EventReceivedReadKeys signals that new decryption keys are available. It doesn't say which encryption level those keys are for.
EventReceivedTransportParameters contains the transport parameters sent by the peer.
EventRestoredTransportParameters contains the transport parameters restored from the session ticket. It is only used for the client.
EventWriteHandshakeData contains new CRYPTO data to send at the Handshake encryption level
EventWriteInitialData contains new CRYPTO data to send at the Initial encryption level