DiscordPHP Documentation

VoiceGroupCrypto
in package
implements VoiceGroupCryptoInterface uses VoiceGroupCryptoTrait

Provides group-based AEAD encryption and decryption for Discord voice RTP packets.

Tags
author

Valithor Obsidion valithor@valgorithms.com

since
10.41.0

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

Properties

$nonceLength

public int $nonceLength

Nonce length based on encryption mode.

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|false

encryptRTPPacket()

public encryptRTPPacket(VoicePacket $packet[, int $seq = = '0' ]) : string

Encrypt an RTP packet (header + Opus payload).

Parameters
$packet : VoicePacket
$seq : int = = '0'
Return values
string

validateEncryptedRTPPacket()

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
string

decrypt()

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|false

encrypt()

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)

Return values
string

        
On this page

Search results