mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 11:12:15 -05:00
move stuff around, save work
This commit is contained in:
parent
fdb013a052
commit
fcc7117770
@ -497,38 +497,21 @@ public class PgpKeyOperation {
|
|||||||
for (int i = 0; i < saveParcel.keys.size(); ++i) {
|
for (int i = 0; i < saveParcel.keys.size(); ++i) {
|
||||||
updateProgress(40 + 50 * (i - 1) / (saveParcel.keys.size() - 1), 100);
|
updateProgress(40 + 50 * (i - 1) / (saveParcel.keys.size() - 1), 100);
|
||||||
if (saveParcel.moddedKeys[i]) {
|
if (saveParcel.moddedKeys[i]) {
|
||||||
//secretkey.replacepublickey with updated public key
|
//to make public key, use a keygen and temp.publickeyring?
|
||||||
//secretkeyring.insertsecretkey with newly signed secret key
|
|
||||||
} else {
|
|
||||||
//else nothing, right?
|
|
||||||
}
|
|
||||||
if (saveParcel.newKeys[i]) {
|
|
||||||
//set the passphrase to the old one, so we can update the whole keyring passphrase later
|
|
||||||
PBESecretKeyEncryptor keyEncryptorOld = new JcePBESecretKeyEncryptorBuilder(
|
|
||||||
PGPEncryptedData.CAST5, sha1Calc)
|
|
||||||
.setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(
|
|
||||||
saveParcel.oldPassPhrase.toCharArray());
|
|
||||||
PBESecretKeyDecryptor keyDecryptorBlank = new JcePBESecretKeyDecryptorBuilder()
|
|
||||||
.setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(
|
|
||||||
saveParcel.oldPassPhrase.toCharArray());
|
|
||||||
saveParcel.keys.set(i, PGPSecretKey.copyWithNewPassword(saveParcel.keys.get(i),
|
|
||||||
keyDecryptorBlank, keyEncryptorOld));
|
|
||||||
}
|
|
||||||
//finally, update the keyrings
|
|
||||||
mKR = PGPSecretKeyRing.insertSecretKey(mKR, saveParcel.keys.get(i));
|
|
||||||
pKR = PGPPublicKeyRing.insertPublicKey(pKR, saveParcel.keys.get(i).getPublicKey());
|
|
||||||
}
|
|
||||||
updateProgress(R.string.progress_adding_sub_keys, 40, 100);
|
|
||||||
|
|
||||||
for (int i = 1; i < saveParcel.keys.size(); ++i) {
|
|
||||||
updateProgress(40 + 50 * (i - 1) / (saveParcel.keys.size() - 1), 100);
|
|
||||||
|
|
||||||
PGPSecretKey subKey = saveParcel.keys.get(i);
|
PGPSecretKey subKey = saveParcel.keys.get(i);
|
||||||
PGPPublicKey subPublicKey = subKey.getPublicKey();
|
PGPPublicKey subPublicKey = subKey.getPublicKey();
|
||||||
|
|
||||||
PBESecretKeyDecryptor keyDecryptor2 = new JcePBESecretKeyDecryptorBuilder()
|
PBESecretKeyDecryptor keyDecryptor2;
|
||||||
|
if (saveParcel.newKeys[i]) {
|
||||||
|
keyDecryptor2 = new JcePBESecretKeyDecryptorBuilder()
|
||||||
|
.setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(
|
||||||
|
"".toCharArray());
|
||||||
|
} else {
|
||||||
|
keyDecryptor2 = new JcePBESecretKeyDecryptorBuilder()
|
||||||
.setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(
|
.setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(
|
||||||
saveParcel.oldPassPhrase.toCharArray());
|
saveParcel.oldPassPhrase.toCharArray());
|
||||||
|
}
|
||||||
PGPPrivateKey subPrivateKey = subKey.extractPrivateKey(keyDecryptor2);
|
PGPPrivateKey subPrivateKey = subKey.extractPrivateKey(keyDecryptor2);
|
||||||
|
|
||||||
// TODO: now used without algorithm and creation time?! (APG 1)
|
// TODO: now used without algorithm and creation time?! (APG 1)
|
||||||
@ -573,7 +556,26 @@ public class PgpKeyOperation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
keyGen.addSubKey(subKeyPair, hashedPacketsGen.generate(), unhashedPacketsGen.generate());
|
keyGen.addSubKey(subKeyPair, hashedPacketsGen.generate(), unhashedPacketsGen.generate());
|
||||||
|
//discard only certain certs
|
||||||
|
//secretkey.replacepublickey with updated public key
|
||||||
}
|
}
|
||||||
|
if (saveParcel.newKeys[i]) { //might not be necessary
|
||||||
|
//set the passphrase to the old one, so we can update the whole keyring passphrase later
|
||||||
|
PBESecretKeyEncryptor keyEncryptorOld = new JcePBESecretKeyEncryptorBuilder(
|
||||||
|
PGPEncryptedData.CAST5, sha1Calc)
|
||||||
|
.setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(
|
||||||
|
saveParcel.oldPassPhrase.toCharArray());
|
||||||
|
PBESecretKeyDecryptor keyDecryptorBlank = new JcePBESecretKeyDecryptorBuilder()
|
||||||
|
.setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(
|
||||||
|
saveParcel.oldPassPhrase.toCharArray());
|
||||||
|
saveParcel.keys.set(i, PGPSecretKey.copyWithNewPassword(saveParcel.keys.get(i),
|
||||||
|
keyDecryptorBlank, keyEncryptorOld));
|
||||||
|
}
|
||||||
|
//finally, update the keyrings
|
||||||
|
mKR = PGPSecretKeyRing.insertSecretKey(mKR, saveParcel.keys.get(i));
|
||||||
|
pKR = PGPPublicKeyRing.insertPublicKey(pKR, saveParcel.keys.get(i).getPublicKey());
|
||||||
|
}
|
||||||
|
updateProgress(R.string.progress_adding_sub_keys, 40, 100);
|
||||||
|
|
||||||
//update the passphrase
|
//update the passphrase
|
||||||
mKR = PGPSecretKeyRing.copyWithNewPassword(mKR, keyDecryptor, keyEncryptor);
|
mKR = PGPSecretKeyRing.copyWithNewPassword(mKR, keyDecryptor, keyEncryptor);
|
||||||
|
Loading…
Reference in New Issue
Block a user