diff --git a/pg/src/main/java/org/bouncycastle/openpgp/api/OpenPGPCertificate.java b/pg/src/main/java/org/bouncycastle/openpgp/api/OpenPGPCertificate.java index 6536fc03f5..96eb2507b2 100644 --- a/pg/src/main/java/org/bouncycastle/openpgp/api/OpenPGPCertificate.java +++ b/pg/src/main/java/org/bouncycastle/openpgp/api/OpenPGPCertificate.java @@ -105,6 +105,11 @@ public OpenPGPCertificate(PGPKeyRing rawCert, OpenPGPImplementation implementati } } + public static OpenPGPCertificate fromAsciiArmor(String armor) + throws IOException + { + return fromAsciiArmor(armor, new BcOpenPGPImplementation()); + } public static OpenPGPCertificate fromAsciiArmor( String armor, diff --git a/pg/src/main/java/org/bouncycastle/openpgp/api/OpenPGPKey.java b/pg/src/main/java/org/bouncycastle/openpgp/api/OpenPGPKey.java index bec8d1ec49..723c4fd23e 100644 --- a/pg/src/main/java/org/bouncycastle/openpgp/api/OpenPGPKey.java +++ b/pg/src/main/java/org/bouncycastle/openpgp/api/OpenPGPKey.java @@ -51,6 +51,12 @@ public OpenPGPKey(PGPSecretKeyRing rawKey, OpenPGPImplementation implementation) } } + public static OpenPGPKey fromAsciiArmor(String armor) + throws IOException + { + return fromAsciiArmor(armor, new BcOpenPGPImplementation()); + } + public static OpenPGPKey fromAsciiArmor( String armor, OpenPGPImplementation implementation) diff --git a/pg/src/test/java/org/bouncycastle/openpgp/api/test/OpenPGPCertificateTest.java b/pg/src/test/java/org/bouncycastle/openpgp/api/test/OpenPGPCertificateTest.java index e2dde8e7f5..936d87edea 100644 --- a/pg/src/test/java/org/bouncycastle/openpgp/api/test/OpenPGPCertificateTest.java +++ b/pg/src/test/java/org/bouncycastle/openpgp/api/test/OpenPGPCertificateTest.java @@ -59,7 +59,7 @@ private void testOpenPGPv6Key() "M0g12vYxoWM8Y81W+bHBw805I8kWVkXU6vFOi+HWvv/ira7ofJu16NnoUkhclkUr\n" + "k0mXubZvyl4GBg==\n" + "-----END PGP PRIVATE KEY BLOCK-----"; - OpenPGPKey key = OpenPGPKey.fromAsciiArmor(armoredKey, new BcOpenPGPImplementation()); + OpenPGPKey key = OpenPGPKey.fromAsciiArmor(armoredKey); isTrue("Test key has no identities", key.getIdentities().isEmpty()); @@ -778,7 +778,7 @@ private void testPKSignsPKRevocationSuperseded() private void signatureValidityTest(String cert, TestSignature... testSignatures) throws IOException { - OpenPGPCertificate certificate = OpenPGPCertificate.fromAsciiArmor(cert, new BcOpenPGPImplementation()); + OpenPGPCertificate certificate = OpenPGPCertificate.fromAsciiArmor(cert); for (TestSignature test : testSignatures) { diff --git a/pg/src/test/java/org/bouncycastle/openpgp/api/test/OpenPGPMessageGeneratorTest.java b/pg/src/test/java/org/bouncycastle/openpgp/api/test/OpenPGPMessageGeneratorTest.java index 7736eb6068..20f398786f 100644 --- a/pg/src/test/java/org/bouncycastle/openpgp/api/test/OpenPGPMessageGeneratorTest.java +++ b/pg/src/test/java/org/bouncycastle/openpgp/api/test/OpenPGPMessageGeneratorTest.java @@ -133,7 +133,7 @@ private void seipd2EncryptedMessage() "j+VjFM21J0hqWlEg+bdiojWnKfA5AQpWUWtnNwDEM0g12vYxoWM8Y81W+bHBw805\n" + "I8kWVkXU6vFOi+HWvv/ira7ofJu16NnoUkhclkUrk0mXubZvyl4GBg==\n" + "-----END PGP PUBLIC KEY BLOCK-----"; - OpenPGPCertificate cert = OpenPGPCertificate.fromAsciiArmor(v6Cert, new BcOpenPGPImplementation()); + OpenPGPCertificate cert = OpenPGPCertificate.fromAsciiArmor(v6Cert); OpenPGPMessageGenerator gen = new OpenPGPMessageGenerator(); gen.addEncryptionCertificate(cert); @@ -231,7 +231,7 @@ private void seipd1EncryptedMessage() "xqAY9Bwizt4FWgXuLm1a4+So4V9j1TRCXd12Uc2l2RNmgDE=\n" + "=miES\n" + "-----END PGP PRIVATE KEY BLOCK-----\n"; - OpenPGPKey key = OpenPGPKey.fromAsciiArmor(v4Key, new BcOpenPGPImplementation()); + OpenPGPKey key = OpenPGPKey.fromAsciiArmor(v4Key); OpenPGPMessageGenerator gen = new OpenPGPMessageGenerator(); gen.addEncryptionCertificate(key); diff --git a/pg/src/test/java/org/bouncycastle/openpgp/api/test/OpenPGPMessageProcessorTest.java b/pg/src/test/java/org/bouncycastle/openpgp/api/test/OpenPGPMessageProcessorTest.java index 2e98e177d1..ee19050814 100644 --- a/pg/src/test/java/org/bouncycastle/openpgp/api/test/OpenPGPMessageProcessorTest.java +++ b/pg/src/test/java/org/bouncycastle/openpgp/api/test/OpenPGPMessageProcessorTest.java @@ -151,8 +151,7 @@ private void roundTripCompressedSymEncMessageMessage() private void roundTripV6KeyEncryptedMessage() throws IOException, PGPException { - OpenPGPKey key = OpenPGPKey.fromAsciiArmor(v6Key, - new BcOpenPGPImplementation()); + OpenPGPKey key = OpenPGPKey.fromAsciiArmor(v6Key); OpenPGPMessageGenerator gen = new OpenPGPMessageGenerator() .setArmored(true) diff --git a/pg/src/test/java/org/bouncycastle/openpgp/api/test/StaticV6OpenPGPMessageGeneratorTest.java b/pg/src/test/java/org/bouncycastle/openpgp/api/test/StaticV6OpenPGPMessageGeneratorTest.java index 8161f59836..f31c00d50c 100644 --- a/pg/src/test/java/org/bouncycastle/openpgp/api/test/StaticV6OpenPGPMessageGeneratorTest.java +++ b/pg/src/test/java/org/bouncycastle/openpgp/api/test/StaticV6OpenPGPMessageGeneratorTest.java @@ -59,7 +59,7 @@ public void performTest() private void staticEncryptedMessage() throws IOException, PGPException { - OpenPGPKey key = OpenPGPKey.fromAsciiArmor(V6KEY, new BcOpenPGPImplementation()); + OpenPGPKey key = OpenPGPKey.fromAsciiArmor(V6KEY); OpenPGPMessageGenerator gen = getStaticGenerator() .addEncryptionCertificate(key); @@ -75,7 +75,7 @@ private void staticEncryptedMessage() private void staticSignedMessage() throws IOException, PGPException { - OpenPGPKey key = OpenPGPKey.fromAsciiArmor(V6KEY, new BcOpenPGPImplementation()); + OpenPGPKey key = OpenPGPKey.fromAsciiArmor(V6KEY); OpenPGPMessageGenerator gen = getStaticGenerator() .addSigningKey(key, null);