aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain/src/org
diff options
context:
space:
mode:
Diffstat (limited to 'OpenPGP-Keychain/src/org')
-rw-r--r--OpenPGP-Keychain/src/org/openintents/crypto/CryptoError.java2
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java23
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java6
3 files changed, 27 insertions, 4 deletions
diff --git a/OpenPGP-Keychain/src/org/openintents/crypto/CryptoError.java b/OpenPGP-Keychain/src/org/openintents/crypto/CryptoError.java
index 265fe2633..2766b8805 100644
--- a/OpenPGP-Keychain/src/org/openintents/crypto/CryptoError.java
+++ b/OpenPGP-Keychain/src/org/openintents/crypto/CryptoError.java
@@ -20,6 +20,8 @@ import android.os.Parcel;
import android.os.Parcelable;
public class CryptoError implements Parcelable {
+ public static final int ID_NO_WRONG_PASSPHRASE = 1;
+
int errorId;
String message;
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java
index 925b93324..e33314ea6 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java
@@ -107,7 +107,7 @@ public class CryptoService extends Service {
} else {
Log.d(Constants.TAG, "Passphrase dialog canceled!");
- // TODO: stop thread?!
+ return null;
}
}
@@ -119,7 +119,7 @@ public class CryptoService extends Service {
public static final int SUCCESS = 1;
public static final int NO_SUCCESS = 0;
- private boolean success;
+ private boolean success = false;
public boolean isSuccess() {
return success;
@@ -203,7 +203,7 @@ public class CryptoService extends Service {
public static final int CANCEL = 0;
public static final String PUB_KEY_IDS = "pub_key_ids";
- private boolean newSelection;
+ private boolean newSelection = false;
private long[] pubKeyIds;
public boolean isNewSelection() {
@@ -246,6 +246,11 @@ public class CryptoService extends Service {
if (sign) {
String passphrase = getCachedPassphrase(appSettings.getKeyId());
+ if (passphrase == null) {
+ callback.onError(new CryptoError(CryptoError.ID_NO_WRONG_PASSPHRASE,
+ "No or wrong passphrase!"));
+ return;
+ }
PgpMain.encryptAndSign(mContext, null, inputData, outputStream,
appSettings.isAsciiArmor(), appSettings.getCompression(), keyIds, null,
@@ -288,6 +293,11 @@ public class CryptoService extends Service {
OutputStream outputStream = new ByteArrayOutputStream();
String passphrase = getCachedPassphrase(appSettings.getKeyId());
+ if (passphrase == null) {
+ callback.onError(new CryptoError(CryptoError.ID_NO_WRONG_PASSPHRASE,
+ "No or wrong passphrase!"));
+ return;
+ }
PgpMain.signText(this, null, inputData, outputStream, appSettings.getKeyId(),
passphrase, appSettings.getHashAlgorithm(), Preferences.getPreferences(this)
@@ -334,6 +344,11 @@ public class CryptoService extends Service {
Log.d(Constants.TAG, "secretKeyId " + secretKeyId);
String passphrase = getCachedPassphrase(secretKeyId);
+ if (passphrase == null) {
+ callback.onError(new CryptoError(CryptoError.ID_NO_WRONG_PASSPHRASE,
+ "No or wrong passphrase!"));
+ return;
+ }
// if (signedOnly) {
// resultData = PgpMain.verifyText(this, this, inputData, outStream,
@@ -501,7 +516,7 @@ public class CryptoService extends Service {
public static final int DISALLOW = 0;
public static final String PACKAGE_NAME = "package_name";
- private boolean allowed;
+ private boolean allowed = false;
private String packageName;
public boolean isAllowed() {
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java
index 80b6e5834..2da86862c 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java
@@ -173,6 +173,8 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor
Toast.makeText(activity,
R.string.error_couldNotExtractPrivateKey,
Toast.LENGTH_SHORT).show();
+
+ sendMessageToHandler(MESSAGE_CANCEL);
return;
} else {
clickSecretKey = PgpHelper.getKeyNum(ProviderHelper
@@ -187,11 +189,15 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor
} catch (PGPException e) {
Toast.makeText(activity, R.string.wrongPassPhrase,
Toast.LENGTH_SHORT).show();
+
+ sendMessageToHandler(MESSAGE_CANCEL);
return;
}
} else {
Toast.makeText(activity, R.string.error_couldNotExtractPrivateKey,
Toast.LENGTH_SHORT).show();
+
+ sendMessageToHandler(MESSAGE_CANCEL);
return; // ran out of keys to try
}
}