crypto

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package crypto provides CryptState for UDP voice packet encryption. Supports legacy mode (OCB2-AES128) and secure mode (AES-256-GCM).

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDecryptFailed  = errors.New("crypto: decryption failed")
	ErrInvalidPacket  = errors.New("crypto: invalid packet")
	ErrReplayDetected = errors.New("crypto: replay detected")
)

Functions

This section is empty.

Types

type CryptState

type CryptState struct {

	// Stats
	Good   uint32
	Late   uint32
	Lost   uint32
	Resync uint32
	// contains filtered or unexported fields
}

CryptState handles AEAD encryption/decryption of UDP voice packets.

func NewCryptState

func NewCryptState(mode Mode) *CryptState

NewCryptState creates a CryptState for the given mode.

func (*CryptState) Decrypt

func (c *CryptState) Decrypt(dst, src []byte) error

Decrypt decrypts src into dst. Returns error on failure.

func (*CryptState) EncNonce

func (c *CryptState) EncNonce() []byte

EncNonce returns a copy of the encryption nonce (for CryptSetup resync response).

func (*CryptState) Encrypt

func (c *CryptState) Encrypt(dst, src []byte) error

Encrypt encrypts src into dst. Dst must have length len(src)+Overhead().

func (*CryptState) GenerateKey

func (c *CryptState) GenerateKey() error

GenerateKey creates random key and nonces for the configured mode.

func (*CryptState) Mode

func (c *CryptState) Mode() Mode

Mode returns the encryption mode.

func (*CryptState) Overhead

func (c *CryptState) Overhead() int

Overhead returns the per-packet encryption overhead in bytes.

func (*CryptState) SetDecNonce

func (c *CryptState) SetDecNonce(nonce []byte) error

SetDecNonce updates the decryption nonce (when client sends ClientNonce during resync).

func (*CryptState) SetKey

func (c *CryptState) SetKey(key, encNonce, decNonce []byte) error

SetKey configures the key and nonces (from CryptSetup message).

type Mode

type Mode int

Mode selects the encryption algorithm.

const (
	ModeLite Mode = iota
	ModeLegacy
	ModeSecure
)

Directories

Path Synopsis
Package ocb2 implements OCB2-AES128 for Mumble legacy mode compatibility.
Package ocb2 implements OCB2-AES128 for Mumble legacy mode compatibility.

Jump to

Keyboard shortcuts

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