aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain/src/org/sufficientlysecure/keychain
diff options
context:
space:
mode:
authorAsh Hughes <ashes-iontach@hotmail.com>2013-03-14 22:04:24 +0000
committerAsh Hughes <ashes-iontach@hotmail.com>2013-03-14 22:04:24 +0000
commitdd27d132beb47fb8878a36df3a2ccc8455c81ec2 (patch)
tree926eff97933332120b39fe4bf7430ab8dd01a633 /OpenPGP-Keychain/src/org/sufficientlysecure/keychain
parent935274960d6a81c64fe829dd3cada4436e044e90 (diff)
downloadopen-keychain-dd27d132beb47fb8878a36df3a2ccc8455c81ec2.tar.gz
open-keychain-dd27d132beb47fb8878a36df3a2ccc8455c81ec2.tar.bz2
open-keychain-dd27d132beb47fb8878a36df3a2ccc8455c81ec2.zip
tidy up code
Diffstat (limited to 'OpenPGP-Keychain/src/org/sufficientlysecure/keychain')
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/helper/PgpHelper.java16
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/helper/PgpMain.java10
2 files changed, 6 insertions, 20 deletions
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/helper/PgpHelper.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/helper/PgpHelper.java
index 697eb1aaa..9b8e4cb23 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/helper/PgpHelper.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/helper/PgpHelper.java
@@ -164,16 +164,8 @@ public class PgpHelper {
for (int i = 0; i < signingKeys.size(); ++i) {
PGPSecretKey key = signingKeys.get(i);
if (key.isMasterKey()) {
- try {
- PBESecretKeyDecryptor keyDecryptor = new JcePBESecretKeyDecryptorBuilder()
- .setProvider(PgpMain.BOUNCY_CASTLE_PROVIDER_NAME).build(new char[] {});
- PGPPrivateKey testKey = key.extractPrivateKey(
- keyDecryptor);
- if (testKey != null) {
- masterKey = key;
- }
- } catch (PGPException e) {
- // all good if this fails, we likely didn't use the right password
+ if (!isSecretKeyPrivateEmpty(key)) {
+ masterKey = key;
}
} else {
usableKeys.add(key);
@@ -424,8 +416,8 @@ public class PgpHelper {
if (testKey != null) {
return false;
}
- } catch (PGPException e) {
- // all good if this fails, we likely didn't use the right password
+ } catch (PGPException e) { //exception if wrong key => not empty
+ return false; //all good if this fails, we likely didn't use the right password
}
return true;
}
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/helper/PgpMain.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/helper/PgpMain.java
index 26739f564..f4b7c7bbd 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/helper/PgpMain.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/helper/PgpMain.java
@@ -493,18 +493,12 @@ public class PgpMain {
boolean save = true;
for (PGPSecretKey testSecretKey : new IterableIterator<PGPSecretKey>(secretKeyRing.getSecretKeys())) {
- try {
- PBESecretKeyDecryptor keyDecryptor = new JcePBESecretKeyDecryptorBuilder()
- .setProvider(BOUNCY_CASTLE_PROVIDER_NAME).build(new char[] {});
- PGPPrivateKey testKey = testSecretKey.extractPrivateKey(
- keyDecryptor);
- if (testKey == null && !testSecretKey.isMasterKey()) {
+ if (!testSecretKey.isMasterKey()) {
+ if (PgpHelper.isSecretKeyPrivateEmpty(testSecretKey)) {
// this is bad, something is very wrong...
save = false;
status = Id.return_value.bad;
}
- } catch (PGPException e) {
- // all good if this fails, we likely didn't use the right password
}
}