org.spongycastle.openpgp.operator.jcajce.JcaPGPKeyPair Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcpg-jdk15on Show documentation
Show all versions of bcpg-jdk15on Show documentation
Spongy Castle is a package-rename (org.bouncycastle.* to org.spongycastle.*) of Bouncy Castle
intended for the Android platform. Android unfortunately ships with a stripped-down version of
Bouncy Castle, which prevents easy upgrades - Spongy Castle overcomes this and provides a full,
up-to-date version of the Bouncy Castle cryptographic libs.
The newest version!
package org.spongycastle.openpgp.operator.jcajce;
import java.security.KeyPair;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.util.Date;
import org.spongycastle.openpgp.PGPAlgorithmParameters;
import org.spongycastle.openpgp.PGPException;
import org.spongycastle.openpgp.PGPKeyPair;
import org.spongycastle.openpgp.PGPPrivateKey;
import org.spongycastle.openpgp.PGPPublicKey;
public class JcaPGPKeyPair
extends PGPKeyPair
{
private static PGPPublicKey getPublicKey(int algorithm, PublicKey pubKey, Date date)
throws PGPException
{
return new JcaPGPKeyConverter().getPGPPublicKey(algorithm, pubKey, date);
}
private static PGPPublicKey getPublicKey(int algorithm, PGPAlgorithmParameters algorithmParameters, PublicKey pubKey, Date date)
throws PGPException
{
return new JcaPGPKeyConverter().getPGPPublicKey(algorithm, algorithmParameters, pubKey, date);
}
private static PGPPrivateKey getPrivateKey(PGPPublicKey pub, PrivateKey privKey)
throws PGPException
{
return new JcaPGPKeyConverter().getPGPPrivateKey(pub, privKey);
}
public JcaPGPKeyPair(int algorithm, KeyPair keyPair, Date date)
throws PGPException
{
this.pub = getPublicKey(algorithm, keyPair.getPublic(), date);
this.priv = getPrivateKey(this.pub, keyPair.getPrivate());
}
public JcaPGPKeyPair(int algorithm, PGPAlgorithmParameters parameters, KeyPair keyPair, Date date)
throws PGPException
{
this.pub = getPublicKey(algorithm, parameters, keyPair.getPublic(), date);
this.priv = getPrivateKey(this.pub, keyPair.getPrivate());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy