mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-24 07:58:50 -05:00
create keys with minimal keyrings being constructed in between
This commit is contained in:
parent
7897c6fadd
commit
de6a515ca5
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user