E2E Test: E2E test for end to end encryption.#656
Conversation
|
@copilot resolve the merge conflicts in this pull request |
…r-end-to-end-encryption # Conflicts: # livekit-rtc/rust-sdks Co-authored-by: cloudwebrtc <17733746+cloudwebrtc@users.noreply.github.com>
Resolved by merging Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
|
|
@copilot resolve the merge conflicts in this pull request |
…r-end-to-end-encryption # Conflicts: # livekit-rtc/rust-sdks Co-authored-by: cloudwebrtc <17733746+cloudwebrtc@users.noreply.github.com>
Resolved in commit |
Summary
Add end-to-end tests for E2EE (shared-key and per-participant key modes), and fix several SDK bugs uncovered along the way that prevented the workflows from working at all.
Depends on
E2eeManager::set_enablednot persisting theenabledflag, which causedset_enabled(true)afterset_enabled(false)to be silently dropped. The shared-key test's re-enable step depends on this fix landing and the bundled FFI dylib being rebuilt.New tests
tests/test_e2ee_shared_key.py— publisher + 2 receivers share a key; verifies connect → publish →OKstate → GCM enforced → ratchet →KEY_RATCHETED→ disable →DECRYPTION_FAILED→ re-enable →OK.tests/test_e2ee_per_participant.py— same flow but with three per-identity keys (indexes 0/1/2); adds asetKeyIndexswitch step at the end. Ported from the Darte2ee_per_participant.darttest, with one deviation: step 6 ratchetskey_index=0instead of2, because the Python/Rust frame cryptor defaults to index 0 — ratcheting an unused key would never affect transmitted frames.Both tests skip when
LIVEKIT_URL/LIVEKIT_API_KEY/LIVEKIT_API_SECRETaren't set.Bug fixes
Room.connectcrashed whenshared_key=None(livekit/rtc/room.py)The proto field is optional ("Only specify if you want to use a shared_key"), but
connectassigned it unconditionally →TypeError: expected bytes, NoneType found. Per-participant mode couldn't connect at all. Now only assigned when notNone.E2EEManager.frame_cryptors()sent an empty oneof (livekit/rtc/e2ee.py)Only
room_handlewas set, so FFI returnedInvalidRequest("message is empty"). Addedreq.e2ee.manager_get_frame_cryptors.SetInParent().FrameCryptordroppedtrack_sid(livekit/rtc/e2ee.py)FrameCryptorSet{Enabled,KeyIndex}Requestrequiretrack_sidin the proto, but the Python wrapper neither stored nor sent it →EncodeError: missing required fields: track_sid. Addedtrack_sidto the constructor, populated it frommanager_get_frame_cryptors, and threaded it through bothset_enabledandset_key_index.Test plan
pytest tests/test_e2ee_shared_key.py tests/test_e2ee_per_participant.py -vpasses against a running LiveKit server (both pass locally in ~10s)tests/test_e2ee.pyunit tests still passexamples/e2ee.pyto confirm shared-key path is unaffected