diff --git a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperationTest.java b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperationTest.java index c46e3ee15..88cf260fb 100644 --- a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperationTest.java +++ b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperationTest.java @@ -19,6 +19,7 @@ import org.spongycastle.bcpg.sig.KeyFlags; import org.spongycastle.jce.provider.BouncyCastleProvider; import org.spongycastle.openpgp.PGPSignature; import org.spongycastle.bcpg.PublicKeyAlgorithmTags; +import org.sufficientlysecure.keychain.service.OperationResultParcel.LogType; import org.sufficientlysecure.keychain.service.OperationResultParcel.OperationLog; import org.sufficientlysecure.keychain.service.OperationResults.EditKeyResult; import org.sufficientlysecure.keychain.service.SaveKeyringParcel; @@ -238,7 +239,7 @@ public class PgpKeyOperationTest { parcel.mFingerprint = ring.getFingerprint(); assertModifyFailure("keyring modification with bad master key id should fail", - ring, parcel); + ring, parcel, LogType.MSG_MF_ERROR_KEYID); } { @@ -248,7 +249,7 @@ public class PgpKeyOperationTest { parcel.mFingerprint = ring.getFingerprint(); assertModifyFailure("keyring modification with null master key id should fail", - ring, parcel); + ring, parcel, LogType.MSG_MF_ERROR_KEYID); } { @@ -259,7 +260,7 @@ public class PgpKeyOperationTest { parcel.mFingerprint[5] += 1; assertModifyFailure("keyring modification with bad fingerprint should fail", - ring, parcel); + ring, parcel, LogType.MSG_MF_ERROR_FINGERPRINT); } { @@ -268,7 +269,7 @@ public class PgpKeyOperationTest { parcel.mFingerprint = null; assertModifyFailure("keyring modification with null fingerprint should fail", - ring, parcel); + ring, parcel, LogType.MSG_MF_ERROR_FINGERPRINT); } { @@ -278,7 +279,7 @@ public class PgpKeyOperationTest { } assertModifyFailure("keyring modification with bad passphrase should fail", - ring, parcel, badphrase); + ring, parcel, badphrase, LogType.MSG_MF_UNLOCK_ERROR); } } @@ -331,7 +332,8 @@ public class PgpKeyOperationTest { parcel.reset(); parcel.mAddSubKeys.add(new SubkeyAdd( PublicKeyAlgorithmTags.RSA_GENERAL, new Random().nextInt(512), KeyFlags.SIGN_DATA, 0L)); - assertModifyFailure("creating a subkey with keysize < 512 should fail", ring, parcel); + assertModifyFailure("creating a subkey with keysize < 512 should fail", ring, parcel, + LogType.MSG_CR_ERROR_KEYSIZE_512); } @@ -339,7 +341,8 @@ public class PgpKeyOperationTest { parcel.reset(); parcel.mAddSubKeys.add(new SubkeyAdd(PublicKeyAlgorithmTags.RSA_GENERAL, 1024, KeyFlags.SIGN_DATA, new Date().getTime()/1000-10)); - assertModifyFailure("creating subkey with past expiry date should fail", ring, parcel); + assertModifyFailure("creating subkey with past expiry date should fail", ring, parcel, + LogType.MSG_MF_ERROR_PAST_EXPIRY); } } @@ -436,14 +439,16 @@ public class PgpKeyOperationTest { parcel.reset(); parcel.mChangeSubKeys.add(new SubkeyChange(keyId, null, new Date().getTime()/1000-10)); - assertModifyFailure("setting subkey expiry to a past date should fail", ring, parcel); + assertModifyFailure("setting subkey expiry to a past date should fail", ring, parcel, + LogType.MSG_MF_ERROR_PAST_EXPIRY); } { // modifying nonexistent subkey should fail parcel.reset(); parcel.mChangeSubKeys.add(new SubkeyChange(123, null, null)); - assertModifyFailure("modifying non-existent subkey should fail", ring, parcel); + assertModifyFailure("modifying non-existent subkey should fail", ring, parcel, + LogType.MSG_MF_ERROR_SUBKEY_MISSING); } } @@ -529,21 +534,24 @@ public class PgpKeyOperationTest { parcel.mRevokeUserIds.add("pink"); parcel.mChangeSubKeys.add(new SubkeyChange(keyId, KeyFlags.CERTIFY_OTHER, null)); - assertModifyFailure("master key modification with all user ids revoked should fail", ring, parcel); + assertModifyFailure("master key modification with all user ids revoked should fail", ring, parcel, + LogType.MSG_MF_ERROR_MASTER_NONE); } { // any flag not including CERTIFY_OTHER should fail parcel.reset(); parcel.mChangeSubKeys.add(new SubkeyChange(keyId, KeyFlags.SIGN_DATA, null)); - assertModifyFailure("setting master key flags without certify should fail", ring, parcel); + assertModifyFailure("setting master key flags without certify should fail", ring, parcel, + LogType.MSG_MF_ERROR_NO_CERTIFY); } { // a past expiry should fail parcel.reset(); parcel.mChangeSubKeys.add(new SubkeyChange(keyId, null, new Date().getTime()/1000-10)); - assertModifyFailure("setting subkey expiry to a past date should fail", ring, parcel); + assertModifyFailure("setting subkey expiry to a past date should fail", ring, parcel, + LogType.MSG_MF_ERROR_PAST_EXPIRY); } } @@ -663,7 +671,8 @@ public class PgpKeyOperationTest { parcel.reset(); parcel.mChangePrimaryUserId = uid; - assertModifyFailure("setting primary user id to a revoked user id should fail", modified, parcel); + assertModifyFailure("setting primary user id to a revoked user id should fail", modified, parcel, + LogType.MSG_MF_ERROR_REVOKED_PRIMARY); } @@ -705,7 +714,8 @@ public class PgpKeyOperationTest { parcel.reset(); parcel.mRevokeUserIds.add("nonexistent"); - assertModifyFailure("revocation of nonexistent user id should fail", modified, parcel); + assertModifyFailure("revocation of nonexistent user id should fail", modified, parcel, + LogType.MSG_MF_ERROR_NOEXIST_REVOKE); } } @@ -715,7 +725,8 @@ public class PgpKeyOperationTest { { parcel.mAddUserIds.add(""); - assertModifyFailure("adding an empty user id should fail", ring, parcel); + assertModifyFailure("adding an empty user id should fail", ring, parcel, + LogType.MSG_MF_UID_ERROR_EMPTY); } parcel.reset(); @@ -784,7 +795,7 @@ public class PgpKeyOperationTest { } assertModifyFailure("changing primary user id to a non-existent one should fail", - ring, parcel); + ring, parcel, LogType.MSG_MF_ERROR_NOEXIST_PRIMARY); } // check for revoked primary user id already done in revoke test @@ -878,17 +889,7 @@ public class PgpKeyOperationTest { } private void assertModifyFailure(String reason, UncachedKeyRing ring, - SaveKeyringParcel parcel, String passphrase) throws Exception { - - CanonicalizedSecretKeyRing secretRing = new CanonicalizedSecretKeyRing(ring.getEncoded(), false, 0); - EditKeyResult result = op.modifySecretKeyRing(secretRing, parcel, passphrase); - - Assert.assertFalse(reason, result.success()); - Assert.assertNull(reason, result.getRing()); - - } - - private void assertModifyFailure(String reason, UncachedKeyRing ring, SaveKeyringParcel parcel) + SaveKeyringParcel parcel, String passphrase, LogType expected) throws Exception { CanonicalizedSecretKeyRing secretRing = new CanonicalizedSecretKeyRing(ring.getEncoded(), false, 0); @@ -896,6 +897,22 @@ public class PgpKeyOperationTest { Assert.assertFalse(reason, result.success()); Assert.assertNull(reason, result.getRing()); + Assert.assertTrue(reason + "(with correct error)", + result.getLog().containsType(expected)); + + } + + private void assertModifyFailure(String reason, UncachedKeyRing ring, SaveKeyringParcel parcel, + LogType expected) + throws Exception { + + CanonicalizedSecretKeyRing secretRing = new CanonicalizedSecretKeyRing(ring.getEncoded(), false, 0); + EditKeyResult result = op.modifySecretKeyRing(secretRing, parcel, passphrase); + + Assert.assertFalse(reason, result.success()); + Assert.assertNull(reason, result.getRing()); + Assert.assertTrue(reason + "(with correct error)", + result.getLog().containsType(expected)); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index 710bd42c6..3fcabf636 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -557,7 +557,7 @@ public class PgpKeyOperation { PGPSecretKey sKey = sKR.getSecretKey(change.mKeyId); if (sKey == null) { - log.add(LogLevel.ERROR, LogType.MSG_MF_SUBKEY_MISSING, + log.add(LogLevel.ERROR, LogType.MSG_MF_ERROR_SUBKEY_MISSING, indent + 1, PgpKeyHelper.convertKeyIdToHex(change.mKeyId)); return new EditKeyResult(EditKeyResult.RESULT_ERROR, log, null); } @@ -638,7 +638,7 @@ public class PgpKeyOperation { PGPSecretKey sKey = sKR.getSecretKey(revocation); if (sKey == null) { - log.add(LogLevel.ERROR, LogType.MSG_MF_SUBKEY_MISSING, + log.add(LogLevel.ERROR, LogType.MSG_MF_ERROR_SUBKEY_MISSING, indent+1, PgpKeyHelper.convertKeyIdToHex(revocation)); return new EditKeyResult(EditKeyResult.RESULT_ERROR, log, null); } @@ -813,7 +813,7 @@ public class PgpKeyOperation { if (!ok) { // might happen, theoretically, if there is a key with no uid.. - log.add(LogLevel.ERROR, LogType.MSG_MF_ERROR_INTEGRITY, indent); + log.add(LogLevel.ERROR, LogType.MSG_MF_ERROR_MASTER_NONE, indent); return null; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResultParcel.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResultParcel.java index 138283b81..8e7dcd4aa 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResultParcel.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResultParcel.java @@ -359,20 +359,21 @@ public class OperationResultParcel implements Parcelable { MSG_MF_ERROR_FINGERPRINT (R.string.msg_mf_error_fingerprint), MSG_MF_ERROR_KEYID (R.string.msg_mf_error_keyid), MSG_MF_ERROR_INTEGRITY (R.string.msg_mf_error_integrity), + MSG_MF_ERROR_MASTER_NONE(R.string.msg_mf_error_master_none), MSG_MF_ERROR_NO_CERTIFY (R.string.msg_cr_error_no_certify), MSG_MF_ERROR_NOEXIST_PRIMARY (R.string.msg_mf_error_noexist_primary), MSG_MF_ERROR_NOEXIST_REVOKE (R.string.msg_mf_error_noexist_revoke), MSG_MF_ERROR_NULL_EXPIRY (R.string.msg_mf_error_null_expiry), MSG_MF_ERROR_PAST_EXPIRY(R.string.msg_mf_error_past_expiry), - MSG_MF_ERROR_REVOKED_PRIMARY (R.string.msg_mf_error_revoked_primary), MSG_MF_ERROR_PGP (R.string.msg_mf_error_pgp), + MSG_MF_ERROR_REVOKED_PRIMARY (R.string.msg_mf_error_revoked_primary), MSG_MF_ERROR_SIG (R.string.msg_mf_error_sig), + MSG_MF_ERROR_SUBKEY_MISSING(R.string.msg_mf_error_subkey_missing), MSG_MF_MASTER (R.string.msg_mf_master), MSG_MF_PASSPHRASE (R.string.msg_mf_passphrase), MSG_MF_PRIMARY_REPLACE_OLD (R.string.msg_mf_primary_replace_old), MSG_MF_PRIMARY_NEW (R.string.msg_mf_primary_new), MSG_MF_SUBKEY_CHANGE (R.string.msg_mf_subkey_change), - MSG_MF_SUBKEY_MISSING (R.string.msg_mf_subkey_missing), MSG_MF_SUBKEY_NEW_ID (R.string.msg_mf_subkey_new_id), MSG_MF_SUBKEY_NEW (R.string.msg_mf_subkey_new), MSG_MF_SUBKEY_REVOKE (R.string.msg_mf_subkey_revoke), diff --git a/OpenKeychain/src/main/res/values-cs/strings.xml b/OpenKeychain/src/main/res/values-cs/strings.xml index dd4d41650..c9e7875d8 100644 --- a/OpenKeychain/src/main/res/values-cs/strings.xml +++ b/OpenKeychain/src/main/res/values-cs/strings.xml @@ -62,7 +62,6 @@ Cache hesel Komprimovat zprávu Komprimovat soubor - Vynutit staré OpenPGPv3 podpisy ID klíče Vytvořeno Expirace diff --git a/OpenKeychain/src/main/res/values-de/strings.xml b/OpenKeychain/src/main/res/values-de/strings.xml index 74282fd29..18e6cf585 100644 --- a/OpenKeychain/src/main/res/values-de/strings.xml +++ b/OpenKeychain/src/main/res/values-de/strings.xml @@ -94,7 +94,6 @@ Passwort-Cache Nachrichten-Komprimierung Datei-Komprimierung - Erzwinge alte OpenPGPv3-Signaturen Schlüsselserver Schlüssel-ID Erstellungsdatum diff --git a/OpenKeychain/src/main/res/values-es/strings.xml b/OpenKeychain/src/main/res/values-es/strings.xml index 0bd3a48c5..1770ec896 100644 --- a/OpenKeychain/src/main/res/values-es/strings.xml +++ b/OpenKeychain/src/main/res/values-es/strings.xml @@ -97,7 +97,6 @@ Caché de frase de contraseña Compresión de mensaje Compresión de archivo - Forzar firmas OpenPGPv3 antiguas Servidores de claves ID de clave Creación @@ -585,7 +584,7 @@ Reemplazando certificado de la anterior identidad de usuario primaria Generando nuevo certificado para nueva identidad de usuario primaria Modificando subclave %s - ¡Intentó operar sobre una subclave ausente %s! + ¡Intentó operar sobre una subclave ausente %s! Generando nueva subclave %2$s de %1$s bits Nueva identidad de subclave: %s ¡La fecha de expiración no puede ser del pasado! diff --git a/OpenKeychain/src/main/res/values-fr/strings.xml b/OpenKeychain/src/main/res/values-fr/strings.xml index 3f570d144..3b356fd18 100644 --- a/OpenKeychain/src/main/res/values-fr/strings.xml +++ b/OpenKeychain/src/main/res/values-fr/strings.xml @@ -97,7 +97,6 @@ Cache de la phrase de passe Compression des messages Compression des fichiers - Forcer les anciennes signatures OpenPGP v3 Serveurs de clefs ID de le clef Création @@ -585,7 +584,7 @@ Remplacement du certificat de l\'ID d\'utilisateur principal précédent Génération d\'un nouveau certificat pour le nouvel ID d\'utilisateur principal Modification de la sous-clef %s - Une action a été tentée sur la sous-clef manquante %s ! + Une action a été tentée sur la sous-clef manquante %s ! Génération d\'une nouvelle sous-clef %2$s de %1$s bit ID de la nouvelle sous-clef : %s La date d\'expiration ne peut pas être dans le passé ! diff --git a/OpenKeychain/src/main/res/values-it/strings.xml b/OpenKeychain/src/main/res/values-it/strings.xml index 590532d4d..33bb4ce9d 100644 --- a/OpenKeychain/src/main/res/values-it/strings.xml +++ b/OpenKeychain/src/main/res/values-it/strings.xml @@ -77,7 +77,6 @@ Cache Frase di Accesso Compressione Messaggio Compressione File - Forza vecchie Firme OpenPGPv3 Server Chiavi ID Chiave Creazione @@ -525,7 +524,7 @@ Sostituzione certificato del ID utente primario precedente Generazione di un nuovo certificato per il nuovo ID utente primario Modifica sottochiave %s - Tentativo di operare su sottochiave mancante %s! + Tentativo di operare su sottochiave mancante %s! Generazione nuovi %1$s bit %2$s sottochiave Nuovo ID sottochiave: %s La data di scadenza non può essere passata! diff --git a/OpenKeychain/src/main/res/values-ja/strings.xml b/OpenKeychain/src/main/res/values-ja/strings.xml index 6794deba9..deb7715e1 100644 --- a/OpenKeychain/src/main/res/values-ja/strings.xml +++ b/OpenKeychain/src/main/res/values-ja/strings.xml @@ -97,7 +97,6 @@ パスフレーズキャッシュ メッセージの圧縮 ファイルの圧縮 - 強制的に古いOpenPGPV3形式の署名にする 鍵サーバ 鍵ID 生成 @@ -571,7 +570,7 @@ 以前の主ユーザIDで証明を入れ替え中 新しい主ユーザIDで新しい証明を生成中 副鍵 %s を変更中 - 遺失した副鍵 %s の操作をしようとした! + 遺失した副鍵 %s の操作をしようとした! 新しい %1$s ビットの %2$s 副鍵の生成中 新しい副鍵 ID: %s 期限切れ日を過去にはできません! diff --git a/OpenKeychain/src/main/res/values-nl/strings.xml b/OpenKeychain/src/main/res/values-nl/strings.xml index f225e204a..a49a51671 100644 --- a/OpenKeychain/src/main/res/values-nl/strings.xml +++ b/OpenKeychain/src/main/res/values-nl/strings.xml @@ -71,7 +71,6 @@ Wachtwoordcache Berichtcompressie Bestandscompressie - Forceer oude OpenPGPv3 Handtekeningen Sleutelservers Sleutel-id Aanmaak diff --git a/OpenKeychain/src/main/res/values-pl/strings.xml b/OpenKeychain/src/main/res/values-pl/strings.xml index a4a66e30c..7b12653c6 100644 --- a/OpenKeychain/src/main/res/values-pl/strings.xml +++ b/OpenKeychain/src/main/res/values-pl/strings.xml @@ -59,7 +59,6 @@ Bufor haseł Kompresja wiadomości Kompresja plików - Wymuś stare podpisy OpenPGPv3 Serwery kluczy Identyfikator klucza Utworzenia diff --git a/OpenKeychain/src/main/res/values-ru/strings.xml b/OpenKeychain/src/main/res/values-ru/strings.xml index 2ac766466..1b2aa7dc6 100644 --- a/OpenKeychain/src/main/res/values-ru/strings.xml +++ b/OpenKeychain/src/main/res/values-ru/strings.xml @@ -74,7 +74,6 @@ Помнить пароль Сжатие сообщения Сжатие файла - Использовать OpenPGPv3 подписи (устар.) Серверы ключей ID ключа Создан diff --git a/OpenKeychain/src/main/res/values-sl/strings.xml b/OpenKeychain/src/main/res/values-sl/strings.xml index 0de5e97ea..e98e207b5 100644 --- a/OpenKeychain/src/main/res/values-sl/strings.xml +++ b/OpenKeychain/src/main/res/values-sl/strings.xml @@ -74,7 +74,6 @@ Hranjenje gesla v spominu Stiskanje sporočil Stiskanje datotek - Vsili stare podpise OpenPGPv3 Strežniki ID ključa Ustvarjanje diff --git a/OpenKeychain/src/main/res/values-uk/strings.xml b/OpenKeychain/src/main/res/values-uk/strings.xml index 7a4c79ddb..401b8ae83 100644 --- a/OpenKeychain/src/main/res/values-uk/strings.xml +++ b/OpenKeychain/src/main/res/values-uk/strings.xml @@ -74,7 +74,6 @@ Кеш парольної фрази Стиснення повідомлення Стиснення файлу - Примусово старі підписи OpenPGPv3 Сервери ключів ІД ключа Створення diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml index 8aa10943d..f6c208ca0 100644 --- a/OpenKeychain/src/main/res/values/strings.xml +++ b/OpenKeychain/src/main/res/values/strings.xml @@ -639,7 +639,7 @@ Actual key fingerprint does not match the expected one! No key ID. This is an internal error, please file a bug report! Internal error, integrity check failed! - No master certificate found to modify! + No master certificate found to operate on! (All revoked?) Bad primary user id specified! Bad user id for revocation specified! Revoked user ids cannot be primary! @@ -651,7 +651,7 @@ Replacing certificate of previous primary user id Generating new certificate for new primary user id Modifying subkey %s - Tried to operate on missing subkey %s! + Tried to operate on missing subkey %s! Generating new %1$s bit %2$s subkey New subkey ID: %s Expiry date cannot be in the past!