noise

package
v1.8.7 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2022 License: MIT, Apache-2.0, MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const ID = "/noise"

ID is the protocol ID for noise

View Source
const LengthPrefixLength = 2

LengthPrefixLength is the length of the length prefix itself, which precedes all transport messages in order to delimit them. In bytes.

MaxPlaintextLength is the maximum payload size. It is MaxTransportMsgLength minus the MAC size. Payloads over this size will be automatically chunked.

View Source
const MaxTransportMsgLength = 0xffff

MaxTransportMsgLength is the Noise-imposed maximum transport message length, inclusive of the MAC size (16 bytes, Poly1305 for noise-libp2p).

Variables

This section is empty.

Functions

This section is empty.

Types

type EarlyDataHandler

type EarlyDataHandler interface {
	// Send is called for the client before sending the first handshake message.
	Send(context.Context, net.Conn, peer.ID) []byte
	// Received is called for the server when the first handshake message from the client is received.
	Received(context.Context, net.Conn, []byte) error
}

EarlyDataHandler allows attaching an (unencrypted) application payload to the first handshake message. While unencrypted, the integrity of this early data is retroactively authenticated on completion of the handshake.

type SessionOption

type SessionOption = func(*SessionTransport) error

func EarlyData

func EarlyData(h EarlyDataHandler) SessionOption

func Prologue

func Prologue(prologue []byte) SessionOption

Prologue sets a prologue for the Noise session. The handshake will only complete successfully if both parties set the same prologue. See https://noiseprotocol.org/noise.html#prologue for details.

type SessionTransport

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

SessionTransport can be used to provide per-connection options

func (*SessionTransport) SecureInbound

func (i *SessionTransport) SecureInbound(ctx context.Context, insecure net.Conn, p peer.ID) (sec.SecureConn, error)

SecureInbound runs the Noise handshake as the responder. If p is empty, connections from any peer are accepted.

func (*SessionTransport) SecureOutbound

func (i *SessionTransport) SecureOutbound(ctx context.Context, insecure net.Conn, p peer.ID) (sec.SecureConn, error)

SecureOutbound runs the Noise handshake as the initiator.

type Transport

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

Transport implements the interface sec.SecureTransport https://godoc.org/github.com/John-LittleBearLabs/go-libp2p/core/sec#SecureConn

func New

func New(privkey crypto.PrivKey) (*Transport, error)

New creates a new Noise transport using the given private key as its libp2p identity key.

func (*Transport) SecureInbound

func (t *Transport) SecureInbound(ctx context.Context, insecure net.Conn, p peer.ID) (sec.SecureConn, error)

SecureInbound runs the Noise handshake as the responder. If p is empty, connections from any peer are accepted.

func (*Transport) SecureOutbound

func (t *Transport) SecureOutbound(ctx context.Context, insecure net.Conn, p peer.ID) (sec.SecureConn, error)

SecureOutbound runs the Noise handshake as the initiator.

func (*Transport) WithSessionOptions

func (t *Transport) WithSessionOptions(opts ...SessionOption) (sec.SecureTransport, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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