session

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2018 License: ISC Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDecrypt   = errors.New("decrypt failure")
	ErrOverflow  = errors.New("message too large")
	ErrInvalidKx = errors.New("invalid kx")
	ErrMarshal   = errors.New("could not marshal")
	ErrUnmarshal = errors.New("could not unmarshal")
)

Functions

func D

func D(id int, fmt string, args ...interface{})

func Init

func Init()

Init prepares the server to start responding to kx initiation requests. It calls regenerateEphemeral once, and then once every minute. If we fail to rotate our ephemeral key, we bring the server down.

func SetDiagnostic

func SetDiagnostic(f Printable)

SetDiagnostic allows a function of the Printable type to be specified as the routine to be called for instrumentation of the kx code.

Types

type KX

type KX struct {
	Conn           net.Conn
	MaxMessageSize uint
	OurPrivateKey  *[sntrup4591761.PrivateKeySize]byte
	OurPublicKey   *[sntrup4591761.PublicKeySize]byte
	TheirPublicKey *[sntrup4591761.PublicKeySize]byte
	// contains filtered or unexported fields
}

KX allows two peers to derive a pair of shared keys. One peer must trigger Initiate (the client) while the other (the server) should call Init once followed by Respond for each connection.

func (*KX) Close

func (kx *KX) Close()

func (*KX) Initiate

func (kx *KX) Initiate() error

Initiate performs a key exchange on behalf of a connecting client. A key exchange involves the following variables: k1, k2, k3, k4: NTRU Prime shared keys. c1, c2, c3, c4: NTRU Prime ciphertexts corresponding to k1, k2, k3, k4. From the perspective of the initiator, the process unfolds as follows:

func (*KX) Read

func (kx *KX) Read() ([]byte, error)

func (*KX) Respond

func (kx *KX) Respond() error

Respond performs a key exchange on behalf of a responding server. A key exchange involves the following variables: k1, k2, k3, k4: NTRU Prime shared keys. c1, c2, c3, c4: NTRU Prime ciphertexts corresponding to k1, k2, k3, k4. From the perspective of the responder, the process unfolds as follows:

func (*KX) SetReadDeadline

func (kx *KX) SetReadDeadline(t time.Time)

func (*KX) SetWriteDeadline

func (kx *KX) SetWriteDeadline(t time.Time)

func (*KX) TheirIdentity

func (kx *KX) TheirIdentity() interface{}

func (*KX) Write

func (kx *KX) Write(data []byte) error

Write encrypts and marshals data to the underlying writer.

type Printable

type Printable func(int, string, ...interface{})

Jump to

Keyboard shortcuts

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