mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-12-12 15:21:08 +01:00
Ignore certificate signatures of unknown type
This commit is contained in:
parent
89790a0a94
commit
b99822f405
8 changed files with 33 additions and 17 deletions
|
|
@ -32,6 +32,7 @@ import java.io.ByteArrayInputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import org.bouncycastle.bcpg.BCPGInputStream;
|
||||
import org.bouncycastle.openpgp.PGPCompressedData;
|
||||
|
|
@ -208,8 +209,8 @@ public class OpenPgpInputStream extends BufferedInputStream {
|
|||
}
|
||||
|
||||
try {
|
||||
SignatureType.valueOf(sigType);
|
||||
} catch (IllegalArgumentException e) {
|
||||
SignatureType.requireFromCode(sigType);
|
||||
} catch (NoSuchElementException e) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -236,8 +237,8 @@ public class OpenPgpInputStream extends BufferedInputStream {
|
|||
if (opsVersion == 3) {
|
||||
int opsSigType = bcpgIn.read();
|
||||
try {
|
||||
SignatureType.valueOf(opsSigType);
|
||||
} catch (IllegalArgumentException e) {
|
||||
SignatureType.requireFromCode(opsSigType);
|
||||
} catch (NoSuchElementException e) {
|
||||
return;
|
||||
}
|
||||
int opsHashAlg = bcpgIn.read();
|
||||
|
|
|
|||
|
|
@ -28,7 +28,14 @@ public class SignatureValidationException extends PGPException {
|
|||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(rejections.size()).append(" rejected signatures:\n");
|
||||
for (PGPSignature signature : rejections.keySet()) {
|
||||
sb.append(SignatureType.valueOf(signature.getSignatureType())).append(' ')
|
||||
String typeString;
|
||||
SignatureType type = SignatureType.fromCode(signature.getSignatureType());
|
||||
if (type == null) {
|
||||
typeString = "0x" + Long.toHexString(signature.getSignatureType());
|
||||
} else {
|
||||
typeString = type.toString();
|
||||
}
|
||||
sb.append(typeString).append(' ')
|
||||
.append(signature.getCreationTime()).append(": ")
|
||||
.append(rejections.get(signature).getMessage()).append('\n');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,11 @@ public final class OpenPgpKeyAttributeUtil {
|
|||
continue;
|
||||
}
|
||||
|
||||
SignatureType signatureType = SignatureType.valueOf(signature.getSignatureType());
|
||||
SignatureType signatureType = SignatureType.fromCode(signature.getSignatureType());
|
||||
if (signatureType == null) {
|
||||
// unknown signature type
|
||||
continue;
|
||||
}
|
||||
if (signatureType == SignatureType.POSITIVE_CERTIFICATION
|
||||
|| signatureType == SignatureType.GENERIC_CERTIFICATION) {
|
||||
int[] hashAlgos = signature.getHashedSubPackets().getPreferredHashAlgorithms();
|
||||
|
|
@ -71,8 +75,8 @@ public final class OpenPgpKeyAttributeUtil {
|
|||
continue;
|
||||
}
|
||||
|
||||
SignatureType signatureType = SignatureType.valueOf(signature.getSignatureType());
|
||||
if (signatureType != SignatureType.POSITIVE_CERTIFICATION
|
||||
SignatureType signatureType = SignatureType.fromCode(signature.getSignatureType());
|
||||
if (signatureType == null || signatureType != SignatureType.POSITIVE_CERTIFICATION
|
||||
&& signatureType != SignatureType.GENERIC_CERTIFICATION) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue