From a1230bbe53d279b44038268d05d85f86ae0ff840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 5 Mar 2014 02:06:44 +0100 Subject: [PATCH] Fix passphrase retrieval --- .../keychain/pgp/PgpDecryptVerify.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java index 345069d9d..c568f462a 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java @@ -310,16 +310,18 @@ public class PgpDecryptVerify { pbe = encData; - // passphrase handling... + // if no passphrase was explicitly set try to get it from the cache service if (passphrase == null) { - // try to get cached passphrase + // returns "" if key has no passphrase passphrase = PassphraseCacheService.getCachedPassphrase(context, encData.getKeyID()); + + // if passphrase was not cached, return here indicating that a passphrase is missing! + if (passphrase == null) { + returnData.setKeyPassphraseNeeded(true); + return returnData; + } } - // if passphrase was not cached, return here! - if (passphrase == null) { - returnData.setKeyPassphraseNeeded(true); - return returnData; - } + break; } @@ -644,7 +646,7 @@ public class PgpDecryptVerify { if (signKeyRing != null) { mKey = PgpKeyHelper.getMasterKey(signKeyRing); } - + if (signature.getKeyID() != mKey.getKeyID()) { validKeyBinding = verifyKeyBinding(mKey, signatureKey); } else { //if the key used to make the signature was the master key, no need to check binding sigs