Skip to content

PacketCipher

Defined in: packages/voice/src/crypto.ts:101

Seals and opens RTP packets for one voice session (“rtpsize” AEAD modes): the RTP header (and extension header) is authenticated, the rest is encrypted, and a 32-bit nonce counter is appended to the packet. The full nonce is that counter followed by zeros (12 bytes for AES-GCM, 24 for XChaCha20-Poly1305).

new PacketCipher(mode, key, counter?): PacketCipher

Defined in: packages/voice/src/crypto.ts:107

VoiceEncryptionMode

Uint8Array

number = 0

First nonce counter (default 0).

PacketCipher

readonly mode: VoiceEncryptionMode

Defined in: packages/voice/src/crypto.ts:102

get counter(): number

Defined in: packages/voice/src/crypto.ts:122

The nonce counter of the next sealed packet (wraps at 2^32).

number

open(packet): { header: RtpHeader; payload: Uint8Array; } | undefined

Defined in: packages/voice/src/crypto.ts:167

Decrypts a received datagram. Removes the encrypted extension data and RTP padding.

Uint8Array

{ header: RtpHeader; payload: Uint8Array; } | undefined

The header and the plaintext payload, or undefined when the packet is malformed or fails authentication.


seal(header, payload): Uint8Array

Defined in: packages/voice/src/crypto.ts:135

Encrypts payload under header.

Uint8Array

Uint8Array

Uint8Array

The datagram: header, ciphertext, tag, nonce suffix.