diff --git a/src/dpp/dave/decryptor.cpp b/src/dpp/dave/decryptor.cpp index 373dc42710..6ad79bf1af 100755 --- a/src/dpp/dave/decryptor.cpp +++ b/src/dpp/dave/decryptor.cpp @@ -64,7 +64,7 @@ void Decryptor::TransitionToPassthroughMode(bool passthroughMode, Duration trans } } -size_t Decryptor::Decrypt(MediaType mediaType, +size_t Decryptor::decrypt(MediaType mediaType, array_view encryptedFrame, array_view frame) { diff --git a/src/dpp/dave/decryptor.h b/src/dpp/dave/decryptor.h index 75ea00bb6a..33c9c44685 100755 --- a/src/dpp/dave/decryptor.h +++ b/src/dpp/dave/decryptor.h @@ -60,7 +60,7 @@ class Decryptor { void TransitionToPassthroughMode(bool passthroughMode, Duration transitionExpiry = kDefaultTransitionDuration); - size_t Decrypt(MediaType mediaType, + size_t decrypt(MediaType mediaType, array_view encryptedFrame, array_view frame); diff --git a/src/dpp/voice/enabled/read_ready.cpp b/src/dpp/voice/enabled/read_ready.cpp index db4375d2d3..48ad8aadd5 100644 --- a/src/dpp/voice/enabled/read_ready.cpp +++ b/src/dpp/voice/enabled/read_ready.cpp @@ -26,7 +26,7 @@ #include #include -#include "../../dave/encryptor.h" +#include "../../dave/decryptor.h" #include "enabled.h" @@ -143,6 +143,25 @@ void discord_voice_client::read_ready() opus_packet_len -= ext_len; } + /** + * If DAVE is enabled, use the user's ratchet to decrypt the OPUS audio data + */ + if (is_end_to_end_encrypted()) { + auto decryptor = mls_state->decryptors.find(vp.vr->user_id); + if (decryptor != mls_state->decryptors.end()) { + std::vector frame(opus_packet_len * 2); + size_t enc_len = decryptor->second->decrypt( + dave::MediaType::Audio, + dave::make_array_view(opus_packet, opus_packet_len), + dave::make_array_view(frame) + ); + if (enc_len > 0) { + opus_packet = frame.data(); + opus_packet_len = enc_len; + } + } + } + /* * We're left with the decrypted, opus-encoded data. * Park the payload and decode on the voice courier thread.