|
22 | 22 | import org.bouncycastle.bcpg.TrustPacket;
|
23 | 23 | import org.bouncycastle.bcpg.sig.IssuerFingerprint;
|
24 | 24 | import org.bouncycastle.bcpg.sig.IssuerKeyID;
|
| 25 | +import org.bouncycastle.bcpg.sig.RevocationReason; |
| 26 | +import org.bouncycastle.bcpg.sig.RevocationReasonTags; |
25 | 27 | import org.bouncycastle.math.ec.rfc8032.Ed25519;
|
26 | 28 | import org.bouncycastle.math.ec.rfc8032.Ed448;
|
27 | 29 | import org.bouncycastle.openpgp.operator.PGPContentVerifier;
|
@@ -897,6 +899,37 @@ public static boolean isCertification(int signatureType)
|
897 | 899 | || PGPSignature.POSITIVE_CERTIFICATION == signatureType;
|
898 | 900 | }
|
899 | 901 |
|
| 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 | + |
900 | 933 | /**
|
901 | 934 | * Return true, if the cryptographic signature encoding of the two signatures match.
|
902 | 935 | * @param sig1 first signature
|
|
0 commit comments