Adjust to new API

This commit is contained in:
Paul Schaub 2025-01-02 15:44:49 +01:00
parent eca3ad56b8
commit f916ac2871
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -1,7 +1,6 @@
package org.pgpainless.bouncycastle.sop.operation; package org.pgpainless.bouncycastle.sop.operation;
import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPSecretKeyRing;
import org.bouncycastle.openpgp.api.OpenPGPKey; import org.bouncycastle.openpgp.api.OpenPGPKey;
import org.bouncycastle.openpgp.api.OpenPGPV6KeyGenerator; import org.bouncycastle.openpgp.api.OpenPGPV6KeyGenerator;
import org.bouncycastle.openpgp.api.bc.BcOpenPGPV6KeyGenerator; import org.bouncycastle.openpgp.api.bc.BcOpenPGPV6KeyGenerator;
@ -32,19 +31,22 @@ public class BCGenerateKey
@Override @Override
public void writeTo(@NotNull OutputStream outputStream) throws IOException public void writeTo(@NotNull OutputStream outputStream) throws IOException
{ {
OpenPGPV6KeyGenerator generator = new BcOpenPGPV6KeyGenerator(new Date()); OpenPGPV6KeyGenerator generator = null;
try {
generator = new BcOpenPGPV6KeyGenerator(new Date());
} catch (PGPException e) {
throw new RuntimeException(e);
}
OpenPGPKey key; OpenPGPKey key;
try try
{ {
if (signOnly) if (signOnly)
{ {
PGPSecretKeyRing keyRing = generator.signOnlyKey(passphrase); key = generator.signOnlyKey(passphrase);
key = new OpenPGPKey(keyRing);
} }
else else
{ {
PGPSecretKeyRing keyRing = generator.ed25519x25519Key(userId, passphrase); key = generator.ed25519x25519Key(userId, passphrase);
key = new OpenPGPKey(keyRing);
} }
} }
catch (PGPException e) catch (PGPException e)