diff --git a/pgpainless-core/src/main/java/org/pgpainless/util/BCUtil.java b/pgpainless-core/src/main/java/org/pgpainless/util/BCUtil.java index a86d8e9b..21020dc4 100644 --- a/pgpainless-core/src/main/java/org/pgpainless/util/BCUtil.java +++ b/pgpainless-core/src/main/java/org/pgpainless/util/BCUtil.java @@ -64,20 +64,6 @@ public class BCUtil { return new PGPSecretKeyRingCollection(Arrays.asList(rings)); } - public static PGPPublicKeyRing publicKeyRingFromSecretKeyRing(@Nonnull PGPSecretKeyRing secretKeys) - throws PGPException, IOException { - ByteArrayOutputStream buffer = new ByteArrayOutputStream(512); - for (PGPSecretKey secretKey : secretKeys) { - PGPPublicKey publicKey = secretKey.getPublicKey(); - if (publicKey != null) { - publicKey.encode(buffer, false); - } - } - KeyFingerPrintCalculator fingerprintCalculator = ImplementationFactory.getInstance().getKeyFingerprintCalculator(); - - return new PGPPublicKeyRing(buffer.toByteArray(), fingerprintCalculator); - } - /* PGPXxxKeyRingCollection -> PGPXxxKeyRing */ diff --git a/pgpainless-sop/src/main/java/org/pgpainless/sop/commands/ExtractCert.java b/pgpainless-sop/src/main/java/org/pgpainless/sop/commands/ExtractCert.java index 6814d630..30ec1043 100644 --- a/pgpainless-sop/src/main/java/org/pgpainless/sop/commands/ExtractCert.java +++ b/pgpainless-sop/src/main/java/org/pgpainless/sop/commands/ExtractCert.java @@ -15,19 +15,19 @@ */ package org.pgpainless.sop.commands; +import static org.pgpainless.sop.Print.err_ln; +import static org.pgpainless.sop.Print.print_ln; + import java.io.IOException; import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPPublicKeyRing; import org.bouncycastle.openpgp.PGPSecretKeyRing; import org.pgpainless.PGPainless; +import org.pgpainless.key.util.KeyRingUtils; import org.pgpainless.sop.Print; -import org.pgpainless.util.BCUtil; import picocli.CommandLine; -import static org.pgpainless.sop.Print.err_ln; -import static org.pgpainless.sop.Print.print_ln; - @CommandLine.Command(name = "extract-cert", description = "Extract a public key certificate from a secret key from standard input") public class ExtractCert implements Runnable { @@ -41,7 +41,7 @@ public class ExtractCert implements Runnable { public void run() { try { PGPSecretKeyRing secretKeys = PGPainless.readKeyRing().secretKeyRing(System.in); - PGPPublicKeyRing publicKeys = BCUtil.publicKeyRingFromSecretKeyRing(secretKeys); + PGPPublicKeyRing publicKeys = KeyRingUtils.publicKeyRingFrom(secretKeys); print_ln(Print.toString(publicKeys.getEncoded(), armor)); } catch (IOException | PGPException e) {