aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain
diff options
context:
space:
mode:
authorAshley Hughes <spirit.returned@gmail.com>2014-03-24 16:47:02 +0000
committerAshley Hughes <spirit.returned@gmail.com>2014-03-24 16:47:02 +0000
commit300b90bcac6fbf5b5e416943e538a2c2bc49342c (patch)
tree4baa71849970681e281ed6df22b620f14118218a /OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain
parent974514e470d6835ee7a2f6cc34863dae23f16a3e (diff)
downloadopen-keychain-300b90bcac6fbf5b5e416943e538a2c2bc49342c.tar.gz
open-keychain-300b90bcac6fbf5b5e416943e538a2c2bc49342c.tar.bz2
open-keychain-300b90bcac6fbf5b5e416943e538a2c2bc49342c.zip
make sure ID info is saved
Diffstat (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain')
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java13
1 files changed, 10 insertions, 3 deletions
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java
index 3d7826553..5f97aa2e5 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java
@@ -368,7 +368,7 @@ public class PgpKeyOperation {
}
/*
- IDs -
+ IDs - NB This might not need to happen later, if we change the way the primary ID is chosen
remove deleted ids
if the primary ID changed we need to:
remove all of the IDs from the keyring, saving their certifications
@@ -382,8 +382,6 @@ public class PgpKeyOperation {
do we need to remove and add in?
*/
- //todo: flag changes of master key if IDs changed maybe?
-
for (PGPSecretKey dKey : saveParcel.deletedKeys) {
mKR = PGPSecretKeyRing.removeSecretKey(mKR, dKey);
}
@@ -406,7 +404,9 @@ public class PgpKeyOperation {
}
int user_id_index = 0;
+ boolean anyIDChanged = false;
if (saveParcel.primaryIDChanged) {
+ anyIDChanged = true;
ArrayList<Pair<String, PGPSignature>> sigList = new ArrayList<Pair<String, PGPSignature>>();
for (String userId : saveParcel.userIDs) {
String orig_id = saveParcel.originalIDs.get(user_id_index);
@@ -437,6 +437,7 @@ public class PgpKeyOperation {
for (String userId : saveParcel.userIDs) {
String orig_id = saveParcel.originalIDs.get(user_id_index);
if (!orig_id.equals(userId)) {
+ anyIDChanged = true;
PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder(
masterPublicKey.getAlgorithm(), HashAlgorithmTags.SHA1)
.setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME);
@@ -452,6 +453,12 @@ public class PgpKeyOperation {
}
}
+ //update the keyring with the new ID information
+ if (anyIDChanged) {
+ pKR = PGPPublicKeyRing.insertPublicKey(pKR, masterPublicKey);
+ mKR = PGPSecretKeyRing.replacePublicKeys(mKR, pKR);
+ }
+
PGPKeyPair masterKeyPair = new PGPKeyPair(masterPublicKey, masterPrivateKey);
PGPSignatureSubpacketGenerator hashedPacketsGen = new PGPSignatureSubpacketGenerator();