check for fingerprint of any subkey (arguable?)

This commit is contained in:
Vincent Breitmoser 2015-05-06 11:25:29 +02:00
parent a45aaa2277
commit 91d500b20d
2 changed files with 18 additions and 6 deletions

View File

@ -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();
}
}

View File

@ -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;