aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain/src/org/sufficientlysecure/keychain
diff options
context:
space:
mode:
authorAshley Hughes <spirit.returned@gmail.com>2013-09-17 18:19:30 +0100
committerAshley Hughes <spirit.returned@gmail.com>2013-09-17 18:19:30 +0100
commitb4382db2638a7b29c95bfb8b442ca9f7644b9d8c (patch)
treeecebd57b3b32d5174632e84884edbe786f43c5a8 /OpenPGP-Keychain/src/org/sufficientlysecure/keychain
parent73ccb816acda7879c66f795045a98e228cb8b58a (diff)
downloadopen-keychain-b4382db2638a7b29c95bfb8b442ca9f7644b9d8c.tar.gz
open-keychain-b4382db2638a7b29c95bfb8b442ca9f7644b9d8c.tar.bz2
open-keychain-b4382db2638a7b29c95bfb8b442ca9f7644b9d8c.zip
add public keys when importing secret keys
Diffstat (limited to 'OpenPGP-Keychain/src/org/sufficientlysecure/keychain')
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/pgp/PgpImportExport.java12
1 files changed, 12 insertions, 0 deletions
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/pgp/PgpImportExport.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/pgp/PgpImportExport.java
index c4ce3d29a..dac9c9b11 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/pgp/PgpImportExport.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/pgp/PgpImportExport.java
@@ -26,9 +26,12 @@ import java.io.OutputStream;
import java.util.ArrayList;
import org.spongycastle.bcpg.ArmoredOutputStream;
+import org.spongycastle.openpgp.operator.KeyFingerPrintCalculator;
+import org.spongycastle.openpgp.operator.jcajce.JcaKeyFingerprintCalculator;
import org.spongycastle.openpgp.PGPException;
import org.spongycastle.openpgp.PGPKeyRing;
import org.spongycastle.openpgp.PGPObjectFactory;
+import org.spongycastle.openpgp.PGPPublicKey;
import org.spongycastle.openpgp.PGPPublicKeyRing;
import org.spongycastle.openpgp.PGPSecretKey;
import org.spongycastle.openpgp.PGPSecretKeyRing;
@@ -261,6 +264,15 @@ public class PgpImportExport {
if (save) {
ProviderHelper.saveKeyRing(mContext, secretKeyRing);
+ // TODO: preserve certifications (http://osdir.com/ml/encryption.bouncy-castle.devel/2007-01/msg00054.html ?)
+ PGPPublicKeyRing newPubRing = null;
+ for (PGPPublicKey key : new IterableIterator<PGPPublicKey>(secretKeyRing.getPublicKeys())) {
+ if (newPubRing == null) {
+ newPubRing = new PGPPublicKeyRing(key.getEncoded(), new JcaKeyFingerprintCalculator());
+ }
+ newPubRing = PGPPublicKeyRing.insertPublicKey(newPubRing, key);
+ }
+ ProviderHelper.saveKeyRing(mContext, newPubRing);
// TODO: remove status returns, use exceptions!
status = Id.return_value.ok;
}