use parcel to save keys, but saving existing keys is disabled, pending a rewrite...
This commit is contained in:
@@ -125,20 +125,9 @@ public class KeychainIntentService extends IntentService implements ProgressDial
|
||||
public static final String DECRYPT_ASSUME_SYMMETRIC = "assume_symmetric";
|
||||
|
||||
// save keyring
|
||||
public static final String SAVE_KEYRING_NEW_PASSPHRASE = "new_passphrase";
|
||||
public static final String SAVE_KEYRING_CURRENT_PASSPHRASE = "current_passphrase";
|
||||
public static final String SAVE_KEYRING_USER_IDS = "user_ids";
|
||||
public static final String SAVE_KEYRING_PRIMARY_ID_CHANGED = "primary_id_changed";
|
||||
public static final String SAVE_KEYRING_KEYS = "keys";
|
||||
public static final String SAVE_KEYRING_KEYS_USAGES = "keys_usages";
|
||||
public static final String SAVE_KEYRING_KEYS_EXPIRY_DATES = "keys_expiry_dates";
|
||||
public static final String SAVE_KEYRING_MASTER_KEY_ID = "master_key_id";
|
||||
public static final String SAVE_KEYRING_PARCEL = "save_parcel";
|
||||
public static final String SAVE_KEYRING_CAN_SIGN = "can_sign";
|
||||
public static final String SAVE_KEYRING_ORIGINAL_IDS = "original_ids";
|
||||
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";
|
||||
@@ -530,8 +519,9 @@ public class KeychainIntentService extends IntentService implements ProgressDial
|
||||
} else if (ACTION_SAVE_KEYRING.equals(action)) {
|
||||
try {
|
||||
/* Input */
|
||||
String oldPassPhrase = data.getString(SAVE_KEYRING_CURRENT_PASSPHRASE);
|
||||
String newPassPhrase = data.getString(SAVE_KEYRING_NEW_PASSPHRASE);
|
||||
SaveKeyringParcel saveParams = data.getParcelable(SAVE_KEYRING_PARCEL);
|
||||
String oldPassPhrase = saveParams.oldPassPhrase;
|
||||
String newPassPhrase = saveParams.newPassPhrase;
|
||||
boolean canSign = true;
|
||||
|
||||
if (data.containsKey(SAVE_KEYRING_CAN_SIGN)) {
|
||||
@@ -541,25 +531,8 @@ public class KeychainIntentService extends IntentService implements ProgressDial
|
||||
if (newPassPhrase == null) {
|
||||
newPassPhrase = oldPassPhrase;
|
||||
}
|
||||
ArrayList<String> userIds = data.getStringArrayList(SAVE_KEYRING_USER_IDS);
|
||||
ArrayList<PGPSecretKey> keys = PgpConversionHelper.BytesToPGPSecretKeyList(data
|
||||
.getByteArray(SAVE_KEYRING_KEYS));
|
||||
ArrayList<Integer> keysUsages = data.getIntegerArrayList(SAVE_KEYRING_KEYS_USAGES);
|
||||
ArrayList<GregorianCalendar> keysExpiryDates = (ArrayList<GregorianCalendar>) data.getSerializable(SAVE_KEYRING_KEYS_EXPIRY_DATES);
|
||||
ArrayList<String> original_ids = data.getStringArrayList(SAVE_KEYRING_ORIGINAL_IDS);
|
||||
ArrayList<String> 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);
|
||||
byte[] tmp = data.getByteArray(SAVE_KEYRING_DELETED_KEYS);
|
||||
ArrayList<PGPSecretKey> deletedKeys;
|
||||
if (tmp != null)
|
||||
deletedKeys = PgpConversionHelper.BytesToPGPSecretKeyList(data
|
||||
.getByteArray(SAVE_KEYRING_DELETED_KEYS));
|
||||
else
|
||||
deletedKeys = new ArrayList<PGPSecretKey>();
|
||||
boolean primaryChanged = data.getBoolean(SAVE_KEYRING_PRIMARY_ID_CHANGED);
|
||||
|
||||
long masterKeyId = data.getLong(SAVE_KEYRING_MASTER_KEY_ID);
|
||||
long masterKeyId = saveParams.keys.get(0).getKeyID();
|
||||
|
||||
PgpKeyOperation keyOperations = new PgpKeyOperation(this, this);
|
||||
/* Operation */
|
||||
@@ -568,9 +541,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial
|
||||
ProviderHelper.getPGPSecretKeyRingByKeyId(this, masterKeyId),
|
||||
oldPassPhrase, newPassPhrase);
|
||||
} else {
|
||||
keyOperations.buildSecretKey(userIds, original_ids, deleted_ids, primaryChanged,
|
||||
modded_keys, deletedKeys, keysExpiryDates, keysUsages, newPassPhrase,
|
||||
oldPassPhrase, new_keys, keys);
|
||||
keyOperations.buildSecretKey(saveParams);
|
||||
}
|
||||
PassphraseCacheService.addCachedPassphrase(this, masterKeyId, newPassPhrase);
|
||||
|
||||
|
||||
@@ -42,20 +42,25 @@ public class SaveKeyringParcel implements Parcelable {
|
||||
public boolean[] newKeys;
|
||||
public ArrayList<PGPSecretKey> keys;
|
||||
|
||||
public SaveKeyringParcel() {}
|
||||
|
||||
private SaveKeyringParcel(Parcel source)
|
||||
{
|
||||
byte[] tmpB;
|
||||
userIDs = (ArrayList<String>)source.readSerializable();
|
||||
originalIDs = (ArrayList<String>)source.readSerializable();
|
||||
deletedIDs = (ArrayList<String>)source.readSerializable();
|
||||
primaryIDChanged = source.readByte() != 0;
|
||||
source.readBooleanArray(moddedKeys);
|
||||
deletedKeys = PgpConversionHelper.BytesToPGPSecretKeyList(source.createByteArray());
|
||||
moddedKeys = source.createBooleanArray();
|
||||
byte[] tmp = source.createByteArray();
|
||||
if (tmp == null)
|
||||
deletedKeys = null;
|
||||
else
|
||||
deletedKeys = PgpConversionHelper.BytesToPGPSecretKeyList(tmp);
|
||||
keysExpiryDates = (ArrayList<GregorianCalendar>)source.readSerializable();
|
||||
keysUsages = source.readArrayList(Integer.class.getClassLoader());
|
||||
newPassPhrase = source.readString();
|
||||
oldPassPhrase = source.readString();
|
||||
source.readBooleanArray(newKeys);
|
||||
newKeys = source.createBooleanArray();
|
||||
keys = PgpConversionHelper.BytesToPGPSecretKeyList(source.createByteArray());
|
||||
}
|
||||
|
||||
@@ -67,7 +72,10 @@ public class SaveKeyringParcel implements Parcelable {
|
||||
destination.writeSerializable(deletedIDs);
|
||||
destination.writeByte((byte) (primaryIDChanged ? 1 : 0));
|
||||
destination.writeBooleanArray(moddedKeys);
|
||||
destination.writeByteArray(PgpConversionHelper.PGPSecretKeyArrayListToBytes(deletedKeys));
|
||||
byte[] tmp = null;
|
||||
if (deletedKeys.size() != 0)
|
||||
tmp = PgpConversionHelper.PGPSecretKeyArrayListToBytes(deletedKeys);
|
||||
destination.writeByteArray(tmp);
|
||||
destination.writeSerializable(keysExpiryDates);
|
||||
destination.writeList(keysUsages);
|
||||
destination.writeString(newPassPhrase);
|
||||
|
||||
Reference in New Issue
Block a user