handshake

package
v0.4.0-3 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultTimeout = 30 * time.Second
	DefaultFilter  = Filter(nil)
)

Functions

This section is empty.

Types

type Filter added in v0.4.0

type Filter interface {
	Filter(id.Signatory) bool
}

A Filter for identities that are established during a handshake. Although the handshake may be successful, the actual identity may want to be rejected because of some application-level logic. Filters are a hook for implementing such logic.

type GCMSession added in v0.4.0

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

func (GCMSession) Decrypt added in v0.4.0

func (session GCMSession) Decrypt(p []byte) ([]byte, error)

func (GCMSession) Encrypt added in v0.4.0

func (session GCMSession) Encrypt(p []byte) ([]byte, error)

func (GCMSession) RemoteSignatory added in v0.4.0

func (session GCMSession) RemoteSignatory() id.Signatory

type Handshaker

type Handshaker interface {
	// Handshake with a remote server by initiating, and then interactively
	// completing, a handshake protocol. The remote server is accessed by
	// reading/writing to the `io.ReaderWriter`.
	Handshake(ctx context.Context, c net.Conn) (Session, error)

	// AcceptHandshake from a remote client by waiting for the initiation of,
	// and then interactively completing, a handshake protocol. The remote
	// client is accessed by reading/writing to the `io.ReaderWriter`.
	AcceptHandshake(ctx context.Context, c net.Conn) (Session, error)
}

func NewECDSA added in v0.4.0

func NewECDSA(opts Options) Handshaker

NewECDSA returns a new Handshaker that uses ECDSA to establish a connection that is authenticated and encrypted using GCM.

func NewInsecure added in v0.4.0

func NewInsecure(opts Options) Handshaker

NewInsecure returns a new Handshaker that implements no authentication, encryption, or restrictions on connections.

type Options added in v0.4.0

type Options struct {
	Logger  logrus.FieldLogger
	PrivKey *ecdsa.PrivateKey
	Timeout time.Duration
	Filter  Filter
}

func DefaultOptions added in v0.4.0

func DefaultOptions() Options

func (Options) WithFilter added in v0.4.0

func (opts Options) WithFilter(filter Filter) Options

func (Options) WithLogger added in v0.4.0

func (opts Options) WithLogger(logger logrus.FieldLogger) Options

func (Options) WithPrivKey added in v0.4.0

func (opts Options) WithPrivKey(privKey *ecdsa.PrivateKey) Options

func (Options) WithTimeout added in v0.4.0

func (opts Options) WithTimeout(timeout time.Duration) Options

type Session added in v0.4.0

type Session interface {
	// Encrypt data for the other Signatory.
	Encrypt([]byte) ([]byte, error)
	// Decrypt data from the other Signatory.
	Decrypt([]byte) ([]byte, error)
	// RemoteSignatory returns the pubkey hash of the Signatory that is on the
	// remote end of the Session.
	RemoteSignatory() id.Signatory
}

func NewGCMSession added in v0.3.0

func NewGCMSession(key []byte, other id.Signatory) (Session, error)

Jump to

Keyboard shortcuts

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