VoiceGroupCrypto
in package
implements
VoiceGroupCryptoInterface
uses
VoiceGroupCryptoTrait
Provides group-based AEAD encryption and decryption for Discord voice RTP packets.
Tags
Table of Contents
Interfaces
- VoiceGroupCryptoInterface
- Interface for group-based AEAD encryption and decryption for Discord voice RTP packets.
Constants
- SUPPORTED_MODES = ['aead_aes256_gcm_rtpsize', 'aead_xchacha20_poly1305_rtpsize']
- Supported encryption modes for voice connections.
Properties
- $mode : string
- $nonceLength : int
- $secret_key : string
Methods
- __construct() : mixed
- decryptRTPPacket() : string|false
- encryptRTPPacket() : string
- validateEncryptedRTPPacket() : bool
- Validate an encrypted RTP packet (header + encrypted payload).
- buildNonce() : string
- Build a nonce for RTP-style AEAD.
- decrypt() : string|false
- Decrypt a message from Discord's MLS Group.
- encrypt() : string
- Encrypt a message for Discord's MLS Group.
Constants
SUPPORTED_MODES
Supported encryption modes for voice connections.
public
array<string|int, string>
SUPPORTED_MODES
= ['aead_aes256_gcm_rtpsize', 'aead_xchacha20_poly1305_rtpsize']
The supported transport encryption modes.
Tags
Properties
$mode
public
string
$mode
The encryption mode.
$nonceLength
public
int
$nonceLength
Nonce length based on encryption mode.
$secret_key
public
string
$secret_key
Methods
__construct()
public
__construct(string $secret_key[, string $mode = 'aead_xchacha20_poly1305_rtpsize' ]) : mixed
Parameters
- $secret_key : string
-
Optional group secret.
- $mode : string = 'aead_xchacha20_poly1305_rtpsize'
-
The supported transport encryption mode.
decryptRTPPacket()
public
decryptRTPPacket(VoicePacket $packet[, int $seq = = '0' ]) : string|false
Decrypt an RTP packet (header + encrypted payload).
Parameters
- $packet : VoicePacket
- $seq : int = = '0'
Return values
string|falseencryptRTPPacket()
public
encryptRTPPacket(VoicePacket $packet[, int $seq = = '0' ]) : string
Encrypt an RTP packet (header + Opus payload).
Parameters
- $packet : VoicePacket
- $seq : int = = '0'
Return values
stringvalidateEncryptedRTPPacket()
Validate an encrypted RTP packet (header + encrypted payload).
public
static validateEncryptedRTPPacket(string $packet) : bool
Parameters
- $packet : string
-
The full RTP packet (header + encrypted payload)
Return values
bool —True if valid, false otherwise
buildNonce()
Build a nonce for RTP-style AEAD.
protected
buildNonce([string $header = '' ][, int $seq = 0 ]) : string
Parameters
- $header : string = ''
- $seq : int = 0
Return values
stringdecrypt()
Decrypt a message from Discord's MLS Group.
protected
decrypt(string $ciphertext[, string $header = '' ][, int $seq = 0 ]) : string|false
Parameters
- $ciphertext : string
- $header : string = ''
-
Optional RTP header
- $seq : int = 0
-
Optional sequence number
Return values
string|falseencrypt()
Encrypt a message for Discord's MLS Group.
protected
encrypt(string $plaintext[, string $header = '' ][, int $seq = 0 ]) : string
Parameters
- $plaintext : string
- $header : string = ''
-
Optional 12-byte RTP header (for RTP-style nonce)
- $seq : int = 0
-
Optional sequence number (for AES-GCM)