From fa533dda325b5d56db16dee2f84152ec4807a2b2 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Sat, 22 Feb 2014 16:08:38 +0000 Subject: pass through which keys are new --- .../org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java | 9 +++++++-- .../keychain/service/KeychainIntentService.java | 4 +++- .../org/sufficientlysecure/keychain/ui/EditKeyActivity.java | 2 ++ .../org/sufficientlysecure/keychain/ui/widget/KeyEditor.java | 5 +++++ .../sufficientlysecure/keychain/ui/widget/SectionView.java | 12 ++++++++++++ 5 files changed, 29 insertions(+), 3 deletions(-) (limited to 'OpenPGP-Keychain/src/main/java/org') 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 ab4408056..a6ff60442 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 @@ -345,7 +345,7 @@ public class PgpKeyOperation { updateProgress(R.string.progress_done, 100, 100); } - public void buildSecretKey(ArrayList userIds, ArrayList OriginalIDs, ArrayList deletedIDs, boolean primaryIDChanged, boolean[] modded_keys, ArrayList deleted_keys, ArrayList keysExpiryDates, ArrayList keysUsages, String newPassPhrase, String oldPassPhrase, ArrayList keys) throws PgpGeneralException, + public void buildSecretKey(ArrayList userIds, ArrayList OriginalIDs, ArrayList deletedIDs, boolean primaryIDChanged, boolean[] modded_keys, ArrayList deleted_keys, ArrayList keysExpiryDates, ArrayList keysUsages, String newPassPhrase, String oldPassPhrase, boolean[] new_keys, ArrayList keys) throws PgpGeneralException, PGPException, SignatureException, IOException { updateProgress(R.string.progress_building_key, 0, 100); @@ -490,6 +490,11 @@ public class PgpKeyOperation { masterKeyPair, mainUserId, sha1Calc, hashedPacketsGen.generate(), unhashedPacketsGen.generate(), certificationSignerBuilder, keyEncryptor); + //updating master is slightly different to updating the others + if (modded_keys[0]) { + + } + updateProgress(R.string.progress_adding_sub_keys, 40, 100); for (int i = 1; i < keys.size(); ++i) { @@ -549,7 +554,7 @@ public class PgpKeyOperation { PGPSecretKeyRing secretKeyRing = keyGen.generateSecretKeyRing(); PGPPublicKeyRing publicKeyRing = keyGen.generatePublicKeyRing(); - +//must copy with new passphrase... new keys will have an empty passphrase... pass in boolean array to mark new key? updateProgress(R.string.progress_saving_key_ring, 90, 100); ProviderHelper.saveKeyRing(mContext, secretKeyRing); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 73de7ca6e..3610ddc9e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -138,6 +138,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial public static final String SAVE_KEYRING_DELETED_IDS = "deleted_ids"; public static final String SAVE_KEYRING_MODDED_KEYS = "modified_keys"; public static final String SAVE_KEYRING_DELETED_KEYS = "deleted_keys"; + public static final String SAVE_KEYRING_NEW_KEYS = "new_keys"; // generate key public static final String GENERATE_KEY_ALGORITHM = "algorithm"; @@ -548,6 +549,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial ArrayList original_ids = data.getStringArrayList(SAVE_KEYRING_ORIGINAL_IDS); ArrayList deleted_ids = data.getStringArrayList(SAVE_KEYRING_DELETED_IDS); boolean[] modded_keys = data.getBooleanArray(SAVE_KEYRING_MODDED_KEYS); + boolean[] new_keys = data.getBooleanArray(SAVE_KEYRING_NEW_KEYS); ArrayList deletedKeys = PgpConversionHelper.BytesToPGPSecretKeyList(data .getByteArray(SAVE_KEYRING_DELETED_KEYS)); boolean primaryChanged = data.getBoolean(SAVE_KEYRING_PRIMARY_ID_CHANGED); @@ -563,7 +565,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial } else { keyOperations.buildSecretKey(userIds, original_ids, deleted_ids, primaryChanged, modded_keys, deletedKeys, keysExpiryDates, keysUsages, newPassPhrase, - oldPassPhrase, keys); + oldPassPhrase, new_keys, keys); } PassphraseCacheService.addCachedPassphrase(this, masterKeyId, newPassPhrase); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 09be0dc79..bb38ac979 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -597,6 +597,8 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener toPrimitiveArray(mKeysView.getNeedsSavingArray())); data.putBoolean(KeychainIntentService.SAVE_KEYRING_PRIMARY_ID_CHANGED, mUserIdsView.primaryChanged()); + data.putBooleanArray(KeychainIntentService.SAVE_KEYRING_NEW_KEYS, + toPrimitiveArray(mKeysView.getNewKeysArray())); intent.putExtra(KeychainIntentService.EXTRA_DATA, data); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java index 5ce5d89d7..68bfc573e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java @@ -314,4 +314,9 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { return retval; } + public boolean getIsNewKey() + { + return mIsNewKey; + } + } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java index 014a891a5..93c10a2b0 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -223,6 +223,18 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor return mList; } + public List getNewKeysArray() + { + ArrayList mList = new ArrayList(); + if (mType == Id.type.key) { + for (int i = 0; i < mEditors.getChildCount(); ++i) { + KeyEditor editor = (KeyEditor) mEditors.getChildAt(i); + mList.add(editor.getIsNewKey()); + } + } + return mList; + } + /** {@inheritDoc} */ public void onClick(View v) { if (canEdit) { -- cgit v1.2.3