Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace NetCord.Gateway.Voice.Encryption;

public sealed class Aes256GcmRtpSizeEncryption : IVoiceEncryption
{
private AesGcm? _decryption;
private AesGcm? _encryption;
private int _nonce;

Expand Down Expand Up @@ -60,7 +61,7 @@ public void Decrypt(RtpPacket packet, Span<byte> plaintext)
var tag = payload[^(TagSize + sizeof(int))..^sizeof(int)];
var ad = packet.ExtendedHeader;

_encryption!.Decrypt(nonce, ciphertext, tag, plaintext, ad);
_decryption!.Decrypt(nonce, ciphertext, tag, plaintext, ad);
}

public void Encrypt(ReadOnlySpan<byte> plaintext, RtpPacketWriter packet)
Expand All @@ -87,11 +88,13 @@ public void Encrypt(ReadOnlySpan<byte> plaintext, RtpPacketWriter packet)

public void SetKey(byte[] key)
{
_decryption = new(key, TagSize);
_encryption = new(key, TagSize);
}
Comment thread
KubaZ2 marked this conversation as resolved.

public void Dispose()
{
_decryption?.Dispose();
_encryption?.Dispose();
}
}