diff --git a/NetCord/Gateway/Voice/Encryption/Aes256GcmRtpSizeEncryption.cs b/NetCord/Gateway/Voice/Encryption/Aes256GcmRtpSizeEncryption.cs index 8f0b56950..e5595402e 100644 --- a/NetCord/Gateway/Voice/Encryption/Aes256GcmRtpSizeEncryption.cs +++ b/NetCord/Gateway/Voice/Encryption/Aes256GcmRtpSizeEncryption.cs @@ -11,6 +11,8 @@ public sealed class Aes256GcmRtpSizeEncryption : IVoiceEncryption private const int TagSize = 16; + public static bool IsSupported => AesGcm.IsSupported; + public string Name => "aead_aes256_gcm_rtpsize"; public int Expansion => TagSize + sizeof(int); diff --git a/NetCord/Gateway/Voice/Encryption/IVoiceEncryption.cs b/NetCord/Gateway/Voice/Encryption/IVoiceEncryption.cs index 3ec6993c4..a41d2a883 100644 --- a/NetCord/Gateway/Voice/Encryption/IVoiceEncryption.cs +++ b/NetCord/Gateway/Voice/Encryption/IVoiceEncryption.cs @@ -5,6 +5,11 @@ namespace NetCord.Gateway.Voice.Encryption; /// public interface IVoiceEncryption : IDisposable { + /// + /// Indicates whether the encryption algorithm is supported on the current platform. + /// + public static abstract bool IsSupported { get; } + /// /// The name of the encryption algorithm. /// diff --git a/NetCord/Gateway/Voice/Encryption/XChaCha20Poly1305RtpSizeEncryption.cs b/NetCord/Gateway/Voice/Encryption/XChaCha20Poly1305RtpSizeEncryption.cs index 220c03099..09d94193e 100644 --- a/NetCord/Gateway/Voice/Encryption/XChaCha20Poly1305RtpSizeEncryption.cs +++ b/NetCord/Gateway/Voice/Encryption/XChaCha20Poly1305RtpSizeEncryption.cs @@ -10,6 +10,8 @@ public sealed class XChaCha20Poly1305RtpSizeEncryption : IVoiceEncryption private byte[]? _key; private int _nonce; + public static bool IsSupported => true; + public string Name => "aead_xchacha20_poly1305_rtpsize"; public int Expansion => XChaCha20Poly1305.ABytes + sizeof(int); diff --git a/NetCord/Gateway/Voice/VoiceEncryptionProvider.cs b/NetCord/Gateway/Voice/VoiceEncryptionProvider.cs index 09731b910..72f63fe0c 100644 --- a/NetCord/Gateway/Voice/VoiceEncryptionProvider.cs +++ b/NetCord/Gateway/Voice/VoiceEncryptionProvider.cs @@ -12,7 +12,7 @@ private VoiceEncryptionProvider() public IVoiceEncryption GetEncryption(IReadOnlyList modes) { - return modes.Contains("aead_aes256_gcm_rtpsize") + return (modes.Contains("aead_aes256_gcm_rtpsize") && Aes256GcmRtpSizeEncryption.IsSupported) ? new Aes256GcmRtpSizeEncryption() : new XChaCha20Poly1305RtpSizeEncryption(); }