aboutsummaryrefslogtreecommitdiffstats
path: root/libraries/spongycastle/pg/src/main/j2me/org/spongycastle/openpgp/PGPKeyPair.java
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/spongycastle/pg/src/main/j2me/org/spongycastle/openpgp/PGPKeyPair.java')
-rw-r--r--libraries/spongycastle/pg/src/main/j2me/org/spongycastle/openpgp/PGPKeyPair.java62
1 files changed, 62 insertions, 0 deletions
diff --git a/libraries/spongycastle/pg/src/main/j2me/org/spongycastle/openpgp/PGPKeyPair.java b/libraries/spongycastle/pg/src/main/j2me/org/spongycastle/openpgp/PGPKeyPair.java
new file mode 100644
index 000000000..fc2c891cb
--- /dev/null
+++ b/libraries/spongycastle/pg/src/main/j2me/org/spongycastle/openpgp/PGPKeyPair.java
@@ -0,0 +1,62 @@
+package org.spongycastle.openpgp;
+
+import java.util.Date;
+
+import org.spongycastle.bcpg.BCPGKey;
+import org.spongycastle.bcpg.DSASecretBCPGKey;
+import org.spongycastle.bcpg.ElGamalSecretBCPGKey;
+import org.spongycastle.bcpg.RSASecretBCPGKey;
+
+
+/**
+ * General class to handle JCA key pairs and convert them into OpenPGP ones.
+ * <p>
+ * A word for the unwary, the KeyID for a OpenPGP public key is calculated from
+ * a hash that includes the time of creation, if you pass a different date to the
+ * constructor below with the same public private key pair the KeyID will not be the
+ * same as for previous generations of the key, so ideally you only want to do
+ * this once.
+ */
+public class PGPKeyPair
+{
+ protected PGPPublicKey pub;
+ protected PGPPrivateKey priv;
+
+ protected PGPKeyPair()
+ {
+ }
+
+ /**
+ * Create a key pair from a PGPPrivateKey and a PGPPublicKey.
+ *
+ * @param pub the public key
+ * @param priv the private key
+ */
+ public PGPKeyPair(
+ PGPPublicKey pub,
+ PGPPrivateKey priv)
+ {
+ this.pub = pub;
+ this.priv = priv;
+ }
+
+ /**
+ * Return the keyID associated with this key pair.
+ *
+ * @return keyID
+ */
+ public long getKeyID()
+ {
+ return pub.getKeyID();
+ }
+
+ public PGPPublicKey getPublicKey()
+ {
+ return pub;
+ }
+
+ public PGPPrivateKey getPrivateKey()
+ {
+ return priv;
+ }
+}