respect user id revocation signatures

Closes #836
This commit is contained in:
Vincent Breitmoser
2014-09-20 00:12:50 +02:00
parent 6536ca825b
commit 344bc1736d
4 changed files with 84 additions and 34 deletions

View File

@@ -20,6 +20,8 @@ package org.sufficientlysecure.keychain.pgp;
import org.spongycastle.bcpg.SignatureSubpacket;
import org.spongycastle.bcpg.SignatureSubpacketTags;
import org.spongycastle.bcpg.sig.Exportable;
import org.spongycastle.bcpg.sig.Revocable;
import org.spongycastle.bcpg.sig.RevocationReason;
import org.spongycastle.openpgp.PGPException;
import org.spongycastle.openpgp.PGPObjectFactory;
@@ -218,12 +220,23 @@ public class WrappedSignature {
return new WrappedSignature(signatures.get(0));
}
/** Returns true if this certificate is revocable in general. */
public boolean isRevokable () {
// If nothing is specified, the packet is considered revocable
if (mSig.getHashedSubPackets() == null
|| !mSig.getHashedSubPackets().hasSubpacket(SignatureSubpacketTags.REVOCABLE)) {
return true;
}
SignatureSubpacket p = mSig.getHashedSubPackets().getSubpacket(SignatureSubpacketTags.REVOCABLE);
return ((Revocable) p).isRevocable();
}
public boolean isLocal() {
if (mSig.getHashedSubPackets() == null
|| !mSig.getHashedSubPackets().hasSubpacket(SignatureSubpacketTags.EXPORTABLE)) {
return false;
}
SignatureSubpacket p = mSig.getHashedSubPackets().getSubpacket(SignatureSubpacketTags.EXPORTABLE);
return p.getData()[0] == 0;
return ((Exportable) p).isExportable();
}
}