Skip to content

Commit b51a997

Browse files
committed
PGPSignature changes
1 parent 046e3ec commit b51a997

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

pg/src/main/java/org/bouncycastle/openpgp/PGPSignature.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import org.bouncycastle.bcpg.TrustPacket;
2323
import org.bouncycastle.bcpg.sig.IssuerFingerprint;
2424
import org.bouncycastle.bcpg.sig.IssuerKeyID;
25+
import org.bouncycastle.bcpg.sig.RevocationReason;
26+
import org.bouncycastle.bcpg.sig.RevocationReasonTags;
2527
import org.bouncycastle.math.ec.rfc8032.Ed25519;
2628
import org.bouncycastle.math.ec.rfc8032.Ed448;
2729
import org.bouncycastle.openpgp.operator.PGPContentVerifier;
@@ -897,6 +899,37 @@ public static boolean isCertification(int signatureType)
897899
|| PGPSignature.POSITIVE_CERTIFICATION == signatureType;
898900
}
899901

902+
public static boolean isRevocation(int signatureType)
903+
{
904+
return PGPSignature.KEY_REVOCATION == signatureType
905+
|| PGPSignature.CERTIFICATION_REVOCATION == signatureType
906+
|| PGPSignature.SUBKEY_REVOCATION == signatureType;
907+
}
908+
909+
public boolean isHardRevocation()
910+
{
911+
if (!isRevocation(getSignatureType()))
912+
{
913+
return false; // no revocation
914+
}
915+
916+
if (!hasSubpackets())
917+
{
918+
return true; // consider missing subpackets (and therefore missing reason) as hard revocation
919+
}
920+
921+
// only consider reasons from the hashed packet area
922+
RevocationReason reason = getHashedSubPackets() != null ?
923+
getHashedSubPackets().getRevocationReason() : null;
924+
if (reason == null)
925+
{
926+
return true; // missing reason packet is hard
927+
}
928+
929+
return reason.getRevocationReason() == RevocationReasonTags.NO_REASON // No reason is hard
930+
|| reason.getRevocationReason() == RevocationReasonTags.KEY_COMPROMISED; // key compromise is hard
931+
}
932+
900933
/**
901934
* Return true, if the cryptographic signature encoding of the two signatures match.
902935
* @param sig1 first signature

0 commit comments

Comments
 (0)