noiseutil

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const EncryptLockNeeded = false

EncryptLockNeeded indicates if calls to Encrypt need a lock

Variables

CipherAESGCM is the standard noise.CipherAESGCM when boringcrypto is not enabled

View Source
var DHP256 noise.DHFunc = newNISTCurve("P256", ecdh.P256(), 32)

DHP256 is the NIST P-256 ECDH function

View Source
var DHP256PKCS11 noise.DHFunc = newNISTP11Curve("P256", ecdh.P256(), 32)

DHP256PKCS11 is the NIST P-256 ECDH function

Functions

This section is empty.

Types

type CipherState added in v1.11.0

type CipherState interface {
	// EncryptDanger encrypts and authenticates a given payload.
	//
	// out is a destination slice to hold the output of the EncryptDanger operation.
	//   - ad is additional data, which will be authenticated and appended to out, but not encrypted.
	//   - plaintext is encrypted, authenticated and appended to out.
	//   - n is a nonce value which must never be re-used with this key.
	//   - nb is a scratch buffer used to assemble the nonce.
	EncryptDanger(out, ad, plaintext []byte, n uint64, nb []byte) ([]byte, error)

	// DecryptDanger authenticates and decrypts a given payload, with the same argument shape as EncryptDanger.
	DecryptDanger(out, ad, ciphertext []byte, n uint64, nb []byte) ([]byte, error)

	// Overhead returns the AEAD tag size, or 0 if the receiver is nil.
	Overhead() int
}

CipherState is the post-handshake AEAD cipher used for the data plane. Each supported cipher has its own concrete implementation in this package with the nonce endianness hardcoded, so the encrypt/decrypt fast path avoids interface dispatch on the byte order.

func NewCipherState added in v1.11.0

func NewCipherState(s *noise.CipherState, cipherFunc noise.CipherFunc) CipherState

NewCipherState wraps the post-handshake noise.CipherState in the per-cipher type that matches cipherFunc. cipherFunc must be the same cipher used to build the noise CipherSuite that produced s.

type CipherStateAESGCM added in v1.11.0

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

CipherStateAESGCM is the data-plane wrapper for the AES-GCM AEAD cipher. AES-GCM uses big-endian nonce encoding per the Noise spec.

func NewCipherStateAESGCM added in v1.11.0

func NewCipherStateAESGCM(s *noise.CipherState) *CipherStateAESGCM

NewCipherStateAESGCM extracts the underlying AEAD from the post-handshake noise.CipherState. The caller is responsible for ensuring the noise cipher is actually AES-GCM, otherwise the type assertion still succeeds but the nonce endianness will be wrong on the wire.

func (*CipherStateAESGCM) DecryptDanger added in v1.11.0

func (s *CipherStateAESGCM) DecryptDanger(out, ad, ciphertext []byte, n uint64, nb []byte) ([]byte, error)

func (*CipherStateAESGCM) EncryptDanger added in v1.11.0

func (s *CipherStateAESGCM) EncryptDanger(out, ad, plaintext []byte, n uint64, nb []byte) ([]byte, error)

func (*CipherStateAESGCM) Overhead added in v1.11.0

func (s *CipherStateAESGCM) Overhead() int

type CipherStateChaChaPoly added in v1.11.0

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

CipherStateChaChaPoly is the data-plane wrapper for the ChaCha20-Poly1305 AEAD cipher. ChaCha20-Poly1305 uses little-endian nonce encoding per the Noise spec.

func NewCipherStateChaChaPoly added in v1.11.0

func NewCipherStateChaChaPoly(s *noise.CipherState) *CipherStateChaChaPoly

NewCipherStateChaChaPoly extracts the underlying AEAD from the post-handshake noise.CipherState. The caller is responsible for ensuring the noise cipher is actually ChaCha20-Poly1305.

func (*CipherStateChaChaPoly) DecryptDanger added in v1.11.0

func (s *CipherStateChaChaPoly) DecryptDanger(out, ad, ciphertext []byte, n uint64, nb []byte) ([]byte, error)

func (*CipherStateChaChaPoly) EncryptDanger added in v1.11.0

func (s *CipherStateChaChaPoly) EncryptDanger(out, ad, plaintext []byte, n uint64, nb []byte) ([]byte, error)

func (*CipherStateChaChaPoly) Overhead added in v1.11.0

func (s *CipherStateChaChaPoly) Overhead() int

Jump to

Keyboard shortcuts

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