aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp
diff options
context:
space:
mode:
Diffstat (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp')
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java11
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerifyResult.java38
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpHelper.java3
3 files changed, 30 insertions, 22 deletions
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java
index 571729bc5..d06898c89 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java
@@ -75,7 +75,7 @@ public class PgpDecryptVerify {
// optional
private ProgressDialogUpdater mProgressDialogUpdater = null;
private boolean mAssumeSymmetric = false;
- private String mPassphrase = "";
+ private String mPassphrase = null;
private long mEnforcedKeyId = 0;
public Builder(Context context, InputData data, OutputStream outStream) {
@@ -253,8 +253,6 @@ public class PgpDecryptVerify {
encryptedData = pbe;
currentProgress += 5;
} else {
- updateProgress(R.string.progress_finding_key, currentProgress, 100);
-
PGPPublicKeyEncryptedData pbe = null;
PGPSecretKey secretKey = null;
Iterator<?> it = enc.getEncryptedDataObjects();
@@ -262,6 +260,8 @@ public class PgpDecryptVerify {
while (it.hasNext()) {
Object obj = it.next();
if (obj instanceof PGPPublicKeyEncryptedData) {
+ updateProgress(R.string.progress_finding_key, currentProgress, 100);
+
PGPPublicKeyEncryptedData encData = (PGPPublicKeyEncryptedData) obj;
secretKey = ProviderHelper.getPGPSecretKeyByKeyId(mContext, encData.getKeyID());
if (secretKey != null) {
@@ -294,14 +294,15 @@ public class PgpDecryptVerify {
// if passphrase was not cached, return here
// indicating that a passphrase is missing!
if (mPassphrase == null) {
- returnData.setKeyPassphraseNeeded(true);
+ returnData.setKeyIdPassphraseNeeded(encData.getKeyID());
+ returnData.setStatus(PgpDecryptVerifyResult.KEY_PASSHRASE_NEEDED);
return returnData;
}
}
break;
}
-
+ } else if (obj instanceof PGPPBEEncryptedData) {
}
}
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerifyResult.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerifyResult.java
index d4a4f6075..ad240e834 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerifyResult.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerifyResult.java
@@ -19,27 +19,33 @@ package org.sufficientlysecure.keychain.pgp;
import android.os.Parcel;
import android.os.Parcelable;
+
import org.openintents.openpgp.OpenPgpSignatureResult;
public class PgpDecryptVerifyResult implements Parcelable {
- boolean mSymmetricPassphraseNeeded;
- boolean mKeyPassphraseNeeded;
+ public static final int SUCCESS = 1;
+ public static final int KEY_PASSHRASE_NEEDED = 2;
+ public static final int SYMMETRIC_PASSHRASE_NEEDED = 3;
+
+ int mStatus;
+ long mKeyIdPassphraseNeeded;
+
OpenPgpSignatureResult mSignatureResult;
- public boolean isSymmetricPassphraseNeeded() {
- return mSymmetricPassphraseNeeded;
+ public int getStatus() {
+ return mStatus;
}
- public void setSymmetricPassphraseNeeded(boolean symmetricPassphraseNeeded) {
- this.mSymmetricPassphraseNeeded = symmetricPassphraseNeeded;
+ public void setStatus(int mStatus) {
+ this.mStatus = mStatus;
}
- public boolean isKeyPassphraseNeeded() {
- return mKeyPassphraseNeeded;
+ public long getKeyIdPassphraseNeeded() {
+ return mKeyIdPassphraseNeeded;
}
- public void setKeyPassphraseNeeded(boolean keyPassphraseNeeded) {
- this.mKeyPassphraseNeeded = keyPassphraseNeeded;
+ public void setKeyIdPassphraseNeeded(long mKeyIdPassphraseNeeded) {
+ this.mKeyIdPassphraseNeeded = mKeyIdPassphraseNeeded;
}
public OpenPgpSignatureResult getSignatureResult() {
@@ -55,8 +61,8 @@ public class PgpDecryptVerifyResult implements Parcelable {
}
public PgpDecryptVerifyResult(PgpDecryptVerifyResult b) {
- this.mSymmetricPassphraseNeeded = b.mSymmetricPassphraseNeeded;
- this.mKeyPassphraseNeeded = b.mKeyPassphraseNeeded;
+ this.mStatus = b.mStatus;
+ this.mKeyIdPassphraseNeeded = b.mKeyIdPassphraseNeeded;
this.mSignatureResult = b.mSignatureResult;
}
@@ -66,16 +72,16 @@ public class PgpDecryptVerifyResult implements Parcelable {
}
public void writeToParcel(Parcel dest, int flags) {
- dest.writeByte((byte) (mSymmetricPassphraseNeeded ? 1 : 0));
- dest.writeByte((byte) (mKeyPassphraseNeeded ? 1 : 0));
+ dest.writeInt(mStatus);
+ dest.writeLong(mKeyIdPassphraseNeeded);
dest.writeParcelable(mSignatureResult, 0);
}
public static final Creator<PgpDecryptVerifyResult> CREATOR = new Creator<PgpDecryptVerifyResult>() {
public PgpDecryptVerifyResult createFromParcel(final Parcel source) {
PgpDecryptVerifyResult vr = new PgpDecryptVerifyResult();
- vr.mSymmetricPassphraseNeeded = source.readByte() == 1;
- vr.mKeyPassphraseNeeded = source.readByte() == 1;
+ vr.mStatus = source.readInt();
+ vr.mKeyIdPassphraseNeeded = source.readLong();
vr.mSignatureResult = source.readParcelable(OpenPgpSignatureResult.class.getClassLoader());
return vr;
}
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpHelper.java
index 2680d77af..cc40afbac 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpHelper.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpHelper.java
@@ -20,6 +20,7 @@ package org.sufficientlysecure.keychain.pgp;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
+
import org.spongycastle.openpgp.*;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.Id;
@@ -43,7 +44,7 @@ public class PgpHelper {
public static final Pattern PGP_MESSAGE = Pattern.compile(
".*?(-----BEGIN PGP MESSAGE-----.*?-----END PGP MESSAGE-----).*", Pattern.DOTALL);
- public static final Pattern PGP_SIGNED_MESSAGE = Pattern
+ public static final Pattern PGP_CLEARTEXT_SIGNATURE = Pattern
.compile(
".*?(-----BEGIN PGP SIGNED MESSAGE-----.*?-----BEGIN PGP SIGNATURE-----.*?-----END PGP SIGNATURE-----).*",
Pattern.DOTALL);