Documentation
¶
Overview ¶
Package crypto provides voice packet encryption and key management.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidCiphertext = errors.New("crypto: invalid ciphertext") ErrDecryptionFailed = errors.New("crypto: decryption failed") )
Functions ¶
func GenerateKey ¶
GenerateKey generates a random AES-128 key (16 bytes).
func GenerateToken ¶
GenerateToken generates a random token string (32 bytes, hex-like).
func HashPassword ¶
HashPassword hashes a password using Argon2id.
Types ¶
type VoiceCipher ¶
type VoiceCipher struct {
// contains filtered or unexported fields
}
VoiceCipher handles AES-128-GCM encryption for voice packets.
func NewVoiceCipher ¶
func NewVoiceCipher(key []byte) (*VoiceCipher, error)
NewVoiceCipher creates a new voice cipher from a 16-byte AES key.
func (*VoiceCipher) Decrypt ¶
func (vc *VoiceCipher) Decrypt(sessionID uint32, seqNum uint32, header, ciphertext []byte) ([]byte, error)
Decrypt decrypts an encrypted Opus frame, verifying the header as additional data.
func (*VoiceCipher) Encrypt ¶
func (vc *VoiceCipher) Encrypt(sessionID uint32, seqNum uint32, header, opus []byte) []byte
Encrypt encrypts an Opus frame, authenticating the header as additional data. Returns ciphertext with appended auth tag.
func (*VoiceCipher) Overhead ¶
func (vc *VoiceCipher) Overhead() int
Overhead returns the number of bytes the AEAD adds to the plaintext (GCM auth tag).
Click to show internal directories.
Click to hide internal directories.