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 76d933b41c..a3c76d257b 100644 --- a/pg/src/main/java/org/bouncycastle/openpgp/api/OpenPGPCertificate.java +++ b/pg/src/main/java/org/bouncycastle/openpgp/api/OpenPGPCertificate.java @@ -18,6 +18,7 @@ import org.bouncycastle.openpgp.api.exception.MissingIssuerCertException; import org.bouncycastle.openpgp.api.util.UTCUtil; import org.bouncycastle.openpgp.operator.PGPContentVerifierBuilderProvider; +import org.bouncycastle.util.io.Streams; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -126,6 +127,25 @@ public static OpenPGPCertificate fromAsciiArmor( implementation); } + public static OpenPGPCertificate fromInputStream(InputStream inputStream) + throws IOException + { + return fromInputStream(inputStream, OpenPGPImplementation.getInstance()); + } + + public static OpenPGPCertificate fromInputStream(InputStream inputStream, OpenPGPImplementation implementation) + throws IOException + { + byte[] bytes = Streams.readAll(inputStream); + return fromBytes(bytes, implementation); + } + + public static OpenPGPCertificate fromBytes(byte[] bytes) + throws IOException + { + return fromBytes(bytes, OpenPGPImplementation.getInstance()); + } + public static OpenPGPCertificate fromBytes( byte[] bytes, OpenPGPImplementation implementation) 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 baa09c8f29..be4ac05457 100644 --- a/pg/src/main/java/org/bouncycastle/openpgp/api/OpenPGPKey.java +++ b/pg/src/main/java/org/bouncycastle/openpgp/api/OpenPGPKey.java @@ -14,6 +14,7 @@ import org.bouncycastle.openpgp.PGPUtil; import org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor; import org.bouncycastle.openpgp.operator.PBESecretKeyDecryptorBuilderProvider; +import org.bouncycastle.util.io.Streams; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -112,6 +113,25 @@ public static OpenPGPKey fromAsciiArmor( implementation); } + public static OpenPGPKey fromInputStream(InputStream inputStream) + throws IOException + { + return fromInputStream(inputStream, OpenPGPImplementation.getInstance()); + } + + public static OpenPGPKey fromInputStream(InputStream inputStream, OpenPGPImplementation implementation) + throws IOException + { + return fromBytes(Streams.readAll(inputStream), implementation); + } + + public static OpenPGPKey fromBytes( + byte[] bytes) + throws IOException + { + return fromBytes(bytes, OpenPGPImplementation.getInstance()); + } + public static OpenPGPKey fromBytes( byte[] bytes, OpenPGPImplementation implementation)