From 931eb40e8e4deb41edcb1c725e74586ff9f918b2 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Mon, 2 Nov 2026 18:27:09 +0100 Subject: fix(crypto): refuse to encrypt when a .gpg-id recipient key is missing CryptoRepository.encrypt looked up every .gpg-id recipient and dropped the ones it could not find, so an entry saved on a device that lacked one recipient's key was encrypted to the others only. With a store shared between a phone key and a smartcard key, entries created on the phone could no longer be decrypted with the smartcard alone. Fail with the lookup error instead (KeyNotFoundException names the key), so the user imports the missing public key and saves again. PasswordCreationActivity also ignored the Result of encrypt and wrote the output buffer regardless: on any encryption failure it wrote an empty .gpg file, overwriting the entry when editing, and committed it. Show the error and leave the file untouched. CryptoRepositoryTest covers both the missing-recipient failure and the all-present success path, with keys generated by PGPainless (added as an app test dependency). Co-Authored-By: Claude Opus 5.5 --- app/build.gradle.kts | 1 + 1 file changed, 1 insertion(+) (limited to 'app/build.gradle.kts') diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 872f79dd..cd79be78 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -101,5 +101,6 @@ dependencies { testImplementation(libs.testing.robolectric) testImplementation(libs.testing.sharedPrefsMock) + testImplementation(libs.thirdparty.pgpainless) testImplementation(libs.bundles.testDependencies) } -- cgit v1.2.3