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
|
|
@ -28,6 +28,7 @@ android {
|
|||
// the offline default and match the first automated tag (v0.1.0 → 100).
|
||||
versionCode = (findProperty("onionwire.versionCode") as String?)?.toIntOrNull() ?: 100
|
||||
versionName = (findProperty("onionwire.versionName") as String?) ?: "0.1.0"
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
ndk {
|
||||
abiFilters += onionwireAbis
|
||||
}
|
||||
|
|
@ -129,4 +130,10 @@ dependencies {
|
|||
|
||||
testImplementation(libs.junit)
|
||||
testImplementation(libs.kotlinx.coroutines.test)
|
||||
|
||||
// Device-only: the AndroidKeyStore provider does not exist in the unit-test
|
||||
// JVM. These run under `./gradlew :app:connectedDebugAndroidTest`.
|
||||
androidTestImplementation(libs.junit)
|
||||
androidTestImplementation(libs.androidx.test.ext.junit)
|
||||
androidTestImplementation(libs.androidx.test.runner)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue