Skip to content
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

Discord DAVE Protocol (E2EE) for voice #1258

Merged
merged 123 commits into from
Oct 7, 2024
Merged

Discord DAVE Protocol (E2EE) for voice #1258

merged 123 commits into from
Oct 7, 2024

Conversation

braindigitalis
Copy link
Contributor

@braindigitalis braindigitalis commented Oct 4, 2024

DAVE? What? huh?

This mega-PR implements Discord's DAVE protocol.

DAVE is an end-to-end encryption scheme that uses MLS (message layer security). To add support for this we use a fork of libdave (a Discord-made open source library) to which i have changed to our code style and documented.
This also depends on libmlspp, which is a third party dependency from cisco, but is currently only available on GitHub and on vcpkg, as such we have made our own fork. Our own fork of mlspp changes the build scripts, as by default it compiles AND INSTALLS as a shared object libmlspp.so, and also installs libbytes.so, libhpke,so, libmls_vectors.so and libtls_syntax.so. We really do NOT want all these installing alongside dpp and becoming separated requirements so this is linked statically into libdpp.so.

Notes about Discord's libdave and Cisco's mlspp

Note that both libdave and mlspp are significantly smaller libraries in terms of poplarity and userbase than dpp, as the mls protocol is yet to pick up widespread traction beyond innovators at places like cisco, signal, facebook, and google. In time, as mls becomes a more popular protocol (IF it becomes a more popular protocol) we can expect better documentation and support for it from third parties and things like libmlspp ending up in places like apt repositories.

Note that if the user disables voice, libmlspp isnt built at all, and nor is the entire of src/dpp/dave

Important: mlspp is not applicable for our code review. It is a security library and its implementation should be considered blackboxed and left well alone!

Refactoring

I have done significant refactoring of discordvoiceclient.cpp to split it into several separate files - if voice is enabled, everything under src/dpp/voice/enabled is compiled into dpp, else everything in src/dpp/voice/disabled is compiled into dpp; currently, a simple empty stub of discord_voice_client. This makes dpp with voice disabled an extremely streamlined version of the library.

Todo

  • MLS negotiation of group
  • Sending audio
  • Receiving audio
  • User join/part of exising MLS group
  • Protocol downgrade if last MLS user leaves
  • Documentation
  • Tidy up and reformat libdave - pay attention to asserts

Code change checklist

  • I have ensured that all methods and functions are fully documented using doxygen style comments.
  • My code follows the coding style guide.
  • I tested that my change works before raising the PR.
  • I have ensured that I did not break any existing API calls.
  • I have not built my pull request using AI, a static analysis tool or similar without any human oversight.

README.md Show resolved Hide resolved
docpages/advanced_reference/voice_model.md Outdated Show resolved Hide resolved
include/dpp/discordclient.h Show resolved Hide resolved
include/dpp/discordclient.h Show resolved Hide resolved
include/dpp/discordvoiceclient.h Show resolved Hide resolved
src/dpp/dave/codec_utils.cpp Outdated Show resolved Hide resolved
src/dpp/dave/codec_utils.cpp Show resolved Hide resolved
src/dpp/dave/codec_utils.h Outdated Show resolved Hide resolved
src/dpp/dave/codec_utils.h Show resolved Hide resolved
src/dpp/dave/cryptor_manager.cpp Outdated Show resolved Hide resolved
src/dpp/dave/cryptor_manager.h Outdated Show resolved Hide resolved
src/dpp/dave/cryptor_manager.h Show resolved Hide resolved
src/dpp/dave/decryptor.cpp Outdated Show resolved Hide resolved
docpages/advanced_reference/voice_model.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
src/dpp/dave/decryptor.h Show resolved Hide resolved
src/dpp/dave/decryptor.h Outdated Show resolved Hide resolved
src/dpp/dave/decryptor.h Show resolved Hide resolved
src/dpp/dave/decryptor.h Show resolved Hide resolved
Copy link
Contributor

@Jaskowicz1 Jaskowicz1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so many new lines I think i'm gonna dream of them tonight.

src/dpp/voice/stub/stubs.cpp Outdated Show resolved Hide resolved
src/dpp/voice/stub/stub.h Outdated Show resolved Hide resolved
src/dpp/voice/enabled/write_ready.cpp Outdated Show resolved Hide resolved
src/dpp/voice/enabled/voice_payload.cpp Outdated Show resolved Hide resolved
src/dpp/voice/enabled/audio_mix.cpp Outdated Show resolved Hide resolved
src/dpp/voice/enabled/displayable_code.cpp Outdated Show resolved Hide resolved
src/dpp/voice/enabled/opus.cpp Outdated Show resolved Hide resolved
src/dpp/voice/enabled/read_ready.cpp Outdated Show resolved Hide resolved
src/dpp/voice/enabled/read_write.cpp Show resolved Hide resolved
src/dpp/voice/enabled/thread.cpp Outdated Show resolved Hide resolved
Copy link
Member

@Mishura4 Mishura4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard to say what code is new and what was moved, but there are some issues. Congrats on getting the feature working though

include/dpp/discordvoiceclient.h Show resolved Hide resolved
include/dpp/discordvoiceclient.h Show resolved Hide resolved
include/dpp/discordvoiceclient.h Show resolved Hide resolved
include/dpp/discordvoiceclient.h Show resolved Hide resolved
include/dpp/discordvoiceclient.h Outdated Show resolved Hide resolved
src/dpp/voice/enabled/handle_frame.cpp Outdated Show resolved Hide resolved
src/dpp/voice/enabled/handle_frame.cpp Show resolved Hide resolved
src/dpp/voice/enabled/handle_frame.cpp Show resolved Hide resolved
src/dpp/voice/enabled/handle_frame.cpp Show resolved Hide resolved
src/dpp/voice/enabled/handle_frame.cpp Show resolved Hide resolved
Copy link
Member

@RealTimeChris RealTimeChris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Copy link
Member

@Mishura4 Mishura4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Eskeetit

@Mishura4 Mishura4 merged commit c5c57e2 into dev Oct 7, 2024
91 checks passed
@braindigitalis braindigitalis added the hacktoberfest-accepted Issues tagged for hacktoberfest label Oct 8, 2024
@braindigitalis braindigitalis deleted the dave branch October 11, 2024 08:39
@braindigitalis braindigitalis added the DAVE Issues or pull requests relating to DAVE E2EE label Oct 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audio audio issues or feature requests build Issue or Pull Request related to the build process code Improvements or additions to code. DAVE Issues or pull requests relating to DAVE E2EE documentation Improvements or additions to documentation hacktoberfest-accepted Issues tagged for hacktoberfest packaging project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants