do respect expectedFingerprint during key import

This commit is contained in:
Vincent Breitmoser 2014-06-04 21:35:03 +02:00
parent cc1e4dce0a
commit 2946d442e5
2 changed files with 18 additions and 9 deletions

View File

@ -3,11 +3,6 @@ package org.sufficientlysecure.keychain.keyimport;
import android.os.Parcel;
import android.os.Parcelable;
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
import java.io.IOException;
/** This is a trivial wrapper around UncachedKeyRing which implements Parcelable. It exists
* for the sole purpose of keeping spongycastle and android imports in separate packages.
*/
@ -40,12 +35,15 @@ public class ParcelableKeyRing implements Parcelable {
}
};
public int describeContents() {
return 0;
}
public UncachedKeyRing getUncachedKeyRing() throws PgpGeneralException, IOException {
return UncachedKeyRing.decodeFromData(mBytes);
public byte[] getBytes() {
return mBytes;
}
public String getExpectedFingerprint() {
return mExpectedFingerprint;
}
}

View File

@ -139,7 +139,18 @@ public class PgpImportExport {
int position = 0;
for (ParcelableKeyRing entry : entries) {
try {
UncachedKeyRing key = entry.getUncachedKeyRing();
UncachedKeyRing key = UncachedKeyRing.decodeFromData(entry.getBytes());
String expectedFp = entry.getExpectedFingerprint();
if(expectedFp != null) {
if(!PgpKeyHelper.convertFingerprintToHex(key.getFingerprint()).equals(expectedFp)) {
Log.e(Constants.TAG, "Actual key fingerprint is not the same as expected!");
badKeys += 1;
continue;
} else {
Log.d(Constants.TAG, "Actual key fingerprint matches expected one.");
}
}
mProviderHelper.savePublicKeyRing(key);
/*switch(status) {