mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-27 06:42:05 +01:00
Properly ignore marker packets when reading keys/sigs
This commit is contained in:
parent
fb16db5db4
commit
e7ed0f76a3
3 changed files with 17 additions and 17 deletions
|
@ -15,9 +15,17 @@
|
||||||
*/
|
*/
|
||||||
package org.pgpainless.key.collection;
|
package org.pgpainless.key.collection;
|
||||||
|
|
||||||
import org.bouncycastle.bcpg.MarkerPacket;
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import org.bouncycastle.openpgp.PGPException;
|
import org.bouncycastle.openpgp.PGPException;
|
||||||
import org.bouncycastle.openpgp.PGPKeyRing;
|
import org.bouncycastle.openpgp.PGPKeyRing;
|
||||||
|
import org.bouncycastle.openpgp.PGPMarker;
|
||||||
import org.bouncycastle.openpgp.PGPObjectFactory;
|
import org.bouncycastle.openpgp.PGPObjectFactory;
|
||||||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||||
import org.bouncycastle.openpgp.PGPPublicKeyRingCollection;
|
import org.bouncycastle.openpgp.PGPPublicKeyRingCollection;
|
||||||
|
@ -26,14 +34,6 @@ import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
|
||||||
import org.bouncycastle.openpgp.PGPUtil;
|
import org.bouncycastle.openpgp.PGPUtil;
|
||||||
import org.pgpainless.implementation.ImplementationFactory;
|
import org.pgpainless.implementation.ImplementationFactory;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class describes a logic of handling a collection of different {@link PGPKeyRing}. The logic was inspired by
|
* This class describes a logic of handling a collection of different {@link PGPKeyRing}. The logic was inspired by
|
||||||
* {@link PGPSecretKeyRingCollection} and {@link PGPPublicKeyRingCollection}.
|
* {@link PGPSecretKeyRingCollection} and {@link PGPPublicKeyRingCollection}.
|
||||||
|
@ -65,7 +65,7 @@ public class PGPKeyRingCollection {
|
||||||
List<PGPPublicKeyRing> publicKeyRings = new ArrayList<>();
|
List<PGPPublicKeyRing> publicKeyRings = new ArrayList<>();
|
||||||
|
|
||||||
while ((obj = pgpFact.nextObject()) != null) {
|
while ((obj = pgpFact.nextObject()) != null) {
|
||||||
if (obj instanceof MarkerPacket) {
|
if (obj instanceof PGPMarker) {
|
||||||
// Skip marker packets
|
// Skip marker packets
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,8 @@ import java.util.List;
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import org.bouncycastle.bcpg.ArmoredInputStream;
|
import org.bouncycastle.bcpg.ArmoredInputStream;
|
||||||
import org.bouncycastle.bcpg.MarkerPacket;
|
|
||||||
import org.bouncycastle.openpgp.PGPException;
|
import org.bouncycastle.openpgp.PGPException;
|
||||||
|
import org.bouncycastle.openpgp.PGPMarker;
|
||||||
import org.bouncycastle.openpgp.PGPObjectFactory;
|
import org.bouncycastle.openpgp.PGPObjectFactory;
|
||||||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||||
import org.bouncycastle.openpgp.PGPPublicKeyRingCollection;
|
import org.bouncycastle.openpgp.PGPPublicKeyRingCollection;
|
||||||
|
@ -117,7 +117,7 @@ public class KeyRingReader {
|
||||||
if (next == null) {
|
if (next == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (next instanceof MarkerPacket) {
|
if (next instanceof PGPMarker) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (next instanceof PGPPublicKeyRing) {
|
if (next instanceof PGPPublicKeyRing) {
|
||||||
|
@ -142,7 +142,7 @@ public class KeyRingReader {
|
||||||
if (next == null) {
|
if (next == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (next instanceof MarkerPacket) {
|
if (next instanceof PGPMarker) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (next instanceof PGPPublicKeyRing) {
|
if (next instanceof PGPPublicKeyRing) {
|
||||||
|
@ -172,7 +172,7 @@ public class KeyRingReader {
|
||||||
if (next == null) {
|
if (next == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (next instanceof MarkerPacket) {
|
if (next instanceof PGPMarker) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (next instanceof PGPSecretKeyRing) {
|
if (next instanceof PGPSecretKeyRing) {
|
||||||
|
@ -198,7 +198,7 @@ public class KeyRingReader {
|
||||||
if (next == null) {
|
if (next == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (next instanceof MarkerPacket) {
|
if (next instanceof PGPMarker) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (next instanceof PGPSecretKeyRing) {
|
if (next instanceof PGPSecretKeyRing) {
|
||||||
|
|
|
@ -24,12 +24,12 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bouncycastle.bcpg.sig.IssuerKeyID;
|
import org.bouncycastle.bcpg.sig.IssuerKeyID;
|
||||||
import org.bouncycastle.bcpg.MarkerPacket;
|
|
||||||
import org.bouncycastle.bcpg.sig.KeyExpirationTime;
|
import org.bouncycastle.bcpg.sig.KeyExpirationTime;
|
||||||
import org.bouncycastle.bcpg.sig.RevocationReason;
|
import org.bouncycastle.bcpg.sig.RevocationReason;
|
||||||
import org.bouncycastle.bcpg.sig.SignatureExpirationTime;
|
import org.bouncycastle.bcpg.sig.SignatureExpirationTime;
|
||||||
import org.bouncycastle.openpgp.PGPCompressedData;
|
import org.bouncycastle.openpgp.PGPCompressedData;
|
||||||
import org.bouncycastle.openpgp.PGPException;
|
import org.bouncycastle.openpgp.PGPException;
|
||||||
|
import org.bouncycastle.openpgp.PGPMarker;
|
||||||
import org.bouncycastle.openpgp.PGPObjectFactory;
|
import org.bouncycastle.openpgp.PGPObjectFactory;
|
||||||
import org.bouncycastle.openpgp.PGPPublicKey;
|
import org.bouncycastle.openpgp.PGPPublicKey;
|
||||||
import org.bouncycastle.openpgp.PGPSecretKey;
|
import org.bouncycastle.openpgp.PGPSecretKey;
|
||||||
|
@ -202,7 +202,7 @@ public class SignatureUtils {
|
||||||
|
|
||||||
Object nextObject = objectFactory.nextObject();
|
Object nextObject = objectFactory.nextObject();
|
||||||
while (nextObject != null) {
|
while (nextObject != null) {
|
||||||
if (nextObject instanceof MarkerPacket) {
|
if (nextObject instanceof PGPMarker) {
|
||||||
nextObject = objectFactory.nextObject();
|
nextObject = objectFactory.nextObject();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue