collect all potential keys before asking for passphrase

This commit is contained in:
Vincent Breitmoser
2017-11-23 10:55:42 +01:00
parent 8154b46326
commit 5e416d6ae5
2 changed files with 59 additions and 21 deletions

View File

@@ -80,6 +80,7 @@ import org.sufficientlysecure.keychain.provider.KeyWritableRepository;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel.RequireAnyDecryptPassphraseBuilder;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import org.sufficientlysecure.keychain.util.CharsetVerifier;
import org.sufficientlysecure.keychain.util.FileHelper;
@@ -583,6 +584,8 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
Iterator<?> it = enc.getEncryptedDataObjects();
RequireAnyDecryptPassphraseBuilder requirePassphraseBuilder = new RequireAnyDecryptPassphraseBuilder();
// go through all objects and find one we can decrypt
while (it.hasNext()) {
Object obj = it.next();
@@ -662,9 +665,8 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
// if passphrase was not cached, return here indicating that a passphrase is missing!
if (passphrase == null) {
log.add(LogType.MSG_DC_PENDING_PASSPHRASE, indent + 1);
return result.with(new DecryptVerifyResult(log,
RequiredInputParcel.createRequiredDecryptPassphrase(masterKeyId, subKeyId),
cryptoInput));
requirePassphraseBuilder.add(masterKeyId, subKeyId);
continue;
}
}
@@ -738,6 +740,10 @@ public class PgpDecryptVerifyOperation extends BaseOperation<PgpDecryptVerifyInp
}
}
if (!asymmetricPacketFound && !requirePassphraseBuilder.isEmpty()) {
return result.with(new DecryptVerifyResult(log, requirePassphraseBuilder.build(), cryptoInput));
}
// More data, just acknowledge and ignore.
while (it.hasNext()) {
Object obj = it.next();