1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-18 02:12:06 +01:00

KeyRingReader.readPublicKeyRingCollection: Handle secret keys as public keys

This commit is contained in:
Paul Schaub 2023-07-06 13:08:56 +02:00
parent bbdb300814
commit 4cc8054cff
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -23,6 +23,7 @@ import org.bouncycastle.openpgp.PGPPublicKeyRingCollection;
import org.bouncycastle.openpgp.PGPSecretKeyRing;
import org.bouncycastle.openpgp.PGPSecretKeyRingCollection;
import org.bouncycastle.util.io.Streams;
import org.pgpainless.PGPainless;
import org.pgpainless.implementation.ImplementationFactory;
import org.pgpainless.key.collection.PGPKeyRingCollection;
import org.pgpainless.util.ArmorUtils;
@ -295,6 +296,12 @@ public class KeyRingReader {
}
if (next instanceof PGPPublicKeyRing) {
rings.add((PGPPublicKeyRing) next);
continue;
}
// Parse public keys from secret keys
if (next instanceof PGPSecretKeyRing) {
rings.add(PGPainless.extractCertificate((PGPSecretKeyRing) next));
continue;
}
if (next instanceof PGPPublicKeyRingCollection) {
PGPPublicKeyRingCollection collection = (PGPPublicKeyRingCollection) next;