aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2014-05-21 21:07:32 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2014-05-21 21:07:32 +0200
commit761d87b661ef14023870ad7be107d33d69ab03e7 (patch)
treef99d583784fde28d467dbeabd583c32755c3807c /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp
parent2f95100d88954db389cba8e615390795d121c1c8 (diff)
downloadopen-keychain-761d87b661ef14023870ad7be107d33d69ab03e7.tar.gz
open-keychain-761d87b661ef14023870ad7be107d33d69ab03e7.tar.bz2
open-keychain-761d87b661ef14023870ad7be107d33d69ab03e7.zip
wrapped-key-ring: split up CachedKeyRing and WrappedKeyRing
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CachedKeyRing.java68
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/KeyRing.java25
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java30
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java5
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java3
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java4
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java10
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedKeyRing.java81
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedPublicKey.java (renamed from OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CachedPublicKey.java)8
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedPublicKeyRing.java (renamed from OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CachedPublicKeyRing.java)33
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedSecretKey.java (renamed from OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CachedSecretKey.java)10
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedSecretKeyRing.java (renamed from OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CachedSecretKeyRing.java)31
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/exception/PgpGeneralException.java3
13 files changed, 173 insertions, 138 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CachedKeyRing.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CachedKeyRing.java
deleted file mode 100644
index def673469..000000000
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CachedKeyRing.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package org.sufficientlysecure.keychain.pgp;
-
-public abstract class CachedKeyRing {
-
- private final long mMasterKeyId;
- private final String mUserId;
- private final boolean mHasAnySecret;
- private final boolean mIsRevoked;
- private final boolean mCanCertify;
- private final long mHasEncryptId;
- private final long mHasSignId;
- private final int mVerified;
-
- protected CachedKeyRing(long masterKeyId, String userId, boolean hasAnySecret,
- boolean isRevoked, boolean canCertify, long hasEncryptId, long hasSignId,
- int verified)
- {
- mMasterKeyId = masterKeyId;
- mUserId = userId;
- mHasAnySecret = hasAnySecret;
- mIsRevoked = isRevoked;
- mCanCertify = canCertify;
- mHasEncryptId = hasEncryptId;
- mHasSignId = hasSignId;
- mVerified = verified;
- }
-
- public long getMasterKeyId() {
- return mMasterKeyId;
- }
-
- public String getPrimaryUserId() {
- return mUserId;
- }
-
- public boolean hasAnySecret() {
- return mHasAnySecret;
- }
-
- public boolean isRevoked() {
- return mIsRevoked;
- }
-
- public boolean canCertify() {
- return mCanCertify;
- }
-
- public long getEncryptId() {
- return mHasEncryptId;
- }
-
- public boolean hasEncrypt() {
- return mHasEncryptId != 0;
- }
-
- public long getSignId() {
- return mHasSignId;
- }
-
- public boolean hasSign() {
- return mHasSignId != 0;
- }
-
- public int getVerified() {
- return mVerified;
- }
-
-}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/KeyRing.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/KeyRing.java
new file mode 100644
index 000000000..cfbad89b7
--- /dev/null
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/KeyRing.java
@@ -0,0 +1,25 @@
+package org.sufficientlysecure.keychain.pgp;
+
+import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
+
+public abstract class KeyRing {
+
+ abstract public long getMasterKeyId() throws PgpGeneralException;
+
+ abstract public String getPrimaryUserId() throws PgpGeneralException;
+
+ abstract public boolean isRevoked() throws PgpGeneralException;
+
+ abstract public boolean canCertify() throws PgpGeneralException;
+
+ abstract public long getEncryptId() throws PgpGeneralException;
+
+ abstract public boolean hasEncrypt() throws PgpGeneralException;
+
+ abstract public long getSignId() throws PgpGeneralException;
+
+ abstract public boolean hasSign() throws PgpGeneralException;
+
+ abstract public int getVerified() throws PgpGeneralException;
+
+}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java
index 27e9e8ebd..21a7c20e3 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java
@@ -233,7 +233,7 @@ public class PgpDecryptVerify {
PGPPublicKeyEncryptedData encryptedDataAsymmetric = null;
PGPPBEEncryptedData encryptedDataSymmetric = null;
- CachedSecretKey secretEncryptionKey = null;
+ WrappedSecretKey secretEncryptionKey = null;
Iterator<?> it = enc.getEncryptedDataObjects();
boolean asymmetricPacketFound = false;
boolean symmetricPacketFound = false;
@@ -245,10 +245,10 @@ public class PgpDecryptVerify {
PGPPublicKeyEncryptedData encData = (PGPPublicKeyEncryptedData) obj;
- CachedSecretKeyRing secretKeyRing;
+ WrappedSecretKeyRing secretKeyRing;
try {
// get actual keyring object based on master key id
- secretKeyRing = mProviderHelper.getCachedSecretKeyRing(
+ secretKeyRing = mProviderHelper.getWrappedSecretKeyRing(
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(
Long.toString(encData.getKeyID()))
);
@@ -368,8 +368,8 @@ public class PgpDecryptVerify {
Object dataChunk = plainFact.nextObject();
OpenPgpSignatureResultBuilder signatureResultBuilder = new OpenPgpSignatureResultBuilder();
int signatureIndex = -1;
- CachedPublicKeyRing signingRing = null;
- CachedPublicKey signingKey = null;
+ WrappedPublicKeyRing signingRing = null;
+ WrappedPublicKey signingKey = null;
if (dataChunk instanceof PGPCompressedData) {
updateProgress(R.string.progress_decompressing_data, currentProgress, 100);
@@ -393,7 +393,7 @@ public class PgpDecryptVerify {
for (int i = 0; i < sigList.size(); ++i) {
try {
long sigKeyId = sigList.get(i).getKeyID();
- signingRing = mProviderHelper.getCachedPublicKeyRing(
+ signingRing = mProviderHelper.getWrappedPublicKeyRing(
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(
Long.toString(sigKeyId)
)
@@ -413,7 +413,11 @@ public class PgpDecryptVerify {
signatureResultBuilder.signatureAvailable(true);
signatureResultBuilder.knownKey(true);
signatureResultBuilder.keyId(signingRing.getMasterKeyId());
- signatureResultBuilder.userId(signingRing.getPrimaryUserId());
+ try {
+ signatureResultBuilder.userId(signingRing.getPrimaryUserId());
+ } catch(PgpGeneralException e) {
+ Log.d(Constants.TAG, "No primary user id in key " + signingRing.getMasterKeyId());
+ }
signatureResultBuilder.signatureKeyCertified(signingRing.getVerified() > 0);
signingKey.initSignature(signature);
@@ -567,8 +571,8 @@ public class PgpDecryptVerify {
throw new InvalidDataException();
}
- CachedPublicKeyRing signingRing = null;
- CachedPublicKey signingKey = null;
+ WrappedPublicKeyRing signingRing = null;
+ WrappedPublicKey signingKey = null;
int signatureIndex = -1;
// go through all signatures
@@ -576,7 +580,7 @@ public class PgpDecryptVerify {
for (int i = 0; i < sigList.size(); ++i) {
try {
long sigKeyId = sigList.get(i).getKeyID();
- signingRing = mProviderHelper.getCachedPublicKeyRing(
+ signingRing = mProviderHelper.getWrappedPublicKeyRing(
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(
Long.toString(sigKeyId)
)
@@ -598,7 +602,11 @@ public class PgpDecryptVerify {
signatureResultBuilder.signatureAvailable(true);
signatureResultBuilder.knownKey(true);
signatureResultBuilder.keyId(signingRing.getMasterKeyId());
- signatureResultBuilder.userId(signingRing.getPrimaryUserId());
+ try {
+ signatureResultBuilder.userId(signingRing.getPrimaryUserId());
+ } catch(PgpGeneralException e) {
+ Log.d(Constants.TAG, "No primary user id in key " + signingRing.getMasterKeyId());
+ }
signatureResultBuilder.signatureKeyCertified(signingRing.getVerified() > 0);
signingKey.initSignature(signature);
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 a0d2d5cea..5c4604647 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java
@@ -27,7 +27,6 @@ import org.spongycastle.openpgp.PGPException;
import org.spongycastle.openpgp.PGPKeyRing;
import org.spongycastle.openpgp.PGPPublicKey;
import org.spongycastle.openpgp.PGPPublicKeyRing;
-import org.spongycastle.openpgp.PGPSecretKey;
import org.spongycastle.openpgp.PGPSecretKeyRing;
import org.spongycastle.openpgp.operator.jcajce.JcaKeyFingerprintCalculator;
import org.sufficientlysecure.keychain.Constants;
@@ -101,7 +100,7 @@ public class PgpImportExport {
}
}
- public boolean uploadKeyRingToServer(HkpKeyServer server, CachedPublicKeyRing keyring) {
+ public boolean uploadKeyRingToServer(HkpKeyServer server, WrappedPublicKeyRing keyring) {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ArmoredOutputStream aos = null;
try {
@@ -229,7 +228,7 @@ public class PgpImportExport {
updateProgress(progress * 100 / masterKeyIdsSize, 100);
try {
- CachedPublicKeyRing ring = mProviderHelper.getCachedPublicKeyRing(
+ WrappedPublicKeyRing ring = mProviderHelper.getWrappedPublicKeyRing(
KeychainContract.KeyRings.buildGenericKeyRingUri(pubKeyMasterId)
);
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java
index 59a48e7eb..b25c38f1a 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java
@@ -72,7 +72,6 @@ public class PgpKeyHelper {
}
@SuppressWarnings("unchecked")
- @Deprecated
public static boolean isEncryptionKey(PGPPublicKey key) {
if (!key.isEncryptionKey()) {
return false;
@@ -114,7 +113,6 @@ public class PgpKeyHelper {
}
@SuppressWarnings("unchecked")
- @Deprecated
public static boolean isSigningKey(PGPPublicKey key) {
if (key.getVersion() <= 3) {
return true;
@@ -146,7 +144,6 @@ public class PgpKeyHelper {
}
@SuppressWarnings("unchecked")
- @Deprecated
public static boolean isCertificationKey(PGPPublicKey key) {
if (key.getVersion() <= 3) {
return true;
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java
index d0ca77da7..b9634c34a 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java
@@ -337,8 +337,8 @@ public class PgpKeyOperation {
}
- public UncachedKeyRing buildSecretKey(CachedSecretKeyRing wmKR,
- CachedPublicKeyRing wpKR,
+ public UncachedKeyRing buildSecretKey(WrappedSecretKeyRing wmKR,
+ WrappedPublicKeyRing wpKR,
SaveKeyringParcel saveParcel)
throws PgpGeneralMsgIdException, PGPException, SignatureException, IOException {
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java
index 96ee3f10a..24d090d04 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java
@@ -266,11 +266,11 @@ public class PgpSignEncrypt {
}
/* Get keys for signature generation for later usage */
- CachedSecretKey signingKey = null;
+ WrappedSecretKey signingKey = null;
if (enableSignature) {
- CachedSecretKeyRing signingKeyRing;
+ WrappedSecretKeyRing signingKeyRing;
try {
- signingKeyRing = mProviderHelper.getCachedSecretKeyRing(mSignatureMasterKeyId);
+ signingKeyRing = mProviderHelper.getWrappedSecretKeyRing(mSignatureMasterKeyId);
} catch (ProviderHelper.NotFoundException e) {
throw new NoSigningKeyException();
}
@@ -316,9 +316,9 @@ public class PgpSignEncrypt {
// Asymmetric encryption
for (long id : mEncryptionMasterKeyIds) {
try {
- CachedPublicKeyRing keyRing = mProviderHelper.getCachedPublicKeyRing(
+ WrappedPublicKeyRing keyRing = mProviderHelper.getWrappedPublicKeyRing(
KeyRings.buildUnifiedKeyRingUri(Long.toString(id)));
- CachedPublicKey key = keyRing.getEncryptionSubKey();
+ WrappedPublicKey key = keyRing.getEncryptionSubKey();
cPk.addMethod(key.getPubKeyEncryptionGenerator());
} catch (PgpGeneralException e) {
Log.e(Constants.TAG, "key not found!", e);
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedKeyRing.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedKeyRing.java
new file mode 100644
index 000000000..94eb91420
--- /dev/null
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedKeyRing.java
@@ -0,0 +1,81 @@
+package org.sufficientlysecure.keychain.pgp;
+
+import org.spongycastle.openpgp.PGPKeyRing;
+import org.spongycastle.openpgp.PGPPublicKey;
+import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
+import org.sufficientlysecure.keychain.util.IterableIterator;
+
+public abstract class WrappedKeyRing extends KeyRing {
+
+ private final boolean mHasAnySecret;
+ private final int mVerified;
+
+ WrappedKeyRing(boolean hasAnySecret, int verified) {
+ mHasAnySecret = hasAnySecret;
+ mVerified = verified;
+ }
+
+ public long getMasterKeyId() {
+ return getRing().getPublicKey().getKeyID();
+ }
+
+ public boolean hasAnySecret() {
+ return mHasAnySecret;
+ }
+
+ public int getVerified() {
+ return mVerified;
+ }
+
+ public String getPrimaryUserId() throws PgpGeneralException {
+ return (String) getRing().getPublicKey().getUserIDs().next();
+ };
+
+ public boolean isRevoked() throws PgpGeneralException {
+ // Is the master key revoked?
+ return getRing().getPublicKey().isRevoked();
+ }
+
+ public boolean canCertify() throws PgpGeneralException {
+ return getRing().getPublicKey().isEncryptionKey();
+ }
+
+ public long getEncryptId() throws PgpGeneralException {
+ for(PGPPublicKey key : new IterableIterator<PGPPublicKey>(getRing().getPublicKeys())) {
+ if(PgpKeyHelper.isEncryptionKey(key)) {
+ return key.getKeyID();
+ }
+ }
+ throw new PgpGeneralException("No valid encryption key found!");
+ }
+
+ public boolean hasEncrypt() throws PgpGeneralException {
+ try {
+ getEncryptId();
+ return true;
+ } catch(PgpGeneralException e) {
+ return false;
+ }
+ }
+
+ public long getSignId() throws PgpGeneralException {
+ for(PGPPublicKey key : new IterableIterator<PGPPublicKey>(getRing().getPublicKeys())) {
+ if(PgpKeyHelper.isSigningKey(key)) {
+ return key.getKeyID();
+ }
+ }
+ throw new PgpGeneralException("No valid signing key found!");
+ }
+
+ public boolean hasSign() throws PgpGeneralException {
+ try {
+ getSignId();
+ return true;
+ } catch (PgpGeneralException e) {
+ return false;
+ }
+ }
+
+ abstract PGPKeyRing getRing();
+
+}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CachedPublicKey.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedPublicKey.java
index dee03db6f..72352a451 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CachedPublicKey.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedPublicKey.java
@@ -11,12 +11,12 @@ import org.sufficientlysecure.keychain.util.IterableIterator;
import java.security.SignatureException;
-public class CachedPublicKey extends UncachedPublicKey {
+public class WrappedPublicKey extends UncachedPublicKey {
// this is the parent key ring
- final CachedKeyRing mRing;
+ final KeyRing mRing;
- CachedPublicKey(CachedKeyRing ring, PGPPublicKey key) {
+ WrappedPublicKey(KeyRing ring, PGPPublicKey key) {
super(key);
mRing = ring;
}
@@ -25,7 +25,7 @@ public class CachedPublicKey extends UncachedPublicKey {
return new IterableIterator<String>(mPublicKey.getUserIDs());
}
- public CachedKeyRing getKeyRing() {
+ public KeyRing getKeyRing() {
return mRing;
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CachedPublicKeyRing.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedPublicKeyRing.java
index 108ed1a4a..624382165 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CachedPublicKeyRing.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedPublicKeyRing.java
@@ -18,18 +18,13 @@ import java.security.SignatureException;
import java.util.Arrays;
import java.util.Iterator;
-public class CachedPublicKeyRing extends CachedKeyRing {
+public class WrappedPublicKeyRing extends WrappedKeyRing {
private PGPPublicKeyRing mRing;
private final byte[] mPubKey;
- public CachedPublicKeyRing(long masterKeyId, String userId, boolean hasAnySecret,
- boolean isRevoked, boolean canCertify, long hasEncryptId, long hasSignId,
- int verified, byte[] blob)
- {
- super(masterKeyId, userId, hasAnySecret, isRevoked, canCertify,
- hasEncryptId, hasSignId, verified);
-
+ public WrappedPublicKeyRing(byte[] blob, boolean hasAnySecret, int verified) {
+ super(hasAnySecret, verified);
mPubKey = blob;
}
@@ -44,19 +39,19 @@ public class CachedPublicKeyRing extends CachedKeyRing {
getRing().encode(stream);
}
- public CachedPublicKey getSubkey() {
- return new CachedPublicKey(this, getRing().getPublicKey());
+ public WrappedPublicKey getSubkey() {
+ return new WrappedPublicKey(this, getRing().getPublicKey());
}
- public CachedPublicKey getSubkey(long id) {
- return new CachedPublicKey(this, getRing().getPublicKey(id));
+ public WrappedPublicKey getSubkey(long id) {
+ return new WrappedPublicKey(this, getRing().getPublicKey(id));
}
/** Getter that returns the subkey that should be used for signing. */
- CachedPublicKey getEncryptionSubKey() throws PgpGeneralException {
+ WrappedPublicKey getEncryptionSubKey() throws PgpGeneralException {
PGPPublicKey key = getRing().getPublicKey(getEncryptId());
if(key != null) {
- CachedPublicKey cKey = new CachedPublicKey(this, key);
+ WrappedPublicKey cKey = new WrappedPublicKey(this, key);
if(!cKey.canEncrypt()) {
throw new PgpGeneralException("key error");
}
@@ -66,7 +61,7 @@ public class CachedPublicKeyRing extends CachedKeyRing {
throw new PgpGeneralException("no encryption key available");
}
- public boolean verifySubkeyBinding(CachedPublicKey cachedSubkey) {
+ public boolean verifySubkeyBinding(WrappedPublicKey cachedSubkey) {
boolean validSubkeyBinding = false;
boolean validTempSubkeyBinding = false;
boolean validPrimaryKeyBinding = false;
@@ -161,17 +156,17 @@ public class CachedPublicKeyRing extends CachedKeyRing {
return validPrimaryKeyBinding;
}
- public IterableIterator<CachedPublicKey> iterator() {
+ public IterableIterator<WrappedPublicKey> iterator() {
final Iterator<PGPPublicKey> it = getRing().getPublicKeys();
- return new IterableIterator<CachedPublicKey>(new Iterator<CachedPublicKey>() {
+ return new IterableIterator<WrappedPublicKey>(new Iterator<WrappedPublicKey>() {
@Override
public boolean hasNext() {
return it.hasNext();
}
@Override
- public CachedPublicKey next() {
- return new CachedPublicKey(CachedPublicKeyRing.this, it.next());
+ public WrappedPublicKey next() {
+ return new WrappedPublicKey(WrappedPublicKeyRing.this, it.next());
}
@Override
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CachedSecretKey.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedSecretKey.java
index 8e45ceb4f..a03e10098 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CachedSecretKey.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedSecretKey.java
@@ -26,18 +26,18 @@ import java.security.NoSuchProviderException;
import java.security.SignatureException;
import java.util.List;
-public class CachedSecretKey extends CachedPublicKey {
+public class WrappedSecretKey extends WrappedPublicKey {
private final PGPSecretKey mSecretKey;
private PGPPrivateKey mPrivateKey = null;
- CachedSecretKey(CachedSecretKeyRing ring, PGPSecretKey key) {
+ WrappedSecretKey(WrappedSecretKeyRing ring, PGPSecretKey key) {
super(ring, key.getPublicKey());
mSecretKey = key;
}
- public CachedSecretKeyRing getRing() {
- return (CachedSecretKeyRing) mRing;
+ public WrappedSecretKeyRing getRing() {
+ return (WrappedSecretKeyRing) mRing;
}
/** Returns the wrapped PGPSecretKeyRing.
@@ -137,7 +137,7 @@ public class CachedSecretKey extends CachedPublicKey {
* @param userIds User IDs to certify, must not be null or empty
* @return A keyring with added certifications
*/
- public UncachedKeyRing certifyUserIds(CachedPublicKeyRing publicKeyRing, List<String> userIds)
+ public UncachedKeyRing certifyUserIds(WrappedPublicKeyRing publicKeyRing, List<String> userIds)
throws PgpGeneralMsgIdException, NoSuchAlgorithmException, NoSuchProviderException,
PGPException, SignatureException {
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CachedSecretKeyRing.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedSecretKeyRing.java
index 398092aeb..c94b7dfba 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/CachedSecretKeyRing.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/WrappedSecretKeyRing.java
@@ -16,18 +16,13 @@ import java.io.IOException;
import java.security.NoSuchProviderException;
import java.util.Iterator;
-public class CachedSecretKeyRing extends CachedKeyRing {
+public class WrappedSecretKeyRing extends WrappedKeyRing {
private PGPSecretKeyRing mRing;
- public CachedSecretKeyRing(long masterKeyId, String userId, boolean hasAnySecret,
- boolean isRevoked, boolean canCertify, long hasEncryptId, long hasSignId,
- int verified, byte[] blob)
+ public WrappedSecretKeyRing(byte[] blob, boolean isRevoked, int verified)
{
- super(masterKeyId, userId, hasAnySecret,
- isRevoked, canCertify, hasEncryptId, hasSignId,
- verified);
-
+ super(isRevoked, verified);
mRing = (PGPSecretKeyRing) PgpConversionHelper.BytesToPGPKeyRing(blob);
}
@@ -35,19 +30,19 @@ public class CachedSecretKeyRing extends CachedKeyRing {
return mRing;
}
- public CachedSecretKey getSubKey() {
- return new CachedSecretKey(this, mRing.getSecretKey());
+ public WrappedSecretKey getSubKey() {
+ return new WrappedSecretKey(this, mRing.getSecretKey());
}
- public CachedSecretKey getSubKey(long id) {
- return new CachedSecretKey(this, mRing.getSecretKey(id));
+ public WrappedSecretKey getSubKey(long id) {
+ return new WrappedSecretKey(this, mRing.getSecretKey(id));
}
/** Getter that returns the subkey that should be used for signing. */
- CachedSecretKey getSigningSubKey() throws PgpGeneralException {
+ WrappedSecretKey getSigningSubKey() throws PgpGeneralException {
PGPSecretKey key = mRing.getSecretKey(getSignId());
if(key != null) {
- CachedSecretKey cKey = new CachedSecretKey(this, key);
+ WrappedSecretKey cKey = new WrappedSecretKey(this, key);
if(!cKey.canSign()) {
throw new PgpGeneralException("key error");
}
@@ -105,17 +100,17 @@ public class CachedSecretKeyRing extends CachedKeyRing {
}
- public IterableIterator<CachedSecretKey> iterator() {
+ public IterableIterator<WrappedSecretKey> iterator() {
final Iterator<PGPSecretKey> it = mRing.getSecretKeys();
- return new IterableIterator<CachedSecretKey>(new Iterator<CachedSecretKey>() {
+ return new IterableIterator<WrappedSecretKey>(new Iterator<WrappedSecretKey>() {
@Override
public boolean hasNext() {
return it.hasNext();
}
@Override
- public CachedSecretKey next() {
- return new CachedSecretKey(CachedSecretKeyRing.this, it.next());
+ public WrappedSecretKey next() {
+ return new WrappedSecretKey(WrappedSecretKeyRing.this, it.next());
}
@Override
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/exception/PgpGeneralException.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/exception/PgpGeneralException.java
index 37d21eea4..f37a61852 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/exception/PgpGeneralException.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/exception/PgpGeneralException.java
@@ -27,4 +27,7 @@ public class PgpGeneralException extends Exception {
public PgpGeneralException(String message, Throwable cause) {
super(message, cause);
}
+ public PgpGeneralException(Throwable cause) {
+ super(cause);
+ }
}