Fix hardware keystore crash on MediaTek devices (AES wrapped import)#184
Open
davidtorcivia wants to merge 1 commit intoOpenBubbles:rustpushfrom
Open
Fix hardware keystore crash on MediaTek devices (AES wrapped import)#184davidtorcivia wants to merge 1 commit intoOpenBubbles:rustpushfrom
davidtorcivia wants to merge 1 commit intoOpenBubbles:rustpushfrom
Conversation
…failures The `supports_import()` capability test only checked RSA and EC key imports, missing AES 256 wrapped key import which fails on some MediaTek TEEs (e.g. BlueFox NX1 / MT6769V Helio G85) with Keystore error code -59 (UNSUPPORTED_MIN_MAC_LENGTH). This caused a crash during onboarding when importing the `ids:identity-storage-key` AES key. Add an AES 256 GCM import test matching the exact key type and access rules used by the real identity storage key, so affected devices correctly fall back to SoftwareKeystore. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
|
Fixes #185 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
supports_import()so devices that fail AES wrapped key import correctly fall back toSoftwareKeystoreKeyStoreException: Failed to import wrapped key. Keystore error code: -59Problem
I was unable to select "use this device" when registering Open Bubbles on my Bluefox NX1 (mediatek) beginning in late January 2026. adb logcat revealed this was a hardware keystore issue.
The hardware keystore capability test in
supports_import()(rust/src/keystore.rs) tests RSA 1024 and EC P384 key imports, but never tests AES 256 wrapped key import. On some MediaTek TEEs, RSA and EC imports succeed but AES wrapped key import fails withUNSUPPORTED_MIN_MAC_LENGTH/ error code -59.This causes a runtime crash when
AesKeystoreKey::ensure("ids:identity-storage-key:openbubbles", 256, ...)is called during activation, because the device was incorrectly classified as hardware-compatible.Affected device
Fix
Add an AES 256 key import test after the existing RSA and EC tests in
supports_import(), using the sameKeyType::Aes(256)andEncryptMode::Gcmaccess rules as the realids:identity-storage-key. If this test fails, the device correctly falls back toSoftwareKeystore.Test plan
adb logcatthatkeystore2reportsError::Km(r#UNSUPPORTED_MIN_MAC_LENGTH)during the new AES testSoftwareKeystore(logs showkeystore:software:encryptor)KeyStoreExceptioncrash — app runs normally(Can't test the last one, but I confirmed the app now works properly on my NX1 - compiled with dummy fairplay certs).