Documentation
¶
Overview ¶
Package crypto provides CryptState for UDP voice packet encryption. Supports legacy mode (OCB2-AES128) and secure mode (AES-256-GCM).
Index ¶
- Variables
- type CryptState
- func (c *CryptState) Decrypt(dst, src []byte) error
- func (c *CryptState) EncNonce() []byte
- func (c *CryptState) Encrypt(dst, src []byte) error
- func (c *CryptState) GenerateKey() error
- func (c *CryptState) Mode() Mode
- func (c *CryptState) Overhead() int
- func (c *CryptState) SetDecNonce(nonce []byte) error
- func (c *CryptState) SetKey(key, encNonce, decNonce []byte) error
- type Mode
Constants ¶
This section is empty.
Variables ¶
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) 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).