-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement AES Encryption for Voice #897
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please run ./gradlew apiDump
i'm not very familiar with voice connections, can you explain a bit why this is needed? |
It kinda is and kinda isn't. I initially wanted to implement AES because it was faster than xsalsa but after doing a couple benchmarks it looks like xsalsa is a little bit more consistent and a couple microseconds faster. This isn't really that surprising considering Kord Voice isn't the most efficient voice library, it doesn't help that Java relies on |
val encryption = if ((receiveVoice || streams != null) && encryption?.supportsDecryption != true) { | ||
VoiceEncryption.XSalsaPoly1305() | ||
} else { | ||
encryption ?: VoiceEncryption.AeadAes256Gcm | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be useful to log if the user's chosen encryption method ends up not being used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or even throw an exception? but logging a warning is probably best.
Functionality-wise LGTM. It likely will make adding/working with encryption a bit easier in the future too, if (or rather when) Discord decides to change things up. |
val encryption = if ((receiveVoice || streams != null) && encryption?.supportsDecryption != true) { | ||
VoiceEncryption.XSalsaPoly1305() | ||
} else { | ||
encryption ?: VoiceEncryption.AeadAes256Gcm | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or even throw an exception? but logging a warning is probably best.
@@ -27,4 +23,17 @@ public sealed interface NonceStrategy { | |||
* Writes the [nonce] to [cursor] in the correct relative position. | |||
*/ | |||
public fun append(nonce: ByteArrayView, cursor: MutableByteArrayCursor) | |||
|
|||
public interface Factory { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this factory? i'd rather not add it if not needed.
Not sure if removing |
I tested voice send/receive for all 3 xsalsa20 poly1305 nonce strategies, all work as expected.