|
23 | 23 | import org.bouncycastle.bcpg.TrustPacket;
|
24 | 24 | import org.bouncycastle.bcpg.sig.IssuerFingerprint;
|
25 | 25 | import org.bouncycastle.bcpg.sig.IssuerKeyID;
|
| 26 | +import org.bouncycastle.bcpg.sig.RevocationReason; |
| 27 | +import org.bouncycastle.bcpg.sig.RevocationReasonTags; |
26 | 28 | import org.bouncycastle.math.ec.rfc8032.Ed25519;
|
27 | 29 | import org.bouncycastle.math.ec.rfc8032.Ed448;
|
28 | 30 | import org.bouncycastle.openpgp.operator.PGPContentVerifier;
|
@@ -905,6 +907,37 @@ public static boolean isCertification(int signatureType)
|
905 | 907 | || PGPSignature.POSITIVE_CERTIFICATION == signatureType;
|
906 | 908 | }
|
907 | 909 |
|
| 910 | + public static boolean isRevocation(int signatureType) |
| 911 | + { |
| 912 | + return PGPSignature.KEY_REVOCATION == signatureType |
| 913 | + || PGPSignature.CERTIFICATION_REVOCATION == signatureType |
| 914 | + || PGPSignature.SUBKEY_REVOCATION == signatureType; |
| 915 | + } |
| 916 | + |
| 917 | + public boolean isHardRevocation() |
| 918 | + { |
| 919 | + if (!isRevocation(getSignatureType())) |
| 920 | + { |
| 921 | + return false; // no revocation |
| 922 | + } |
| 923 | + |
| 924 | + if (!hasSubpackets()) |
| 925 | + { |
| 926 | + return true; // consider missing subpackets (and therefore missing reason) as hard revocation |
| 927 | + } |
| 928 | + |
| 929 | + // only consider reasons from the hashed packet area |
| 930 | + RevocationReason reason = getHashedSubPackets() != null ? |
| 931 | + getHashedSubPackets().getRevocationReason() : null; |
| 932 | + if (reason == null) |
| 933 | + { |
| 934 | + return true; // missing reason packet is hard |
| 935 | + } |
| 936 | + |
| 937 | + return reason.getRevocationReason() == RevocationReasonTags.NO_REASON // No reason is hard |
| 938 | + || reason.getRevocationReason() == RevocationReasonTags.KEY_COMPROMISED; // key compromise is hard |
| 939 | + } |
| 940 | + |
908 | 941 | /**
|
909 | 942 | * Return true, if the cryptographic signature encoding of the two signatures match.
|
910 | 943 | *
|
|
0 commit comments