diff options
Diffstat (limited to 'OpenPGP-Keychain/src')
-rw-r--r-- | OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java | 13 |
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(); |