Documentation ¶
Index ¶
- Variables
- func Listen(network, laddr string, config *Config) (net.Listener, error)
- func NewListener(inner net.Listener, config *Config) net.Listener
- type ApplicationSuite
- type Certificate
- type CertificatePair
- type CertificateType
- type Config
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) Handshake() error
- func (c *Conn) HandshakeContext(ctx context.Context) error
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) Read(b []byte) (int, error)
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) SetDeadline(t time.Time) error
- func (c *Conn) SetReadDeadline(t time.Time) error
- func (c *Conn) SetWriteDeadline(t time.Time) error
- func (c *Conn) State() (state State)
- func (c *Conn) Write(d []byte) (int, error)
- type Dialer
- type ErrorCode
- type ErrorFrame
- type Extension
- type ExtensionType
- type FinishFrame
- type Frame
- type FrameType
- type HandshakeSuite
- type HostnameId
- type HostnameIdType
- type HostnamePSK
- type HostnameType
- type InfoFrame
- type InitHello
- type InitHelloState
- type Marshaller
- type ResponseHello
- func (ch *ResponseHello) Marshal() ([]byte, error)
- func (ch *ResponseHello) MarshalEncrypted(c cipher.AEAD, rand io.Reader) ([]byte, error)
- func (ch *ResponseHello) Unmarshal(d []byte) (err error)
- func (ch *ResponseHello) UnmarshalEncrypted(d []byte, c cipher.AEAD) (err error)
- func (ch *ResponseHello) UnmarshalPartial(d []byte) (err error)
- type ResponseHelloState
- type State
- type Suite
- type Unmarshaller
Constants ¶
This section is empty.
Variables ¶
var (
ErrorInvalidFrameType = errors.New("unknown frame type")
)
Functions ¶
func Listen ¶
Listen creates a STL listener accepting connections on the given network address using net.Listen.
func NewListener ¶
NewListener creates a Listener which accepts connections from an inner Listener and wraps each connection with Server. The configuration config must be non-nil and must include at least one certificate or else set GetCertificate.
Types ¶
type ApplicationSuite ¶
type ApplicationSuite uint8
const ( AppSuiteNotSet ApplicationSuite = iota AES128gcm AES256gcm Chacha20_poly1305 )
type Certificate ¶
type Certificate struct { CertificateType CertificateType Length uint16 Certificate []byte Verify []byte }
func (*Certificate) Marshal ¶
func (c *Certificate) Marshal() ([]byte, error)
func (*Certificate) Unmarshal ¶
func (c *Certificate) Unmarshal(d []byte) error
type CertificatePair ¶
type CertificatePair struct { CertType CertificateType Certificate [][]byte PrivateKey crypto.PrivateKey }
func CKIKeyPair ¶
func CKIKeyPair(certPEMBlock, keyPEMBlock []byte) (CertificatePair, error)
func LoadCKIKeyPair ¶
func LoadCKIKeyPair(certFile, keyFile string) (CertificatePair, error)
func LoadX509KeyPair ¶
func LoadX509KeyPair(certFile, keyFile string) (CertificatePair, error)
func X509KeyPair ¶
func X509KeyPair(certPEMBlock, keyPEMBlock []byte) (CertificatePair, error)
type CertificateType ¶
type CertificateType uint8
const ( CertificateType_CKI CertificateType = iota CertificateType_X509 )
type Config ¶
type Config struct { Hostname string HostnameMode HostnameType PreferredCurve HandshakeSuite NextProto string Certificates []CertificatePair ClientAuth bool ClientCAPool cki.CertPool GetCertificate func(*InitHello) (*CertificatePair, error) AllowedTimeDiff time.Duration Rand io.Reader Time func() time.Time SkipCertificateVerification bool RootCertificates []*Certificate }
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
func Dial ¶
Dial connects to the given network address using net.Dial and then initiates a STL handshake, returning the resulting STL connection. Dial interprets a nil configuration as equivalent to the zero configuration; see the documentation of Config for the defaults.
func DialWithDialer ¶
DialWithDialer connects to the given network address using dialer.Dial and then initiates a STL handshake, returning the resulting STL connection. Any timeout or deadline given in the dialer apply to connection and STL handshake as a whole.
DialWithDialer interprets a nil configuration as equivalent to the zero configuration; see the documentation of Config for the defaults.
DialWithDialer uses context.Background internally; to specify the context, use Dialer.DialContext with NetDialer set to the desired dialer.
func Responder ¶
Server returns a new STL responder side connection using conn as the underlying transport.
func (*Conn) RemoteAddr ¶
RemoteAddr returns the remote network address.
func (*Conn) SetDeadline ¶
SetDeadline sets the read and write deadlines associated with the connection. A zero value for t means Read and Write will not time out. After a Write has timed out, the TLS state is corrupt and all future writes will return the same error.
func (*Conn) SetReadDeadline ¶
SetReadDeadline sets the read deadline on the underlying connection. A zero value for t means Read will not time out.
func (*Conn) SetWriteDeadline ¶
SetWriteDeadline sets the write deadline on the underlying connection. A zero value for t means Write will not time out. After a Write has timed out, the TLS state is corrupt and all future writes will return the same error.
type Dialer ¶
type Dialer struct { // NetDialer is the optional dialer to use for the STL connections' // underlying TCP connections. // A nil NetDialer is equivalent to the net.Dialer zero value. NetDialer *net.Dialer // Config is the STL configuration to use for new connections. // A nil configuration is equivalent to the zero // configuration; see the documentation of Config for the // defaults. Config *Config }
Dialer dials STL connections given a configuration and a Dialer for the underlying connection.
func (*Dialer) Dial ¶
Dial connects to the given network address and initiates a STL handshake, returning the resulting STL connection.
The returned Conn, if any, will always be of type *Conn.
Dial uses context.Background internally; to specify the context, use DialContext.
func (*Dialer) DialContext ¶
DialContext connects to the given network address and initiates a STL handshake, returning the resulting STL connection.
The provided Context must be non-nil. If the context expires before the connection is complete, an error is returned. Once successfully connected, any expiration of the context will not affect the connection.
The returned Conn, if any, will always be of type *Conn.
type ErrorFrame ¶
type ErrorFrame struct {
Code ErrorCode
}
func (*ErrorFrame) Error ¶
func (ef *ErrorFrame) Error() string
func (*ErrorFrame) Marshal ¶
func (ef *ErrorFrame) Marshal() ([]byte, error)
func (*ErrorFrame) Unmarshal ¶
func (ef *ErrorFrame) Unmarshal(d []byte) error
func (*ErrorFrame) WriteTo ¶
func (ef *ErrorFrame) WriteTo(w io.Writer)
type Extension ¶
type Extension struct { ExtType ExtensionType Data []byte }
type ExtensionType ¶
type ExtensionType byte
const ( ExtensionType_Certificate ExtensionType = iota + 1 ExtensionType_CertificateRequest ExtensionType_Name ExtensionType_NameRequest ExtensionType_EarlyData ExtensionType_HostnameId ExtensionType_NextProto )
type FinishFrame ¶
type FinishFrame struct{}
func (*FinishFrame) Marshal ¶
func (ff *FinishFrame) Marshal() ([]byte, error)
func (*FinishFrame) Unmarshal ¶
func (ff *FinishFrame) Unmarshal(d []byte) error
type Frame ¶
func (*Frame) MarshalBinary ¶
type HandshakeSuite ¶
type HandshakeSuite uint8
const ( HsSuiteNotSet HandshakeSuite = iota ECDHE_x25519 ECDHE_p386 ECDHE_p256 DBVF6_pn14qp438 )
type HostnameId ¶
type HostnameId struct { HostnameIdType HostnameIdType KeyIdLength uint8 KeyId []byte Data []byte }
func (*HostnameId) Marshal ¶
func (h *HostnameId) Marshal() ([]byte, error)
type HostnameIdType ¶
type HostnameIdType uint8
const ( HostnameIdType_UnknownType HostnameIdType = iota HostnameIdType_HMAC HostnameIdType_PSK )
type HostnamePSK ¶
type HostnamePSK struct { Suite ApplicationSuite CertID []byte PublicKey []byte Data []byte }
type HostnameType ¶
type HostnameType byte
const ( HostnameType_unknown HostnameType = iota HostnameType_IP HostnameType_DNS HostnameType_PSK HostnameType_OnRequest )
type InitHello ¶
type InitHelloState ¶
type InitHelloState struct {
// contains filtered or unexported fields
}
type Marshaller ¶
type ResponseHello ¶
type ResponseHello struct { Version byte Suite Suite Key []byte Epoch uint32 Random [32]byte Extensions []Extension }
func (*ResponseHello) Marshal ¶
func (ch *ResponseHello) Marshal() ([]byte, error)
func (*ResponseHello) MarshalEncrypted ¶
func (*ResponseHello) Unmarshal ¶
func (ch *ResponseHello) Unmarshal(d []byte) (err error)
func (*ResponseHello) UnmarshalEncrypted ¶
func (ch *ResponseHello) UnmarshalEncrypted(d []byte, c cipher.AEAD) (err error)
func (*ResponseHello) UnmarshalPartial ¶
func (ch *ResponseHello) UnmarshalPartial(d []byte) (err error)
type ResponseHelloState ¶
type ResponseHelloState struct {
// contains filtered or unexported fields
}
type Suite ¶
type Suite struct { Handshake HandshakeSuite Application ApplicationSuite }