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

Replace JcaPGPObjectFactory with custom PGPObjectFactory.

Workaround for https://github.com/bcgit/bc-java/issues/1428
This commit is contained in:
Paul Schaub 2023-06-15 15:20:08 +02:00
parent 56cb9ba3c6
commit 82cea93e7b
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
2 changed files with 11 additions and 9 deletions

View file

@ -15,7 +15,6 @@ import org.bouncycastle.openpgp.PGPPrivateKey;
import org.bouncycastle.openpgp.PGPPublicKey;
import org.bouncycastle.openpgp.PGPSecretKey;
import org.bouncycastle.openpgp.PGPSessionKey;
import org.bouncycastle.openpgp.jcajce.JcaPGPObjectFactory;
import org.bouncycastle.openpgp.operator.KeyFingerPrintCalculator;
import org.bouncycastle.openpgp.operator.PBEDataDecryptorFactory;
import org.bouncycastle.openpgp.operator.PBEKeyEncryptionMethodGenerator;
@ -139,11 +138,11 @@ public class JceImplementationFactory extends ImplementationFactory {
@Override
public PGPObjectFactory getPGPObjectFactory(InputStream inputStream) {
return new JcaPGPObjectFactory(inputStream);
return new PGPObjectFactory(inputStream, ImplementationFactory.getInstance().getKeyFingerprintCalculator());
}
@Override
public PGPObjectFactory getPGPObjectFactory(byte[] bytes) {
return new JcaPGPObjectFactory(bytes);
return new PGPObjectFactory(bytes, ImplementationFactory.getInstance().getKeyFingerprintCalculator());
}
}

View file

@ -4,13 +4,14 @@
package org.pgpainless.key;
import java.io.IOException;
import org.bouncycastle.openpgp.PGPPublicKeyRing;
import org.bouncycastle.openpgp.PGPSecretKeyRing;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import org.pgpainless.PGPainless;
import java.io.IOException;
import org.pgpainless.util.TestAllImplementations;
public class V6OpenPgpKeyTest {
@ -43,12 +44,14 @@ public class V6OpenPgpKeyTest {
"I8kWVkXU6vFOi+HWvv/ira7ofJu16NnoUkhclkUrk0mXubZvyl4GBg==\n" +
"-----END PGP PUBLIC KEY BLOCK-----";
@Test
@TestTemplate
@ExtendWith(TestAllImplementations.class)
public void testParseCert() throws IOException {
PGPPublicKeyRing cert = PGPainless.readKeyRing().publicKeyRing(CERT);
}
@Test
@TestTemplate
@ExtendWith(TestAllImplementations.class)
public void testParseKey() throws IOException {
PGPSecretKeyRing key = PGPainless.readKeyRing().secretKeyRing(KEY);
}