mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-01-05 10:38:05 -05:00
modifyKey: couple more fixes from tests
This commit is contained in:
parent
e477577c55
commit
f6e39b0a97
@ -339,12 +339,13 @@ public class PgpKeyOperation {
|
|||||||
// take care of that here.
|
// take care of that here.
|
||||||
PGPSignature cert = generateRevocationSignature(masterPrivateKey,
|
PGPSignature cert = generateRevocationSignature(masterPrivateKey,
|
||||||
masterPublicKey, userId);
|
masterPublicKey, userId);
|
||||||
modifiedPublicKey = PGPPublicKey.addCertification(masterPublicKey, userId, cert);
|
modifiedPublicKey = PGPPublicKey.addCertification(modifiedPublicKey, userId, cert);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. If primary user id changed, generate new certificates for both old and new
|
// 3. If primary user id changed, generate new certificates for both old and new
|
||||||
if (saveParcel.changePrimaryUserId != null) {
|
if (saveParcel.changePrimaryUserId != null) {
|
||||||
log.add(LogLevel.INFO, LogType.MSG_MF_UID_PRIMARY, indent);
|
log.add(LogLevel.INFO, LogType.MSG_MF_UID_PRIMARY, indent);
|
||||||
|
indent += 1;
|
||||||
|
|
||||||
// we work on the modifiedPublicKey here, to respect new or newly revoked uids
|
// we work on the modifiedPublicKey here, to respect new or newly revoked uids
|
||||||
// noinspection unchecked
|
// noinspection unchecked
|
||||||
@ -353,7 +354,7 @@ public class PgpKeyOperation {
|
|||||||
PGPSignature currentCert = null;
|
PGPSignature currentCert = null;
|
||||||
// noinspection unchecked
|
// noinspection unchecked
|
||||||
for (PGPSignature cert : new IterableIterator<PGPSignature>(
|
for (PGPSignature cert : new IterableIterator<PGPSignature>(
|
||||||
masterPublicKey.getSignaturesForID(userId))) {
|
modifiedPublicKey.getSignaturesForID(userId))) {
|
||||||
// if it's not a self cert, never mind
|
// if it's not a self cert, never mind
|
||||||
if (cert.getKeyID() != masterPublicKey.getKeyID()) {
|
if (cert.getKeyID() != masterPublicKey.getKeyID()) {
|
||||||
continue;
|
continue;
|
||||||
@ -397,10 +398,11 @@ public class PgpKeyOperation {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// otherwise, generate new non-primary certification
|
// otherwise, generate new non-primary certification
|
||||||
|
log.add(LogLevel.DEBUG, LogType.MSG_MF_PRIMARY_REPLACE_OLD, indent);
|
||||||
modifiedPublicKey = PGPPublicKey.removeCertification(
|
modifiedPublicKey = PGPPublicKey.removeCertification(
|
||||||
modifiedPublicKey, userId, currentCert);
|
modifiedPublicKey, userId, currentCert);
|
||||||
PGPSignature newCert = generateUserIdSignature(
|
PGPSignature newCert = generateUserIdSignature(
|
||||||
masterPrivateKey, masterPublicKey, userId, false);
|
masterPrivateKey, masterPublicKey, userId, false, masterKeyFlags);
|
||||||
modifiedPublicKey = PGPPublicKey.addCertification(
|
modifiedPublicKey = PGPPublicKey.addCertification(
|
||||||
modifiedPublicKey, userId, newCert);
|
modifiedPublicKey, userId, newCert);
|
||||||
continue;
|
continue;
|
||||||
@ -411,10 +413,11 @@ public class PgpKeyOperation {
|
|||||||
// if it should be
|
// if it should be
|
||||||
if (userId.equals(saveParcel.changePrimaryUserId)) {
|
if (userId.equals(saveParcel.changePrimaryUserId)) {
|
||||||
// add shiny new primary user id certificate
|
// add shiny new primary user id certificate
|
||||||
|
log.add(LogLevel.DEBUG, LogType.MSG_MF_PRIMARY_NEW, indent);
|
||||||
modifiedPublicKey = PGPPublicKey.removeCertification(
|
modifiedPublicKey = PGPPublicKey.removeCertification(
|
||||||
modifiedPublicKey, userId, currentCert);
|
modifiedPublicKey, userId, currentCert);
|
||||||
PGPSignature newCert = generateUserIdSignature(
|
PGPSignature newCert = generateUserIdSignature(
|
||||||
masterPrivateKey, masterPublicKey, userId, true);
|
masterPrivateKey, masterPublicKey, userId, true, masterKeyFlags);
|
||||||
modifiedPublicKey = PGPPublicKey.addCertification(
|
modifiedPublicKey = PGPPublicKey.addCertification(
|
||||||
modifiedPublicKey, userId, newCert);
|
modifiedPublicKey, userId, newCert);
|
||||||
}
|
}
|
||||||
@ -423,6 +426,7 @@ public class PgpKeyOperation {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
indent -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the secret key ring
|
// Update the secret key ring
|
||||||
|
@ -15,6 +15,7 @@ import org.sufficientlysecure.keychain.util.Log;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.security.SignatureException;
|
import java.security.SignatureException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/** OpenKeychain wrapper around PGPSignature objects.
|
/** OpenKeychain wrapper around PGPSignature objects.
|
||||||
@ -55,6 +56,31 @@ public class WrappedSignature {
|
|||||||
return mSig.getCreationTime();
|
return mSig.getCreationTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<WrappedSignature> getEmbeddedSignatures() {
|
||||||
|
ArrayList<WrappedSignature> sigs = new ArrayList<WrappedSignature>();
|
||||||
|
if (!mSig.hasSubpackets()) {
|
||||||
|
return sigs;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
PGPSignatureList list;
|
||||||
|
list = mSig.getHashedSubPackets().getEmbeddedSignatures();
|
||||||
|
for(int i = 0; i < list.size(); i++) {
|
||||||
|
sigs.add(new WrappedSignature(list.get(i)));
|
||||||
|
}
|
||||||
|
list = mSig.getUnhashedSubPackets().getEmbeddedSignatures();
|
||||||
|
for(int i = 0; i < list.size(); i++) {
|
||||||
|
sigs.add(new WrappedSignature(list.get(i)));
|
||||||
|
}
|
||||||
|
} catch (PGPException e) {
|
||||||
|
// no matter
|
||||||
|
Log.e(Constants.TAG, "exception reading embedded signatures", e);
|
||||||
|
} catch (IOException e) {
|
||||||
|
// no matter
|
||||||
|
Log.e(Constants.TAG, "exception reading embedded signatures", e);
|
||||||
|
}
|
||||||
|
return sigs;
|
||||||
|
}
|
||||||
|
|
||||||
public byte[] getEncoded() throws IOException {
|
public byte[] getEncoded() throws IOException {
|
||||||
return mSig.getEncoded();
|
return mSig.getEncoded();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user