diff options
author | Ashley Hughes <spirit.returned@gmail.com> | 2014-01-31 15:19:59 +0000 |
---|---|---|
committer | Ashley Hughes <spirit.returned@gmail.com> | 2014-01-31 15:19:59 +0000 |
commit | de6a515ca51ab04f9c62b80a952d4e4ed00cce5b (patch) | |
tree | ee4fb054fa03f3477ee22815a6b732a8a572d4ce /OpenPGP-Keychain/src/main/java/org | |
parent | 7897c6fadd2a285f8b2b52f56b71741a44f13f03 (diff) | |
download | open-keychain-de6a515ca51ab04f9c62b80a952d4e4ed00cce5b.tar.gz open-keychain-de6a515ca51ab04f9c62b80a952d4e4ed00cce5b.tar.bz2 open-keychain-de6a515ca51ab04f9c62b80a952d4e4ed00cce5b.zip |
create keys with minimal keyrings being constructed in between
Diffstat (limited to 'OpenPGP-Keychain/src/main/java/org')
3 files changed, 25 insertions, 8 deletions
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpConversionHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpConversionHelper.java index e406a142e..20d446824 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpConversionHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpConversionHelper.java @@ -80,9 +80,27 @@ public class PgpConversionHelper { * @return */ public static PGPSecretKey BytesToPGPSecretKey(byte[] keyBytes) { - PGPSecretKey key = BytesToPGPSecretKeyList(keyBytes).get(0); + PGPObjectFactory factory = new PGPObjectFactory(keyBytes); + Object obj = null; + try { + obj = factory.nextObject(); + } catch (IOException e) { + Log.e(Constants.TAG, "Error while converting to PGPSecretKey!", e); + } + PGPSecretKey secKey = null; + if(obj instanceof PGPSecretKey) { + if ((secKey = (PGPSecretKey)obj ) == null) { + Log.e(Constants.TAG, "No keys given!"); + } + } else if(obj instanceof PGPSecretKeyRing) { //master keys are sent as keyrings + PGPSecretKeyRing keyRing = null; + if ((keyRing = (PGPSecretKeyRing)obj) == null) { + Log.e(Constants.TAG, "No keys given!"); + } + secKey = keyRing.getSecretKey(); + } - return key; + return secKey; } /** 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 85c1177df..09334fe6d 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 @@ -193,19 +193,18 @@ public class EditKeyActivity extends SherlockFragmentActivity { if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { // get new key from data bundle returned from service Bundle data = message.getData(); - PGPSecretKeyRing masterKey = (PGPSecretKey) PgpConversionHelper - .BytesToPGPKey(data + PGPSecretKey masterKey = (PGPSecretKey) PgpConversionHelper + .BytesToPGPSecretKey(data .getByteArray(KeychainIntentService.RESULT_NEW_KEY)); PGPSecretKey subKey = (PGPSecretKey) PgpConversionHelper - .BytesToPGPKey(data + .BytesToPGPSecretKey(data .getByteArray(KeychainIntentService.RESULT_NEW_KEY2)); // add master key - mKeys.add(maskterKey); + mKeys.add(masterKey); mKeysUsages.add(Id.choice.usage.sign_only); //TODO: get from key flags // add sub key - subIt.next(); // masterkey mKeys.add(subKey); mKeysUsages.add(Id.choice.usage.encrypt_only); //TODO: get from key flags 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 4c8a50c90..83661d140 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 @@ -324,7 +324,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor // get new key from data bundle returned from service Bundle data = message.getData(); PGPSecretKey newKey = (PGPSecretKey) PgpConversionHelper - .BytesToPGPKey(data + .BytesToPGPSecretKey(data .getByteArray(KeychainIntentService.RESULT_NEW_KEY)); // add view with new key |