1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-12-23 03:17:58 +01:00

Workaround for BC not correctly parsing RevocationKey packets

This commit is contained in:
Paul Schaub 2022-01-04 17:23:13 +01:00
parent 88e3c61b20
commit fa0e208c98

View file

@ -10,7 +10,6 @@ import java.util.Date;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -37,7 +36,6 @@ import org.bouncycastle.openpgp.PGPPublicKey;
import org.bouncycastle.openpgp.PGPSignature; import org.bouncycastle.openpgp.PGPSignature;
import org.bouncycastle.openpgp.PGPSignatureList; import org.bouncycastle.openpgp.PGPSignatureList;
import org.bouncycastle.openpgp.PGPSignatureSubpacketVector; import org.bouncycastle.openpgp.PGPSignatureSubpacketVector;
import org.bouncycastle.util.encoders.Hex;
import org.pgpainless.algorithm.CompressionAlgorithm; import org.pgpainless.algorithm.CompressionAlgorithm;
import org.pgpainless.algorithm.Feature; import org.pgpainless.algorithm.Feature;
import org.pgpainless.algorithm.HashAlgorithm; import org.pgpainless.algorithm.HashAlgorithm;
@ -581,7 +579,16 @@ public final class SignatureSubpacketsUtil {
if (allPackets.length == 0) { if (allPackets.length == 0) {
return null; return null;
} }
return (P) allPackets[allPackets.length - 1]; // return last
org.bouncycastle.bcpg.SignatureSubpacket last = allPackets[allPackets.length - 1];
if (type == SignatureSubpacket.revocationKey) {
// RevocationKey subpackets are not castable for some reason
// We need to manually construct the new object
return (P) new RevocationKey(last.isCritical(), last.isLongLength(), last.getData());
}
return (P) last;
} }
/** /**