Skip to content

Commit ea5cde9

Browse files
committed
Default to BcOpenPGPImplementation
1 parent ecd7051 commit ea5cde9

File tree

6 files changed

+18
-12
lines changed

6 files changed

+18
-12
lines changed

pg/src/main/java/org/bouncycastle/openpgp/api/OpenPGPCertificate.java

+5
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ public OpenPGPCertificate(PGPKeyRing rawCert, OpenPGPImplementation implementati
105105
}
106106
}
107107

108+
public static OpenPGPCertificate fromAsciiArmor(String armor)
109+
throws IOException
110+
{
111+
return fromAsciiArmor(armor, new BcOpenPGPImplementation());
112+
}
108113

109114
public static OpenPGPCertificate fromAsciiArmor(
110115
String armor,

pg/src/main/java/org/bouncycastle/openpgp/api/OpenPGPKey.java

+6
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ public OpenPGPKey(PGPSecretKeyRing rawKey, OpenPGPImplementation implementation)
5151
}
5252
}
5353

54+
public static OpenPGPKey fromAsciiArmor(String armor)
55+
throws IOException
56+
{
57+
return fromAsciiArmor(armor, new BcOpenPGPImplementation());
58+
}
59+
5460
public static OpenPGPKey fromAsciiArmor(
5561
String armor,
5662
OpenPGPImplementation implementation)

pg/src/test/java/org/bouncycastle/openpgp/api/test/OpenPGPCertificateTest.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import org.bouncycastle.openpgp.PGPObjectFactory;
1010
import org.bouncycastle.openpgp.PGPSignature;
1111
import org.bouncycastle.openpgp.PGPSignatureList;
12-
import org.bouncycastle.openpgp.api.BcOpenPGPImplementation;
1312
import org.bouncycastle.openpgp.api.OpenPGPCertificate;
1413
import org.bouncycastle.openpgp.api.OpenPGPKey;
1514
import org.bouncycastle.openpgp.api.util.UTCUtil;
@@ -59,7 +58,7 @@ private void testOpenPGPv6Key()
5958
"M0g12vYxoWM8Y81W+bHBw805I8kWVkXU6vFOi+HWvv/ira7ofJu16NnoUkhclkUr\n" +
6059
"k0mXubZvyl4GBg==\n" +
6160
"-----END PGP PRIVATE KEY BLOCK-----";
62-
OpenPGPKey key = OpenPGPKey.fromAsciiArmor(armoredKey, new BcOpenPGPImplementation());
61+
OpenPGPKey key = OpenPGPKey.fromAsciiArmor(armoredKey);
6362

6463
isTrue("Test key has no identities", key.getIdentities().isEmpty());
6564

