diff options
Diffstat (limited to 'pg/src/main/java/org/spongycastle/openpgp/jcajce')
5 files changed, 152 insertions, 0 deletions
diff --git a/pg/src/main/java/org/spongycastle/openpgp/jcajce/JcaPGPObjectFactory.java b/pg/src/main/java/org/spongycastle/openpgp/jcajce/JcaPGPObjectFactory.java new file mode 100644 index 00000000..b310de39 --- /dev/null +++ b/pg/src/main/java/org/spongycastle/openpgp/jcajce/JcaPGPObjectFactory.java @@ -0,0 +1,35 @@ +package org.spongycastle.openpgp.jcajce; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; + +import org.spongycastle.openpgp.PGPObjectFactory; +import org.spongycastle.openpgp.operator.jcajce.JcaKeyFingerprintCalculator; + +/** + * {@link PGPObjectFactory} that uses the sources cryptographic primitives from the JCA API. + */ +public class JcaPGPObjectFactory + extends PGPObjectFactory +{ + /** + * Construct an object factory to read PGP objects from encoded data. + * + * @param encoded the PGP encoded data. + */ + public JcaPGPObjectFactory(byte[] encoded) + { + this(new ByteArrayInputStream(encoded)); + } + + /** + * Construct an object factory to read PGP objects from a stream. + * + * @param in the stream containing PGP encoded objects. + */ + public JcaPGPObjectFactory(InputStream in) + { + // FIXME: Convert this to builder style so we can set provider? + super(in, new JcaKeyFingerprintCalculator()); + } +} diff --git a/pg/src/main/java/org/spongycastle/openpgp/jcajce/JcaPGPPublicKeyRing.java b/pg/src/main/java/org/spongycastle/openpgp/jcajce/JcaPGPPublicKeyRing.java new file mode 100644 index 00000000..218e7f2f --- /dev/null +++ b/pg/src/main/java/org/spongycastle/openpgp/jcajce/JcaPGPPublicKeyRing.java @@ -0,0 +1,26 @@ +package org.spongycastle.openpgp.jcajce; + +import java.io.IOException; +import java.io.InputStream; + +import org.spongycastle.openpgp.PGPPublicKeyRing; +import org.spongycastle.openpgp.operator.KeyFingerPrintCalculator; +import org.spongycastle.openpgp.operator.jcajce.JcaKeyFingerprintCalculator; + +public class JcaPGPPublicKeyRing + extends PGPPublicKeyRing +{ + private static KeyFingerPrintCalculator fingerPrintCalculator = new JcaKeyFingerprintCalculator(); + + public JcaPGPPublicKeyRing(byte[] encoding) + throws IOException + { + super(encoding, fingerPrintCalculator); + } + + public JcaPGPPublicKeyRing(InputStream in) + throws IOException + { + super(in, fingerPrintCalculator); + } +} diff --git a/pg/src/main/java/org/spongycastle/openpgp/jcajce/JcaPGPPublicKeyRingCollection.java b/pg/src/main/java/org/spongycastle/openpgp/jcajce/JcaPGPPublicKeyRingCollection.java new file mode 100644 index 00000000..e23e18e6 --- /dev/null +++ b/pg/src/main/java/org/spongycastle/openpgp/jcajce/JcaPGPPublicKeyRingCollection.java @@ -0,0 +1,32 @@ +package org.spongycastle.openpgp.jcajce; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Collection; + +import org.spongycastle.openpgp.PGPException; +import org.spongycastle.openpgp.PGPPublicKeyRingCollection; +import org.spongycastle.openpgp.operator.jcajce.JcaKeyFingerprintCalculator; + +public class JcaPGPPublicKeyRingCollection + extends PGPPublicKeyRingCollection +{ + public JcaPGPPublicKeyRingCollection(byte[] encoding) + throws IOException, PGPException + { + this(new ByteArrayInputStream(encoding)); + } + + public JcaPGPPublicKeyRingCollection(InputStream in) + throws IOException, PGPException + { + super(in, new JcaKeyFingerprintCalculator()); + } + + public JcaPGPPublicKeyRingCollection(Collection collection) + throws IOException, PGPException + { + super(collection); + } +} diff --git a/pg/src/main/java/org/spongycastle/openpgp/jcajce/JcaPGPSecretKeyRing.java b/pg/src/main/java/org/spongycastle/openpgp/jcajce/JcaPGPSecretKeyRing.java new file mode 100644 index 00000000..9e1395a6 --- /dev/null +++ b/pg/src/main/java/org/spongycastle/openpgp/jcajce/JcaPGPSecretKeyRing.java @@ -0,0 +1,27 @@ +package org.spongycastle.openpgp.jcajce; + +import java.io.IOException; +import java.io.InputStream; + +import org.spongycastle.openpgp.PGPException; +import org.spongycastle.openpgp.PGPSecretKeyRing; +import org.spongycastle.openpgp.operator.KeyFingerPrintCalculator; +import org.spongycastle.openpgp.operator.jcajce.JcaKeyFingerprintCalculator; + +public class JcaPGPSecretKeyRing + extends PGPSecretKeyRing +{ + private static KeyFingerPrintCalculator fingerPrintCalculator = new JcaKeyFingerprintCalculator(); + + public JcaPGPSecretKeyRing(byte[] encoding) + throws IOException, PGPException + { + super(encoding, fingerPrintCalculator); + } + + public JcaPGPSecretKeyRing(InputStream in) + throws IOException, PGPException + { + super(in, fingerPrintCalculator); + } +} diff --git a/pg/src/main/java/org/spongycastle/openpgp/jcajce/JcaPGPSecretKeyRingCollection.java b/pg/src/main/java/org/spongycastle/openpgp/jcajce/JcaPGPSecretKeyRingCollection.java new file mode 100644 index 00000000..a105ac08 --- /dev/null +++ b/pg/src/main/java/org/spongycastle/openpgp/jcajce/JcaPGPSecretKeyRingCollection.java @@ -0,0 +1,32 @@ +package org.spongycastle.openpgp.jcajce; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Collection; + +import org.spongycastle.openpgp.PGPException; +import org.spongycastle.openpgp.PGPSecretKeyRingCollection; +import org.spongycastle.openpgp.operator.jcajce.JcaKeyFingerprintCalculator; + +public class JcaPGPSecretKeyRingCollection + extends PGPSecretKeyRingCollection +{ + public JcaPGPSecretKeyRingCollection(byte[] encoding) + throws IOException, PGPException + { + this(new ByteArrayInputStream(encoding)); + } + + public JcaPGPSecretKeyRingCollection(InputStream in) + throws IOException, PGPException + { + super(in, new JcaKeyFingerprintCalculator()); + } + + public JcaPGPSecretKeyRingCollection(Collection collection) + throws IOException, PGPException + { + super(collection); + } +} |