Skip to content

E2EE: allow setting key_ring_size and key_derivation_algorithm, update webrtc to m144#921

Open
onestacked wants to merge 5 commits intolivekit:mainfrom
onestacked:EC-compat-changes-webrtc-change
Open

E2EE: allow setting key_ring_size and key_derivation_algorithm, update webrtc to m144#921
onestacked wants to merge 5 commits intolivekit:mainfrom
onestacked:EC-compat-changes-webrtc-change

Conversation

@onestacked
Copy link

@onestacked onestacked commented Feb 28, 2026

This PR uses this webrtc-sdk PR to configure the KDF, instead of just overwriting the derived key afterwards. This should also now properly support KeyRatcheting.

I've tested this with https://codeberg.org/esoteric_programmer/matrix-jukebox and it is compatible with Element Call.

Since this PR needs to use a new webrtc build it also updates webtc to m144. See this PR

Fixes: #796

@onestacked
Copy link
Author

Now based on webrtc-sdk/webrtc#224

@onestacked onestacked changed the title E2EE: Alternative implementation: allow setting key_ring_size and key_derivation_function (And add HKDF as a kdf) E2EE: allow setting key_ring_size and key_derivation_function (And add HKDF as a kdf) Mar 6, 2026
@onestacked onestacked changed the title E2EE: allow setting key_ring_size and key_derivation_function (And add HKDF as a kdf) E2EE: allow setting key_ring_size and key_derivation_algorithm Mar 6, 2026
@onestacked
Copy link
Author

webrtc-sdk/webrtc#224 is now merged, this will only need a new webrtc-sdk build and update to that. (once thats done I'll look into why node fails.

@alexander-potemkin
Copy link

Please, keep going, @onestacked !! :)

@onestacked
Copy link
Author

onestacked commented Mar 8, 2026

This is mosly waiting for review and the WebRTC build to be done.
From my side there isn'tuch to do anymore, just fixing the CI (which needs something for node) and maybe adding some tests. Most of the CI failures are because this uses a local WebRTC build which of course doesn't exust in CI.

@alexander-potemkin
Copy link

@theomonnom , @typester , I hope you would forgive me for pinging you directly. I'm just a person who wants to help a very needed work from @onestacked to make to your product.

@maxinflection
Copy link

We've been running a production deployment with an equivalent patch set for about three weeks now — a Matrix bot that joins Element Call rooms via LiveKit, decrypts E2EE audio, and transcribes it. Our patches target the same layers (webrtc C++ → webrtc-sys → livekit crates → livekit-ffi) and the approach is functionally identical: branch on a KeyDerivationAlgorithm enum in DeriveKeys(), call BoringSSL's HKDF() with EVP_sha256(), and thread the option through the Rust/FFI stack.
Can confirm:
• HKDF-SHA256 with salt "LKFrameEncryptionKey" and 128 zero-byte info produces correct AES-128-GCM keys matching Element Call's JS SDK
• Key ratcheting still works correctly when left on PBKDF2 (default path unchanged)
• Tested against Element Call clients on Element Web and Element X

Happy to help test once the new webrtc-sdk release unblocks this. Looking forward to dropping our custom .so build.

@onestacked
Copy link
Author

onestacked commented Mar 12, 2026

Webrtc-sdk has just been rebased to a new upstream release: webrtc-sdk/webrtc#217 so livekit will probably update fairly soon.

@fkwp
Copy link

fkwp commented Mar 12, 2026

We've been running a production deployment with an equivalent patch set for about three weeks now — a Matrix bot that joins Element Call rooms via LiveKit, decrypts E2EE audio, and transcribes it. Our patches target the same layers (webrtc C++ → webrtc-sys → livekit crates → livekit-ffi) and the approach is functionally identical: branch on a KeyDerivationAlgorithm enum in DeriveKeys(), call BoringSSL's HKDF() with EVP_sha256(), and thread the option through the Rust/FFI stack. Can confirm: • HKDF-SHA256 with salt "LKFrameEncryptionKey" and 128 zero-byte info produces correct AES-128-GCM keys matching Element Call's JS SDK • Key ratcheting still works correctly when left on PBKDF2 (default path unchanged) • Tested against Element Call clients on Element Web and Element X

Happy to help test once the new webrtc-sdk release unblocks this. Looking forward to dropping our custom .so build.

that's nice @maxinflection that MatrixRTC is getting traction around the matrix rust-sdk. I think the community would be really interested in your project. So yes please share your stuff :-)

@onestacked onestacked force-pushed the EC-compat-changes-webrtc-change branch from a775d90 to 303b040 Compare March 18, 2026 09:08
@onestacked onestacked changed the title E2EE: allow setting key_ring_size and key_derivation_algorithm E2EE: allow setting key_ring_size and key_derivation_algorithm, update webrtc to m144 Mar 18, 2026
@onestacked onestacked force-pushed the EC-compat-changes-webrtc-change branch from 303b040 to 229e2bb Compare March 18, 2026 11:26
@onestacked
Copy link
Author

I'm not sure why the FFI Proto fails on checkout?

I don't think any change should effect this.

@onestacked
Copy link
Author

Also let me know if you want my PR split, as it now does three things (key_ring_size, key_derivation_algorithm and webrtc update)

@onestacked onestacked force-pushed the EC-compat-changes-webrtc-change branch from 229e2bb to 6f225c3 Compare March 18, 2026 11:48
@onestacked onestacked force-pushed the EC-compat-changes-webrtc-change branch from 6f225c3 to 6856cd4 Compare March 18, 2026 12:06

pub const SCRATH_PATH: &str = "livekit_webrtc";
pub const WEBRTC_TAG: &str = "webrtc-0001d84-2";
pub const WEBRTC_TAG: &str = "webrtc-24f6822";
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey, this is a version that will be released soon webrtc-24f6822-2. You can update to it now. And the m144 upgrade will begin next week.

solutions = [
{
"name": 'src',
"url": 'https://github.com/webrtc-sdk/webrtc.git@m137_release',
Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert to m137_release here first. We will modify this section again after updating to m144.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

E2EE HKDF & keyring_size support

5 participants