@@ -778,7 +777,7 @@ private void testPKSignsPKRevocationSuperseded()
778777
private void signatureValidityTest(String cert, TestSignature... testSignatures)
779778
throws IOException
780779
{
781-
OpenPGPCertificate certificate = OpenPGPCertificate.fromAsciiArmor(cert, new BcOpenPGPImplementation());
780+
OpenPGPCertificate certificate = OpenPGPCertificate.fromAsciiArmor(cert);
782781

783782
for (TestSignature test : testSignatures)
784783
{

pg/src/test/java/org/bouncycastle/openpgp/api/test/OpenPGPMessageGeneratorTest.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import org.bouncycastle.bcpg.CompressionAlgorithmTags;
44
import org.bouncycastle.bcpg.test.AbstractPacketTest;
55
import org.bouncycastle.openpgp.PGPException;
6-
import org.bouncycastle.openpgp.api.BcOpenPGPImplementation;
76
import org.bouncycastle.openpgp.api.OpenPGPCertificate;
87
import org.bouncycastle.openpgp.api.OpenPGPKey;
98
import org.bouncycastle.openpgp.api.OpenPGPMessageGenerator;
@@ -133,7 +132,7 @@ private void seipd2EncryptedMessage()
133132
"j+VjFM21J0hqWlEg+bdiojWnKfA5AQpWUWtnNwDEM0g12vYxoWM8Y81W+bHBw805\n" +
134133
"I8kWVkXU6vFOi+HWvv/ira7ofJu16NnoUkhclkUrk0mXubZvyl4GBg==\n" +
135134
"-----END PGP PUBLIC KEY BLOCK-----";
136-
OpenPGPCertificate cert = OpenPGPCertificate.fromAsciiArmor(v6Cert, new BcOpenPGPImplementation());
135+
OpenPGPCertificate cert = OpenPGPCertificate.fromAsciiArmor(v6Cert);
137136

138137
OpenPGPMessageGenerator gen = new OpenPGPMessageGenerator();
139138
gen.addEncryptionCertificate(cert);
@@ -231,7 +230,7 @@ private void seipd1EncryptedMessage()
231230
"xqAY9Bwizt4FWgXuLm1a4+So4V9j1TRCXd12Uc2l2RNmgDE=\n" +
232231
"=miES\n" +
233232
"-----END PGP PRIVATE KEY BLOCK-----\n";
234-
OpenPGPKey key = OpenPGPKey.fromAsciiArmor(v4Key, new BcOpenPGPImplementation());
233+
OpenPGPKey key = OpenPGPKey.fromAsciiArmor(v4Key);
235234

236235
OpenPGPMessageGenerator gen = new OpenPGPMessageGenerator();
237236
gen.addEncryptionCertificate(key);

pg/src/test/java/org/bouncycastle/openpgp/api/test/OpenPGPMessageProcessorTest.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import org.bouncycastle.bcpg.SymmetricKeyAlgorithmTags;
55
import org.bouncycastle.bcpg.test.AbstractPacketTest;
66
import org.bouncycastle.openpgp.PGPException;
7-
import org.bouncycastle.openpgp.api.BcOpenPGPImplementation;
87
import org.bouncycastle.openpgp.api.OpenPGPKey;
98
import org.bouncycastle.openpgp.api.OpenPGPMessageGenerator;
109
import org.bouncycastle.openpgp.api.OpenPGPMessageProcessor;
@@ -151,8 +150,7 @@ private void roundTripCompressedSymEncMessageMessage()
151150
private void roundTripV6KeyEncryptedMessage()
152151
throws IOException, PGPException
153152
{
154-
OpenPGPKey key = OpenPGPKey.fromAsciiArmor(v6Key,
155-
new BcOpenPGPImplementation());
153+
OpenPGPKey key = OpenPGPKey.fromAsciiArmor(v6Key);
156154

157155
OpenPGPMessageGenerator gen = new OpenPGPMessageGenerator()
158156
.setArmored(true)

pg/src/test/java/org/bouncycastle/openpgp/api/test/StaticV6OpenPGPMessageGeneratorTest.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import org.bouncycastle.openpgp.PGPPublicKey;
77
import org.bouncycastle.openpgp.PGPPublicKeyRing;
88
import org.bouncycastle.openpgp.PGPSecretKeyRing;
9-
import org.bouncycastle.openpgp.api.BcOpenPGPImplementation;
109
import org.bouncycastle.openpgp.api.OpenPGPKey;
1110
import org.bouncycastle.openpgp.api.OpenPGPMessageGenerator;
1211
import org.bouncycastle.openpgp.api.OpenPGPMessageOutputStream;
@@ -59,7 +58,7 @@ public void performTest()
5958
private void staticEncryptedMessage()
6059
throws IOException, PGPException
6160
{
62-
OpenPGPKey key = OpenPGPKey.fromAsciiArmor(V6KEY, new BcOpenPGPImplementation());
61+
OpenPGPKey key = OpenPGPKey.fromAsciiArmor(V6KEY);
6362

6463
OpenPGPMessageGenerator gen = getStaticGenerator()
6564
.addEncryptionCertificate(key);
@@ -75,7 +74,7 @@ private void staticEncryptedMessage()
7574
private void staticSignedMessage()
7675
throws IOException, PGPException
7776
{
78-
OpenPGPKey key = OpenPGPKey.fromAsciiArmor(V6KEY, new BcOpenPGPImplementation());
77+
OpenPGPKey key = OpenPGPKey.fromAsciiArmor(V6KEY);
7978
OpenPGPMessageGenerator gen = getStaticGenerator()
8079
.addSigningKey(key, null);
8180

0 commit comments

Comments
 (0)