From 38db67df80d6f0822b590e7ef92cc25fbf078a9c Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Thu, 30 Nov 2023 20:09:02 +0100 Subject: [PATCH] Backport 74c7b025a0aa49f947fedb1753a72bcee4334858 Do not choke on unknown signature subpackets Fixes #418 --- .../signature/subpackets/SignatureSubpacketsHelper.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pgpainless-core/src/main/java/org/pgpainless/signature/subpackets/SignatureSubpacketsHelper.java b/pgpainless-core/src/main/java/org/pgpainless/signature/subpackets/SignatureSubpacketsHelper.java index 8af60a03..7f105a85 100644 --- a/pgpainless-core/src/main/java/org/pgpainless/signature/subpackets/SignatureSubpacketsHelper.java +++ b/pgpainless-core/src/main/java/org/pgpainless/signature/subpackets/SignatureSubpacketsHelper.java @@ -35,7 +35,13 @@ public class SignatureSubpacketsHelper { public static SignatureSubpackets applyFrom(PGPSignatureSubpacketVector vector, SignatureSubpackets subpackets) { for (SignatureSubpacket subpacket : vector.toArray()) { - org.pgpainless.algorithm.SignatureSubpacket type = org.pgpainless.algorithm.SignatureSubpacket.requireFromCode(subpacket.getType()); + org.pgpainless.algorithm.SignatureSubpacket type = org.pgpainless.algorithm.SignatureSubpacket.fromCode(subpacket.getType()); + if (type == null) { + // Unknown subpacket, ignore and just add to the residuals + subpackets.addResidualSubpacket(subpacket); + continue; + } + switch (type) { case signatureCreationTime: case issuerKeyId: