diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2014-06-04 21:35:03 +0200 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2014-06-04 21:35:03 +0200 |
commit | 2946d442e5d51a3e65029b1df2032194d3dc7e2e (patch) | |
tree | 679d7da2b8168e22d8663048491d58edddb76c9c /OpenKeychain/src/main/java/org/sufficientlysecure | |
parent | cc1e4dce0a71161911091ff7c2bfa0947642cd79 (diff) | |
download | open-keychain-2946d442e5d51a3e65029b1df2032194d3dc7e2e.tar.gz open-keychain-2946d442e5d51a3e65029b1df2032194d3dc7e2e.tar.bz2 open-keychain-2946d442e5d51a3e65029b1df2032194d3dc7e2e.zip |
do respect expectedFingerprint during key import
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ParcelableKeyRing.java | 14 | ||||
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java | 13 |
2 files changed, 18 insertions, 9 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ParcelableKeyRing.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ParcelableKeyRing.java index 3d3b6339a..5da6c4cd3 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ParcelableKeyRing.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ParcelableKeyRing.java @@ -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; } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java index 1817ad3a6..14ec67e64 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java @@ -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) { |