org.bouncycastle.openpgp.operator.bc.BcPGPKeyPair 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
The Bouncy Castle Java API for handling the OpenPGP protocol. This jar contains the OpenPGP API for JDK 1.5 to JDK 1.7. The APIs can be used in conjunction with a JCE/JCA provider such as the one provided with the Bouncy Castle Cryptography APIs.
package org.bouncycastle.openpgp.operator.bc;
import java.util.Date;
import org.bouncycastle.crypto.AsymmetricCipherKeyPair;
import org.bouncycastle.crypto.params.AsymmetricKeyParameter;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPKeyPair;
import org.bouncycastle.openpgp.PGPPrivateKey;
import org.bouncycastle.openpgp.PGPPublicKey;
public class BcPGPKeyPair
extends PGPKeyPair
{
private static PGPPublicKey getPublicKey(int algorithm, AsymmetricKeyParameter pubKey, Date date)
throws PGPException
{
return new BcPGPKeyConverter().getPGPPublicKey(algorithm, pubKey, date);
}
private static PGPPrivateKey getPrivateKey(PGPPublicKey pub, AsymmetricKeyParameter privKey)
throws PGPException
{
return new BcPGPKeyConverter().getPGPPrivateKey(pub, privKey);
}
public BcPGPKeyPair(int algorithm, AsymmetricCipherKeyPair keyPair, Date date)
throws PGPException
{
this.pub = getPublicKey(algorithm, (AsymmetricKeyParameter)keyPair.getPublic(), date);
this.priv = getPrivateKey(this.pub, (AsymmetricKeyParameter)keyPair.getPrivate());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy