noise

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package noise implements the Noise_NNpsk0_25519_ChaChaPoly_SHA256 handshake pattern from the Noise Protocol Framework (revision 34), which is all of Noise that mote needs: an ephemeral-ephemeral key agreement mixed with a pre-shared key established out of band (by the CPace exchange).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CipherState

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

A CipherState encrypts or decrypts a sequence of messages with a key and an incrementing nonce, as defined in Noise §5.1.

func (*CipherState) Decrypt

func (c *CipherState) Decrypt(out, ad, ciphertext []byte) ([]byte, error)

Decrypt appends to out the decryption of ciphertext with associated data ad, using and incrementing the nonce counter.

func (*CipherState) Encrypt

func (c *CipherState) Encrypt(out, ad, plaintext []byte) ([]byte, error)

Encrypt appends to out the encryption of plaintext with associated data ad, using and incrementing the nonce counter.

type HandshakeState

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

A HandshakeState runs the two-message NNpsk0 handshake:

-> psk, e
<- e, ee

Once WriteMessage or ReadMessage returns an error, the HandshakeState is dead and every later call returns an error too.

func NewHandshakeState

func NewHandshakeState(initiator bool, psk []byte) (*HandshakeState, error)

NewHandshakeState returns a HandshakeState using the 32-byte pre-shared key psk. The initiator sends the first message.

func (*HandshakeState) ReadMessage

func (hs *HandshakeState) ReadMessage(out, message []byte) ([]byte, *CipherState, *CipherState, error)

ReadMessage processes the next handshake message, appending the decrypted payload to out. On the final handshake message it also returns the two transport cipher states, in the order returned by split.

func (*HandshakeState) WriteMessage

func (hs *HandshakeState) WriteMessage(out, payload []byte) ([]byte, *CipherState, *CipherState, error)

WriteMessage appends the next handshake message, carrying the encrypted payload, to out. On the final handshake message it also returns the two transport cipher states, in the order returned by split.

Jump to

Keyboard shortcuts

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