noiseconn

package
v0.0.0-...-8bb18f9 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	None uint64 = iota
	HandshakeSent
	HandshakeReceived
	HandshakeComplete
)
View Source
const (
	HandshakeSendRetries int    = 3
	StateIdle            uint64 = 0
	StateDialing         uint64 = 1
	StateAccepting       uint64 = 2
	StateComplete        uint64 = 3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

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

func NewNoiseConn

func NewNoiseConn(keypair noise.DHKey, remoteStatic []byte) *Conn

func (*Conn) Accept

func (nc *Conn) Accept() error

func (*Conn) Close

func (nc *Conn) Close() error

Close closes the noise connection, resetting the state, and requiring a new conn to be set and a new Dial or Accept call to establish a new connection.

func (*Conn) Dial

func (nc *Conn) Dial() error

func (*Conn) Read

func (nc *Conn) Read(p []byte) (int, error)

TODO: Handle receiving handshake packets during active session TODO: Handle rekeys during active session

func (*Conn) Reset

func (nc *Conn) Reset()

func (*Conn) SetConn

func (nc *Conn) SetConn(conn net.Conn)

func (*Conn) Write

func (nc *Conn) Write(p []byte) (int, error)

type NoiseState

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

func NewNoiseState

func NewNoiseState(s noise.DHKey, rs []byte) *NoiseState

func (*NoiseState) ConsumeHandshakeP1

func (ns *NoiseState) ConsumeHandshakeP1(in []byte) error

Consume handshake message p1 as responder

func (*NoiseState) ConsumeHandshakeP2

func (ns *NoiseState) ConsumeHandshakeP2(in []byte) error

Consume handshake message p2 as initiator

func (*NoiseState) Decrypt

func (ns *NoiseState) Decrypt(ciphertext, decrypted []byte, n uint64) ([]byte, error)

func (*NoiseState) Encrypt

func (ns *NoiseState) Encrypt(plaintext, encrypted []byte, n uint64) ([]byte, error)

func (*NoiseState) GenerateHandshakeP1

func (ns *NoiseState) GenerateHandshakeP1(out []byte) ([]byte, error)

Construct handshake message p1 as initiator

func (*NoiseState) GenerateHandshakeP2

func (ns *NoiseState) GenerateHandshakeP2(out []byte) ([]byte, error)

Construct handshake message p2 as responder

func (*NoiseState) Initialize

func (ns *NoiseState) Initialize(initiator bool) error

func (*NoiseState) Nonce

func (ns *NoiseState) Nonce() uint64

func (*NoiseState) Reset

func (ns *NoiseState) Reset()

Jump to

Keyboard shortcuts

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