mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-11 03:25:05 -05:00
do respect expectedFingerprint during key import
This commit is contained in:
parent
cc1e4dce0a
commit
2946d442e5
@ -3,11 +3,6 @@ package org.sufficientlysecure.keychain.keyimport;
|
|||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
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
|
/** 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.
|
* 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() {
|
public int describeContents() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UncachedKeyRing getUncachedKeyRing() throws PgpGeneralException, IOException {
|
public byte[] getBytes() {
|
||||||
return UncachedKeyRing.decodeFromData(mBytes);
|
return mBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getExpectedFingerprint() {
|
||||||
|
return mExpectedFingerprint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,18 @@ public class PgpImportExport {
|
|||||||
int position = 0;
|
int position = 0;
|
||||||
for (ParcelableKeyRing entry : entries) {
|
for (ParcelableKeyRing entry : entries) {
|
||||||
try {
|
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);
|
mProviderHelper.savePublicKeyRing(key);
|
||||||
/*switch(status) {
|
/*switch(status) {
|
||||||
|
Loading…
Reference in New Issue
Block a user