Skip to content

Conversation

lukasIO
Copy link
Contributor

@lukasIO lukasIO commented Sep 18, 2025

this PR adds data channel encryption capabilities.
For backwards compatibility this is not enabled on existing implementations.
Instead RoomOptions.e2ee is being deprecated (no dc encryption) and a new RoomOptions.encryption field is introduced which enables data channel encryption

@lukasIO lukasIO changed the title DC e2ee feature(e2ee): add data channel encryption Sep 19, 2025
@lukasIO lukasIO marked this pull request as ready for review September 19, 2025 12:35
));
}
Err(e) => {
log::warn!("Failed to encrypt data packet: {}", e);
Copy link
Contributor

Choose a reason for hiding this comment

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

If E2EE is enabled and encryption fails, it seems to me publish_data should return the error and not continue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makes sense

Copy link
Contributor

@ladvoc ladvoc Sep 23, 2025

Choose a reason for hiding this comment

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

To do that, I think the best approach is to define a new error type (i.e. EncryptionError) and add a case for it in the RoomError enum. I'm not sure how much information can be extracted from the underlying exception from libwebrtc, so it probably makes sense to just dump the error string inside EncryptionError.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

wouldn't introducing a new error type be a breaking change for match clauses? 🤔
there's no non_exhaustive declared for it afaict

Copy link
Contributor

@ladvoc ladvoc Sep 23, 2025

Choose a reason for hiding this comment

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

Ah good point, I had assumed it was declared as non exhaustive—it should be for v3. Given that it isn't, I think using the existing Rtc case is the way to go.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for Rtc I'm not able to supply a string argument and the error type is defined as webrtc internal error.

I was going for Internal as an error in order to be able to supply a reason

};

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice example!

pub auto_subscribe: bool,
pub adaptive_stream: bool,
pub dynacast: bool,
#[deprecated(note = "Use `encryption` field instead, see x for a detailed explanation")]
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have something ready to link for "x"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

currently wip, will wait for the actual link to update and merge

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.

3 participants