uncomment, use Parcel. Builds, not functional

This commit is contained in:
Ashley Hughes 2014-03-07 15:36:01 +00:00
parent fba0e2af1d
commit b06e4d827a

View File

@ -383,33 +383,32 @@ public class PgpKeyOperation {
do we need to remove and add in?
*/
/*
for (PGPSecretKey dKey : deleted_keys) {
for (PGPSecretKey dKey : saveParcel.deletedKeys) {
mKR = PGPSecretKeyRing.removeSecretKey(mKR, dKey);
}
masterKey = mKR.getSecretKey();
PGPPublicKey masterPublicKey = masterKey.getPublicKey();
int usageId = keysUsages.get(0);
int usageId = saveParcel.keysUsages.get(0);
boolean canSign;
String mainUserId = userIds.get(0);
String mainUserId = saveParcel.userIDs.get(0);
PBESecretKeyDecryptor keyDecryptor = new JcePBESecretKeyDecryptorBuilder().setProvider(
Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(oldPassPhrase.toCharArray());
Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(saveParcel.oldPassPhrase.toCharArray());
PGPPrivateKey masterPrivateKey = masterKey.extractPrivateKey(keyDecryptor);
updateProgress(R.string.progress_certifying_master_key, 20, 100);
for (String delID : deletedIDs) {
for (String delID : saveParcel.deletedIDs) {
masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, delID);
}
int user_id_index = 0;
if (primaryIDChanged) {
if (saveParcel.primaryIDChanged) {
ArrayList<Pair<String, PGPSignature>> sigList = new ArrayList<Pair<String, PGPSignature>>();
for (String userId : userIds) {
String orig_id = OriginalIDs.get(user_id_index);
for (String userId : saveParcel.userIDs) {
String orig_id = saveParcel.originalIDs.get(user_id_index);
if (orig_id.equals(userId)) {
Iterator<PGPSignature> orig_sigs = masterPublicKey.getSignaturesForID(orig_id); //TODO: make sure this iterator only has signatures we are interested in
while (orig_sigs.hasNext()) {
@ -434,8 +433,8 @@ public class PgpKeyOperation {
masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, to_add.first, to_add.second);
}
} else {
for (String userId : userIds) {
String orig_id = OriginalIDs.get(user_id_index);
for (String userId : saveParcel.userIDs) {
String orig_id = saveParcel.originalIDs.get(user_id_index);
if (!orig_id.equals(userId)) {
PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder(
masterPublicKey.getAlgorithm(), HashAlgorithmTags.SHA1)
@ -463,10 +462,10 @@ public class PgpKeyOperation {
hashedPacketsGen.setPreferredHashAlgorithms(true, PREFERRED_HASH_ALGORITHMS);
hashedPacketsGen.setPreferredCompressionAlgorithms(true, PREFERRED_COMPRESSION_ALGORITHMS);
if (keysExpiryDates.get(0) != null) {
if (saveParcel.keysExpiryDates.get(0) != null) {
GregorianCalendar creationDate = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
creationDate.setTime(masterPublicKey.getCreationTime());
GregorianCalendar expiryDate = keysExpiryDates.get(0);
GregorianCalendar expiryDate = saveParcel.keysExpiryDates.get(0);
//note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c
//here we purposefully ignore partial days in each date - long type has no fractional part!
long numDays = (expiryDate.getTimeInMillis() / 86400000) - (creationDate.getTimeInMillis() / 86400000);
@ -490,15 +489,15 @@ public class PgpKeyOperation {
PBESecretKeyEncryptor keyEncryptor = new JcePBESecretKeyEncryptorBuilder(
PGPEncryptedData.CAST5, sha1Calc)
.setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(
newPassPhrase.toCharArray());
saveParcel.newPassPhrase.toCharArray());
PGPKeyRingGenerator keyGen = new PGPKeyRingGenerator(PGPSignature.POSITIVE_CERTIFICATION,
masterKeyPair, mainUserId, sha1Calc, hashedPacketsGen.generate(),
unhashedPacketsGen.generate(), certificationSignerBuilder, keyEncryptor);
for (int i = 0; i < keys.size(); ++i) {
updateProgress(40 + 50 * (i - 1) / (keys.size() - 1), 100);
if (new_keys[i]) {
for (int i = 0; i < saveParcel.keys.size(); ++i) {
updateProgress(40 + 50 * (i - 1) / (saveParcel.keys.size() - 1), 100);
if (saveParcel.newKeys[i]) {
} else {
@ -506,15 +505,15 @@ public class PgpKeyOperation {
}
updateProgress(R.string.progress_adding_sub_keys, 40, 100);
for (int i = 1; i < keys.size(); ++i) {
updateProgress(40 + 50 * (i - 1) / (keys.size() - 1), 100);
for (int i = 1; i < saveParcel.keys.size(); ++i) {
updateProgress(40 + 50 * (i - 1) / (saveParcel.keys.size() - 1), 100);
PGPSecretKey subKey = keys.get(i);
PGPSecretKey subKey = saveParcel.keys.get(i);
PGPPublicKey subPublicKey = subKey.getPublicKey();
PBESecretKeyDecryptor keyDecryptor2 = new JcePBESecretKeyDecryptorBuilder()
.setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(
oldPassPhrase.toCharArray());
saveParcel.oldPassPhrase.toCharArray());
PGPPrivateKey subPrivateKey = subKey.extractPrivateKey(keyDecryptor2);
// TODO: now used without algorithm and creation time?! (APG 1)
@ -523,7 +522,7 @@ public class PgpKeyOperation {
hashedPacketsGen = new PGPSignatureSubpacketGenerator();
unhashedPacketsGen = new PGPSignatureSubpacketGenerator();
usageId = keysUsages.get(i);
usageId = saveParcel.keysUsages.get(i);
canSign = (usageId & KeyFlags.SIGN_DATA) > 0; //todo - separate function for this
if (canSign) {
Date todayDate = new Date(); //both sig times the same
@ -543,10 +542,10 @@ public class PgpKeyOperation {
}
hashedPacketsGen.setKeyFlags(false, usageId);
if (keysExpiryDates.get(i) != null) {
if (saveParcel.keysExpiryDates.get(i) != null) {
GregorianCalendar creationDate = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
creationDate.setTime(subPublicKey.getCreationTime());
GregorianCalendar expiryDate = keysExpiryDates.get(i);
GregorianCalendar expiryDate = saveParcel.keysExpiryDates.get(i);
//note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c
//here we purposefully ignore partial days in each date - long type has no fractional part!
long numDays = (expiryDate.getTimeInMillis() / 86400000) - (creationDate.getTimeInMillis() / 86400000);
@ -570,7 +569,6 @@ public class PgpKeyOperation {
ProviderHelper.saveKeyRing(mContext, publicKeyRing);
updateProgress(R.string.progress_done, 100, 100);
*/
}
public PGPPublicKeyRing certifyKey(long masterKeyId, long pubKeyId, String passphrase)