aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain
diff options
context:
space:
mode:
authorAshley Hughes <spirit.returned@gmail.com>2014-01-31 11:44:10 +0000
committerAshley Hughes <spirit.returned@gmail.com>2014-01-31 11:44:10 +0000
commit617f117e23765bf0b6d113d40e9c0f323d39a8cf (patch)
tree47fa10d3c0f717b92c62dcd98c58e4e79ecb738f /OpenPGP-Keychain
parentfa0bd5edb4411ff227f49038ab597e84c938a7a9 (diff)
downloadopen-keychain-617f117e23765bf0b6d113d40e9c0f323d39a8cf.tar.gz
open-keychain-617f117e23765bf0b6d113d40e9c0f323d39a8cf.tar.bz2
open-keychain-617f117e23765bf0b6d113d40e9c0f323d39a8cf.zip
generate single key
Diffstat (limited to 'OpenPGP-Keychain')
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java2
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java28
2 files changed, 9 insertions, 21 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 85c3ed9d2..9782d1ac2 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
@@ -116,6 +116,8 @@ public class PgpKeyOperation {
* @throws PgpGeneralException
* @throws InvalidAlgorithmParameterException
*/
+
+ // TODO: key flags?
public PGPSecretKey createKey(int algorithmChoice, int keySize, String passPhrase,
boolean isMasterKey) throws NoSuchAlgorithmException, PGPException, NoSuchProviderException,
PgpGeneralException, InvalidAlgorithmParameterException {
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 1f9605fb1..4c8a50c90 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
@@ -290,18 +290,19 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
// fill values for this action
Bundle data = new Bundle();
+ Boolean isMasterKey;
String passPhrase;
if (mEditors.getChildCount() > 0) {
PGPSecretKey masterKey = ((KeyEditor) mEditors.getChildAt(0)).getValue();
passPhrase = PassphraseCacheService
.getCachedPassphrase(mActivity, masterKey.getKeyID());
-
- data.putByteArray(KeychainIntentService.GENERATE_KEY_MASTER_KEY,
- PgpConversionHelper.PGPSecretKeyToBytes(masterKey));
+ isMasterKey = true;
} else {
passPhrase = "";
+ isMasterKey = false;
}
+ data.putBoolean(KeychainIntentService.GENERATE_KEY_MASTER_KEY, isMasterKey);
data.putString(KeychainIntentService.GENERATE_KEY_SYMMETRIC_PASSPHRASE, passPhrase);
data.putInt(KeychainIntentService.GENERATE_KEY_ALGORITHM, mNewKeyAlgorithmChoice.getId());
data.putInt(KeychainIntentService.GENERATE_KEY_KEY_SIZE, mNewKeySize);
@@ -322,30 +323,15 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
// get new key from data bundle returned from service
Bundle data = message.getData();
- PGPSecretKeyRing newKeyRing = (PGPSecretKeyRing) PgpConversionHelper
- .BytesToPGPKeyRing(data
+ PGPSecretKey newKey = (PGPSecretKey) PgpConversionHelper
+ .BytesToPGPKey(data
.getByteArray(KeychainIntentService.RESULT_NEW_KEY));
- boolean isMasterKey = (mEditors.getChildCount() == 0);
-
- // take only the key from this ring
- PGPSecretKey newKey = null;
- @SuppressWarnings("unchecked")
- Iterator<PGPSecretKey> it = newKeyRing.getSecretKeys();
-
- if (isMasterKey) {
- newKey = it.next();
- } else {
- // first one is the master key
- it.next();
- newKey = it.next();
- }
-
// add view with new key
KeyEditor view = (KeyEditor) mInflater.inflate(R.layout.edit_key_key_item,
mEditors, false);
view.setEditorListener(SectionView.this);
- view.setValue(newKey, isMasterKey, -1);
+ view.setValue(newKey, newKey.isMasterKey(), -1);
mEditors.addView(view);
SectionView.this.updateEditorsVisible();
}