aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java13
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java11
2 files changed, 18 insertions, 6 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java
index ff0b545cd..b48a1da91 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/ImportExportOperation.java
@@ -275,7 +275,7 @@ public class ImportExportOperation extends BaseOperation {
// If we have an expected fingerprint, make sure it matches
if (entry.mExpectedFingerprint != null) {
- if(!KeyFormattingUtils.convertFingerprintToHex(key.getFingerprint()).equals(entry.mExpectedFingerprint)) {
+ if (!key.containsSubkey(entry.mExpectedFingerprint)) {
log.add(LogType.MSG_IMPORT_FINGERPRINT_ERROR, 2);
badKeys += 1;
continue;
@@ -314,10 +314,7 @@ public class ImportExportOperation extends BaseOperation {
log.add(result, 2);
- } catch (IOException e) {
- Log.e(Constants.TAG, "Encountered bad key on import!", e);
- ++badKeys;
- } catch (PgpGeneralException e) {
+ } catch (IOException | PgpGeneralException e) {
Log.e(Constants.TAG, "Encountered bad key on import!", e);
++badKeys;
}
@@ -460,6 +457,7 @@ public class ImportExportOperation extends BaseOperation {
int okSecret = 0, okPublic = 0, progress = 0;
+ Cursor cursor = null;
try {
String selection = null, ids[] = null;
@@ -480,7 +478,7 @@ public class ImportExportOperation extends BaseOperation {
+ " IN (" + placeholders + ")";
}
- Cursor cursor = mProviderHelper.getContentResolver().query(
+ cursor = mProviderHelper.getContentResolver().query(
KeyRings.buildUnifiedKeyRingsUri(), new String[]{
KeyRings.MASTER_KEY_ID, KeyRings.PUBKEY_DATA,
KeyRings.PRIVKEY_DATA, KeyRings.HAS_ANY_SECRET
@@ -569,6 +567,9 @@ public class ImportExportOperation extends BaseOperation {
} catch (Exception e) {
Log.e(Constants.TAG, "error closing stream", e);
}
+ if (cursor != null) {
+ cursor.close();
+ }
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java
index b86618a9a..2bb4f7dc4 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedKeyRing.java
@@ -215,6 +215,17 @@ public class UncachedKeyRing {
}
+ public boolean containsSubkey(String expectedFingerprint) {
+ Iterator<PGPPublicKey> it = mRing.getPublicKeys();
+ while (it.hasNext()) {
+ if (KeyFormattingUtils.convertFingerprintToHex(
+ it.next().getFingerprint()).equals(expectedFingerprint)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
public interface IteratorWithIOThrow<E> {
public boolean hasNext() throws IOException;
public E next() throws IOException;