-
Notifications
You must be signed in to change notification settings - Fork 164
Encrypted data channel #781
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
Merged
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
30e8c9c
Proto v1.41.0
pblazej 2ef85c0
Todo
pblazej a1f2230
Lib v137.7151.06
pblazej a8ac611
Minimal impl
pblazej c29edbc
Lib v137.7151.07
pblazej 37e1267
Basic test
pblazej 37a5f27
Participant keys
pblazej 9e2acec
Failure tests
pblazej c9c5683
Fix sequencing
pblazej f0e7299
Fix pod
pblazej a473c49
Add current key infra
pblazej 13a2f8d
Ratcheting test
pblazej 414e235
Simplify extensions
pblazej dbb1ef5
Retry cosmetics
pblazej 621d9ad
Key index test
pblazej 1a16920
Stream handling and delegates
pblazej bf349fa
Deprecate old methods and fix tests
pblazej cde547a
Cosmetics
pblazej 96eccc0
Deprecate e2ee options
pblazej c7eed63
Move data channel tests around
pblazej c21e498
Assert
pblazej bb1c86a
Minor simplifications
pblazej 592c0d4
Change
pblazej 5bf4652
Fix fallback
pblazej 87b49c0
Merge branch 'main' into blaze/dc-e2ee
pblazej 70af9b6
Update proto plugin
pblazej bdbe79c
Proto v1.41.0, new generator
pblazej d569de4
Fix default ratchet window
pblazej b34a38f
Revert "Fix default ratchet window"
pblazej 15dfb96
Cmt
pblazej d48f241
Param names
pblazej 6070ec2
Always decrypt
pblazej 9b567f8
Split inits
pblazej 825ae80
ObjC
pblazej 7529f9c
Merge branch 'main' into blaze/dc-e2ee
hiroshihorie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| minor type="added" "Added support for data channel encryption, deprecated existing E2EE options" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -120,6 +120,8 @@ public class Room: NSObject, @unchecked Sendable, ObservableObject, Loggable { | |
| let incomingStreamManager = IncomingStreamManager() | ||
| lazy var outgoingStreamManager = OutgoingStreamManager { [weak self] packet in | ||
| try await self?.send(dataPacket: packet) | ||
| } encryptionProvider: { [weak self] in | ||
| self?.e2eeManager?.dataChannelEncryptionType ?? .none | ||
| } | ||
|
|
||
| // MARK: - PreConnect | ||
|
|
@@ -340,15 +342,26 @@ public class Room: NSObject, @unchecked Sendable, ObservableObject, Loggable { | |
| _state.mutate { $0.connectOptions = connectOptions } | ||
| } | ||
|
|
||
| await cleanUp() | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved due to |
||
|
|
||
| try Task.checkCancellation() | ||
|
|
||
| // enable E2EE | ||
| if let e2eeOptions = state.roomOptions.e2eeOptions { | ||
| e2eeManager = E2EEManager(e2eeOptions: e2eeOptions) | ||
| e2eeManager!.setup(room: self) | ||
| } | ||
| } else if let encryptionOptions = state.roomOptions.encryptionOptions { | ||
| e2eeManager = E2EEManager(options: encryptionOptions) | ||
| e2eeManager!.setup(room: self) | ||
|
|
||
| await cleanUp() | ||
| subscriberDataChannel.e2eeManager = e2eeManager | ||
| publisherDataChannel.e2eeManager = e2eeManager | ||
| } else { | ||
| e2eeManager = nil | ||
|
|
||
| try Task.checkCancellation() | ||
| subscriberDataChannel.e2eeManager = nil | ||
| publisherDataChannel.e2eeManager = nil | ||
| } | ||
|
|
||
| _state.mutate { $0.connectionState = .connecting } | ||
|
|
||
|
|
@@ -620,15 +633,21 @@ extension Room: DataChannelDelegate { | |
| func dataChannel(_: DataChannelPair, didReceiveDataPacket dataPacket: Livekit_DataPacket) { | ||
| switch dataPacket.value { | ||
| case let .speaker(update): engine(self, didUpdateSpeakers: update.speakers) | ||
| case let .user(userPacket): engine(self, didReceiveUserPacket: userPacket) | ||
| case let .user(userPacket): engine(self, didReceiveUserPacket: userPacket, encryptionType: dataPacket.encryptedPacket.encryptionType.toLKType()) | ||
| case let .transcription(packet): room(didReceiveTranscriptionPacket: packet) | ||
| case let .rpcResponse(response): room(didReceiveRpcResponse: response) | ||
| case let .rpcAck(ack): room(didReceiveRpcAck: ack) | ||
| case let .rpcRequest(request): room(didReceiveRpcRequest: request, from: dataPacket.participantIdentity) | ||
| case let .streamHeader(header): Task { await incomingStreamManager.handle(header: header, from: dataPacket.participantIdentity) } | ||
| case let .streamChunk(chunk): Task { await incomingStreamManager.handle(chunk: chunk) } | ||
| case let .streamTrailer(trailer): Task { await incomingStreamManager.handle(trailer: trailer) } | ||
| case let .streamHeader(header): Task { await incomingStreamManager.handle(header: header, from: dataPacket.participantIdentity, encryptionType: dataPacket.encryptedPacket.encryptionType.toLKType()) } | ||
| case let .streamChunk(chunk): Task { await incomingStreamManager.handle(chunk: chunk, encryptionType: dataPacket.encryptedPacket.encryptionType.toLKType()) } | ||
| case let .streamTrailer(trailer): Task { await incomingStreamManager.handle(trailer: trailer, encryptionType: dataPacket.encryptedPacket.encryptionType.toLKType()) } | ||
| default: return | ||
| } | ||
| } | ||
|
|
||
| func dataChannel(_: DataChannelPair, didFailToDecryptDataPacket _: Livekit_DataPacket, error: LiveKitError) { | ||
| delegates.notify { | ||
| $0.room?(self, didFailToDecryptDataWithEror: error) | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Maybe this can be
weak? I think theRoomholds the instance. 🤔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.
I'd be careful with that - I mean, there's no point in making sure that there's only 1 strong ref... if there's no cycle here... Let's double-check if the DC is deallocated properly (if needed).