Skip to content

Add a key size option for AES-256 E2EE keys - #1061

Open
netbrut wants to merge 2 commits into
livekit:mainfrom
netbrut:e2ee-aes256-key-size
Open

netbrut wants to merge 2 commits into
livekit:mainfrom
netbrut:e2ee-aes256-key-size

Conversation

@netbrut

@netbrut netbrut commented Nov 4, 2026

Copy link
Copy Markdown

Fixes #1060. Android counterpart of the Swift change in #1200.
BaseKeyProvider always derived AES-128 frame keys. The prefixed WebRTC library already used by this SDK (150.7871.04) accepts the key size: FrameCryptorFactory.createFrameCryptorKeyProvider has an overload with a trailing int (bits), and the shorter overload passes 128. This PR only forwards it.
• New KeyProviderKeySize enum (BITS_128 default, BITS_256), added as the last BaseKeyProvider constructor parameter, so existing callers are unchanged.
• Default key provider in E2EEOptions explicitly uses 128.
• Changeset (minor).
Every participant in a room must use the same size; the KDoc says so.
Verified: :livekit-android-sdk:compileDebugKotlin passes. Not verified: runtime behavior (needs a device) and JS ↔ Swift ↔ Android interop with keySize: 256. I'm happy to run the interop test as soon as a release is out.

BaseKeyProvider always derived AES-128 frame keys. The prefixed WebRTC
Android library already accepts the key size (a trailing int, in bits,
defaulting to 128 in the shorter overload of createFrameCryptorKeyProvider),
so this only forwards it.

Adds KeyProviderKeySize (BITS_128 default, BITS_256) as the last
BaseKeyProvider constructor parameter, so existing callers are unchanged.
Every participant in a room must use the same size. Matches
KeyProviderOptions.keySize in the JS SDK and the Swift SDK (#1200).

Fixes livekit#1060

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011bMyZt4jGEfw4YQ5siiMRs
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@changeset-bot

changeset-bot Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: efbc333

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
client-sdk-android Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 2 potential issues.

Devin Review

keyRingSize: Int = defaultKeyRingSize,
discardFrameWhenCryptorNotReady: Boolean = defaultDiscardFrameWhenCryptorNotReady,
keyDerivationAlgorithm: FrameCryptorKeyDerivationAlgorithm = defaultKeyDerivationAlgorithm,
keySize: KeyProviderKeySize = defaultKeySize,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 Precompiled E2EE clients fail after upgrade

Precompiled clients using BaseKeyProvider constructor arguments hit NoSuchMethodError after this upgrade. Adding keySize removes the JVM constructor signatures those clients reference.

Learn more

Kotlin compiles calls with omitted constructor parameters against a synthetic JVM constructor containing every parameter and a default-value mask. Adding keySize replaces that signature, as well as the eight-argument constructor. An already-compiled Android module that calls the old constructor still links successfully during packaging but fails when the call runs. The no-argument constructor remains available, so this affects callers that supply any arguments.

Example: An existing compiled library calls BaseKeyProvider(enableSharedKey = false). An application upgrades this SDK without rebuilding that library; invoking its E2EE setup throws NoSuchMethodError instead of creating a provider.

Recommended fix: Preserve the old JVM constructor signatures, including the synthetic default-argument form, while exposing the new size configuration through a compatible additional API. Verify compatibility against a client compiled using the base SDK.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Adds a short example for the new BaseKeyProvider keySize option to the
e2eeOptions documentation, as the repository guidelines ask for new
public APIs.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011bMyZt4jGEfw4YQ5siiMRs
@netbrut

netbrut commented Nov 4, 2026

Copy link
Copy Markdown
Author

Thanks. We kept the new parameter last with a default so source compatibility is unchanged. BaseKeyProvider's constructor has grown the same way before (e.g. keyDerivationAlgorithm in #886), so we followed that pattern rather than adding hidden overloads. Happy to add a hidden deprecated constructor with the previous signature if the maintainers prefer binary compatibility here.

@tangowhisky-dev

Copy link
Copy Markdown

Thanks for working on this. I'm already working on an app which uses E2EE and would like this very much ported in android (Web & Swift already provides it, swift-recently merged). Would very much like this feature enabled. Happy to test it out when available.

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: support keySize 256 (AES-256-GCM) on native SDKs — JS already has keySize: 128 | 256

4 participants