mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-26 00:48:51 -05:00
style changes
This commit is contained in:
parent
95eb33b2ed
commit
be007ecc56
@ -217,7 +217,7 @@ public class PgpKeyOperation {
|
|||||||
PGPPrivateKey masterPrivateKey = masterKey.extractPrivateKey(keyDecryptor);
|
PGPPrivateKey masterPrivateKey = masterKey.extractPrivateKey(keyDecryptor);
|
||||||
|
|
||||||
updateProgress(R.string.progress_certifying_master_key, 20, 100);
|
updateProgress(R.string.progress_certifying_master_key, 20, 100);
|
||||||
int user_id_index = 0;
|
|
||||||
for (String userId : userIds) {
|
for (String userId : userIds) {
|
||||||
PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder(
|
PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder(
|
||||||
masterPublicKey.getAlgorithm(), HashAlgorithmTags.SHA1)
|
masterPublicKey.getAlgorithm(), HashAlgorithmTags.SHA1)
|
||||||
@ -228,7 +228,6 @@ public class PgpKeyOperation {
|
|||||||
|
|
||||||
PGPSignature certification = sGen.generateCertification(userId, masterPublicKey);
|
PGPSignature certification = sGen.generateCertification(userId, masterPublicKey);
|
||||||
masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, userId, certification);
|
masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, userId, certification);
|
||||||
user_id_index++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PGPKeyPair masterKeyPair = new PGPKeyPair(masterPublicKey, masterPrivateKey);
|
PGPKeyPair masterKeyPair = new PGPKeyPair(masterPublicKey, masterPrivateKey);
|
||||||
@ -412,7 +411,7 @@ public class PgpKeyOperation {
|
|||||||
masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, delID);
|
masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, delID);
|
||||||
}
|
}
|
||||||
|
|
||||||
int user_id_index = 0;
|
int userIDIndex = 0;
|
||||||
|
|
||||||
PGPSignatureSubpacketGenerator hashedPacketsGen = new PGPSignatureSubpacketGenerator();
|
PGPSignatureSubpacketGenerator hashedPacketsGen = new PGPSignatureSubpacketGenerator();
|
||||||
PGPSignatureSubpacketGenerator unhashedPacketsGen = new PGPSignatureSubpacketGenerator();
|
PGPSignatureSubpacketGenerator unhashedPacketsGen = new PGPSignatureSubpacketGenerator();
|
||||||
@ -442,12 +441,12 @@ public class PgpKeyOperation {
|
|||||||
anyIDChanged = true;
|
anyIDChanged = true;
|
||||||
ArrayList<Pair<String, PGPSignature>> sigList = new ArrayList<Pair<String, PGPSignature>>();
|
ArrayList<Pair<String, PGPSignature>> sigList = new ArrayList<Pair<String, PGPSignature>>();
|
||||||
for (String userId : saveParcel.userIDs) {
|
for (String userId : saveParcel.userIDs) {
|
||||||
String orig_id = saveParcel.originalIDs.get(user_id_index);
|
String origID = saveParcel.originalIDs.get(userIDIndex);
|
||||||
if (orig_id.equals(userId) && !userId.equals(saveParcel.originalPrimaryID) && user_id_index != 0) {
|
if (origID.equals(userId) && !userId.equals(saveParcel.originalPrimaryID) && userIDIndex != 0) {
|
||||||
Iterator<PGPSignature> orig_sigs = masterPublicKey.getSignaturesForID(orig_id); //TODO: make sure this iterator only has signatures we are interested in
|
Iterator<PGPSignature> origSigs = masterPublicKey.getSignaturesForID(origID); //TODO: make sure this iterator only has signatures we are interested in
|
||||||
while (orig_sigs.hasNext()) {
|
while (origSigs.hasNext()) {
|
||||||
PGPSignature orig_sig = orig_sigs.next();
|
PGPSignature origSig = origSigs.next();
|
||||||
sigList.add(new Pair<String, PGPSignature>(orig_id, orig_sig));
|
sigList.add(new Pair<String, PGPSignature>(origID, origSig));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder(
|
PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder(
|
||||||
@ -456,25 +455,25 @@ public class PgpKeyOperation {
|
|||||||
PGPSignatureGenerator sGen = new PGPSignatureGenerator(signerBuilder);
|
PGPSignatureGenerator sGen = new PGPSignatureGenerator(signerBuilder);
|
||||||
|
|
||||||
sGen.init(PGPSignature.POSITIVE_CERTIFICATION, masterPrivateKey);
|
sGen.init(PGPSignature.POSITIVE_CERTIFICATION, masterPrivateKey);
|
||||||
if (user_id_index == 0) {
|
if (userIDIndex == 0) {
|
||||||
sGen.setHashedSubpackets(hashedPacketsGen.generate());
|
sGen.setHashedSubpackets(hashedPacketsGen.generate());
|
||||||
sGen.setUnhashedSubpackets(unhashedPacketsGen.generate());
|
sGen.setUnhashedSubpackets(unhashedPacketsGen.generate());
|
||||||
}
|
}
|
||||||
PGPSignature certification = sGen.generateCertification(userId, masterPublicKey);
|
PGPSignature certification = sGen.generateCertification(userId, masterPublicKey);
|
||||||
sigList.add(new Pair<String, PGPSignature>(userId, certification));
|
sigList.add(new Pair<String, PGPSignature>(userId, certification));
|
||||||
}
|
}
|
||||||
if (!orig_id.equals("")) {
|
if (!origID.equals("")) {
|
||||||
masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, orig_id);
|
masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, origID);
|
||||||
}
|
}
|
||||||
user_id_index++;
|
userIDIndex++;
|
||||||
}
|
}
|
||||||
for (Pair<String, PGPSignature> to_add : sigList) {
|
for (Pair<String, PGPSignature> toAdd : sigList) {
|
||||||
masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, to_add.first, to_add.second);
|
masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, toAdd.first, toAdd.second);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (String userId : saveParcel.userIDs) {
|
for (String userId : saveParcel.userIDs) {
|
||||||
String orig_id = saveParcel.originalIDs.get(user_id_index);
|
String origID = saveParcel.originalIDs.get(userIDIndex);
|
||||||
if (!orig_id.equals(userId)) {
|
if (!origID.equals(userId)) {
|
||||||
anyIDChanged = true;
|
anyIDChanged = true;
|
||||||
PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder(
|
PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder(
|
||||||
masterPublicKey.getAlgorithm(), HashAlgorithmTags.SHA1)
|
masterPublicKey.getAlgorithm(), HashAlgorithmTags.SHA1)
|
||||||
@ -482,26 +481,26 @@ public class PgpKeyOperation {
|
|||||||
PGPSignatureGenerator sGen = new PGPSignatureGenerator(signerBuilder);
|
PGPSignatureGenerator sGen = new PGPSignatureGenerator(signerBuilder);
|
||||||
|
|
||||||
sGen.init(PGPSignature.POSITIVE_CERTIFICATION, masterPrivateKey);
|
sGen.init(PGPSignature.POSITIVE_CERTIFICATION, masterPrivateKey);
|
||||||
if (user_id_index == 0) {
|
if (userIDIndex == 0) {
|
||||||
sGen.setHashedSubpackets(hashedPacketsGen.generate());
|
sGen.setHashedSubpackets(hashedPacketsGen.generate());
|
||||||
sGen.setUnhashedSubpackets(unhashedPacketsGen.generate());
|
sGen.setUnhashedSubpackets(unhashedPacketsGen.generate());
|
||||||
}
|
}
|
||||||
PGPSignature certification = sGen.generateCertification(userId, masterPublicKey);
|
PGPSignature certification = sGen.generateCertification(userId, masterPublicKey);
|
||||||
if (!orig_id.equals("")) {
|
if (!origID.equals("")) {
|
||||||
masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, orig_id);
|
masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, origID);
|
||||||
}
|
}
|
||||||
masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, userId, certification);
|
masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, userId, certification);
|
||||||
}
|
}
|
||||||
user_id_index++;
|
userIDIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<Pair<String, PGPSignature>> sigList = new ArrayList<Pair<String, PGPSignature>>();
|
ArrayList<Pair<String, PGPSignature>> sigList = new ArrayList<Pair<String, PGPSignature>>();
|
||||||
if (saveParcel.moddedKeys[0]) {
|
if (saveParcel.moddedKeys[0]) {
|
||||||
user_id_index = 0;
|
userIDIndex = 0;
|
||||||
for (String userId : saveParcel.userIDs) {
|
for (String userId : saveParcel.userIDs) {
|
||||||
String orig_id = saveParcel.originalIDs.get(user_id_index);
|
String origID = saveParcel.originalIDs.get(userIDIndex);
|
||||||
if (!(orig_id.equals(saveParcel.originalPrimaryID) && !saveParcel.primaryIDChanged)) {
|
if (!(origID.equals(saveParcel.originalPrimaryID) && !saveParcel.primaryIDChanged)) {
|
||||||
Iterator<PGPSignature> sigs = masterPublicKey.getSignaturesForID(userId); //TODO: make sure this iterator only has signatures we are interested in
|
Iterator<PGPSignature> sigs = masterPublicKey.getSignaturesForID(userId); //TODO: make sure this iterator only has signatures we are interested in
|
||||||
while (sigs.hasNext()) {
|
while (sigs.hasNext()) {
|
||||||
PGPSignature sig = sigs.next();
|
PGPSignature sig = sigs.next();
|
||||||
@ -511,7 +510,7 @@ public class PgpKeyOperation {
|
|||||||
if (!userId.equals("")) {
|
if (!userId.equals("")) {
|
||||||
masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, userId);
|
masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, userId);
|
||||||
}
|
}
|
||||||
user_id_index++;
|
userIDIndex++;
|
||||||
}
|
}
|
||||||
anyIDChanged = true;
|
anyIDChanged = true;
|
||||||
}
|
}
|
||||||
@ -623,8 +622,8 @@ public class PgpKeyOperation {
|
|||||||
//replace lost IDs
|
//replace lost IDs
|
||||||
if (saveParcel.moddedKeys[0]) {
|
if (saveParcel.moddedKeys[0]) {
|
||||||
masterPublicKey = mKR.getPublicKey();
|
masterPublicKey = mKR.getPublicKey();
|
||||||
for (Pair<String, PGPSignature> to_add : sigList) {
|
for (Pair<String, PGPSignature> toAdd : sigList) {
|
||||||
masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, to_add.first, to_add.second);
|
masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, toAdd.first, toAdd.second);
|
||||||
}
|
}
|
||||||
pKR = PGPPublicKeyRing.insertPublicKey(pKR, masterPublicKey);
|
pKR = PGPPublicKeyRing.insertPublicKey(pKR, masterPublicKey);
|
||||||
mKR = PGPSecretKeyRing.replacePublicKeys(mKR, pKR);
|
mKR = PGPSecretKeyRing.replacePublicKeys(mKR, pKR);
|
||||||
|
Loading…
Reference in New Issue
Block a user