aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpConversionHelper.java
diff options
context:
space:
mode:
authorAshley Hughes <spirit.returned@gmail.com>2014-02-01 17:01:03 +0000
committerAshley Hughes <spirit.returned@gmail.com>2014-02-01 17:01:03 +0000
commitaf5e01db8e847e0f77cfcf53daf2dd4b241aaee3 (patch)
treeaa9d21b44e30309cca1fac3f5edcf8c43fb76670 /OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpConversionHelper.java
parentb87f0b2658c471a5c4186f9c874ad52b070b5f1d (diff)
parent3f0f3cca6afa65dba4ff5868e5112cce39e2dc94 (diff)
downloadopen-keychain-af5e01db8e847e0f77cfcf53daf2dd4b241aaee3.tar.gz
open-keychain-af5e01db8e847e0f77cfcf53daf2dd4b241aaee3.tar.bz2
open-keychain-af5e01db8e847e0f77cfcf53daf2dd4b241aaee3.zip
create new keys without lots of extra certification
Diffstat (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpConversionHelper.java')
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpConversionHelper.java22
1 files changed, 20 insertions, 2 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;
}
/**