feat(android): wrap the store passphrase in the Android Keystore
Typing the passphrase on every launch was the v1 posture. It stays the fallback, but it is no longer required: on first unlock the passphrase can be remembered (checkbox, on by default) and is stored as an AES-256-GCM blob wrapped by a key that never leaves the Android Keystore. - crypto/StoreSecret.kt: the OWSEAL1 envelope (magic + IV + ciphertext + GCM tag) and the wipe helpers. No android.* imports, so the code that runs on a device is the code the unit tests exercise, with a JVM AES key standing in for the Keystore key. - crypto/KeystorePassphraseCipher.kt: AES-256-GCM key under alias `onionwire.store`, StrongBox requested first (API 28+) with a graceful fallback on ProviderException (StrongBoxUnavailableException is one), and an honest KeyInfo-backed report of where the key actually lives. setUserAuthenticationRequired(false) stays the default on purpose. - crypto/StoredPassphraseStore.kt: ciphertext only, at filesDir/secrets/store-passphrase.bin, written tmp+rename. A failed decrypt reports Unavailable and does NOT delete the blob. - WireViewModel: unlock(passphrase, remember), unlockStored(), forgetStoredPassphrase(); the secret CharArray is zeroed in `finally`; the Keystore probe runs off the main thread at ViewModel construction. - UnlockScreen: one-tap when a stored blob exists, the typed passphrase is dropped from Compose state as soon as it is handed over and is never put in saved instance state; "Forget stored passphrase" deletes blob and key. - androidTest: the device-only half (AndroidKeyStore, StrongBox, KeyInfo), which cannot run in the unit-test JVM. Verified: ./gradlew :app:assembleDebug and :app:testDebugUnitTest green, 25 tests / 0 failures (11 new StoreSecretTest, 9 new StoredPassphraseStoreTest).
This commit is contained in:
parent
e6e2a158a8
commit
2fd640e230
13 changed files with 1245 additions and 43 deletions
|
|
@ -9,11 +9,15 @@ composeBom = "2025.12.01"
|
|||
jna = "5.19.1"
|
||||
coroutines = "1.11.0"
|
||||
junit = "4.13.2"
|
||||
androidxTestJunit = "1.3.0"
|
||||
androidxTestRunner = "1.7.0"
|
||||
|
||||
[libraries]
|
||||
androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "coreKtx" }
|
||||
jna = { module = "net.java.dev.jna:jna", version.ref = "jna" }
|
||||
junit = { module = "junit:junit", version.ref = "junit" }
|
||||
androidx-test-ext-junit = { module = "androidx.test.ext:junit", version.ref = "androidxTestJunit" }
|
||||
androidx-test-runner = { module = "androidx.test:runner", version.ref = "androidxTestRunner" }
|
||||
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
|
||||
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
|
||||
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activityCompose" }
|
||||
|
|
|
|||
Loading…
Reference in a new issue