Skip to content

fix(controller): restore ADB keystore capabilities broken by S3#21

Merged
luisguzman-adfa merged 2 commits into
mainfrom
fix/adb-keystore-revert-s3
Jun 19, 2026
Merged

fix(controller): restore ADB keystore capabilities broken by S3#21
luisguzman-adfa merged 2 commits into
mainfrom
fix/adb-keystore-revert-s3

Conversation

@luisguzman-adfa

Copy link
Copy Markdown
Collaborator

Summary

Reverts the keystore change from S3 (PR #10), which broke every ADB connection. Confirmed via logcat.

S3 re-scoped the ADB identity key to SIGN | VERIFY only, assuming ENCRYPT|DECRYPT + the NONE/PKCS1 encryption paddings + setRandomizedEncryptionRequired(false) were unused attack surface. That assumption was wrong.

Root cause (from logcat)

The ADB connection runs over TLS, and the libadb (MuntashirAkon:libadb-android:3.1.1) / conscrypt handshake signs with this key via a raw RSA op (Cipher "RSA/ECB/NoPadding", CryptoUpcalls.rsaSignDigestWithPrivateKey). On a freshly generated S3 key the keystore rejects it:

android.security.KeyStoreException: Incompatible padding mode (INCOMPATIBLE_PADDING_MODE)
CryptoUpcalls: Could not find provider for algorithm: RSA/ECB/NoPadding
→ SSLHandshakeException at io.github.muntashirakon.adb.AdbConnection.startHandshake

So those capabilities are required by the TLS handshake, not vestigial.

Changes (IIABAdbManager)

  • Restore PURPOSE_SIGN | VERIFY | ENCRYPT | DECRYPT + setEncryptionPaddings(ENCRYPTION_PADDING_NONE, ENCRYPTION_PADDING_RSA_PKCS1) + setRandomizedEncryptionRequired(false).
  • Bump KEY_ALIAS iiab_adb_key_v3v4 so devices that already generated the broken SIGN|VERIFY-only v3 key regenerate a working one. One-time cost: ADB must be re-paired on affected devices.
  • Add a comment marking these capabilities as required so they are not stripped again.
  • TECH_DEBT_PLAN.md: withdraw S3 from the register — it was a misdiagnosis, not real debt.

Notes

No unit test (AndroidKeyStore + TLS handshake, device-only). Validation is on-device: ADB connects again in Sync/Share. The rest of Phase 1 (S1/M4/D6/D2/D12/D11) is unaffected and stands.

S3 (PR #10) re-scoped the ADB identity key to SIGN|VERIFY only, on the
assumption that ENCRYPT|DECRYPT + the NONE/PKCS1 encryption paddings +
setRandomizedEncryptionRequired(false) were unused attack surface. That
assumption was wrong.

The ADB connection runs over TLS; the libadb (MuntashirAkon:libadb-android)
/ conscrypt handshake signs with this key via a raw RSA operation
(Cipher "RSA/ECB/NoPadding"), which REQUIRES PURPOSE_ENCRYPT plus
ENCRYPTION_PADDING_NONE (and PKCS1) and setRandomizedEncryptionRequired(false).
With the S3 key spec, a freshly generated key made the keystore reject the
handshake op with KeyStoreException "INCOMPATIBLE_PADDING_MODE", so every ADB
connection failed with an SSLHandshakeException (confirmed via logcat).

- Restore PURPOSE_SIGN|VERIFY|ENCRYPT|DECRYPT + setEncryptionPaddings(NONE, PKCS1)
  + setRandomizedEncryptionRequired(false) on the key spec.
- Bump KEY_ALIAS iiab_adb_key_v3 -> v4 so devices that already generated the
  broken SIGN|VERIFY-only v3 key regenerate a working one (one-time ADB re-pair).
- Add a comment marking these capabilities as required so they are not stripped
  again, and withdraw S3 from the tech-debt register (it was a misdiagnosis).
…rt-s3

# Conflicts:
#	controller/docs/TECH_DEBT_PLAN.md
@luisguzman-adfa luisguzman-adfa merged commit b54818a into main Jun 19, 2026
1 check passed
@luisguzman-adfa luisguzman-adfa deleted the fix/adb-keystore-revert-s3 branch June 19, 2026 05:47
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.

1 participant