public abstract class PGPKeyPairGenerator
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected java.util.Date |
creationTime |
protected KeyFingerPrintCalculator |
fingerPrintCalculator |
protected java.security.SecureRandom |
random |
protected int |
version |
| Constructor and Description |
|---|
PGPKeyPairGenerator(int version,
java.util.Date creationTime,
java.security.SecureRandom random,
KeyFingerPrintCalculator fingerPrintCalculator)
Create an instance of the key pair generator.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkPQCKeyVersion(int algorithm)
Check that the generator's key version may carry the given RFC 9980 algorithm (sec. 3.5).
|
PGPKeyPair |
generateBrainpoolP256r1ECDHKeyPair()
Generate an ECDH elliptic curve encryption key over the brainpoolP256r1 curve.
|
PGPKeyPair |
generateBrainpoolP256r1ECDSAKeyPair()
Generate an ECDSA elliptic curve signing key over the brainpoolP256r1 curve.
|
PGPKeyPair |
generateBrainpoolP384r1ECDHKeyPair()
Generate an ECDH elliptic curve encryption key over the brainpoolP384r1 curve.
|
PGPKeyPair |
generateBrainpoolP384r1ECDSAKeyPair()
Generate an ECDSA elliptic curve signing key over the brainpoolP384r1 curve.
|
PGPKeyPair |
generateBrainpoolP512r1ECDHKeyPair()
Generate an ECDH elliptic curve encryption key over the brainpoolP512r1 curve.
|
PGPKeyPair |
generateBrainpoolP512r1ECDSAKeyPair()
Generate an ECDSA elliptic curve signing key over the brainpoolP512r1 curve.
|
abstract PGPKeyPair |
generateECDHKeyPair(org.bouncycastle.asn1.ASN1ObjectIdentifier curveOID)
Generate an elliptic curve Diffie-Hellman encryption key pair over the curve identified by the given OID.
|
abstract PGPKeyPair |
generateECDSAKeyPair(org.bouncycastle.asn1.ASN1ObjectIdentifier curveOID)
Generate an elliptic curve signing key over the curve identified by the given OID.
|
abstract PGPKeyPair |
generateEd25519KeyPair()
Generate an elliptic curve signing key over the twisted Edwards curve25519.
|
abstract PGPKeyPair |
generateEd448KeyPair()
Generate an elliptic curve signing key over the twisted Edwards curve448.
|
PGPKeyPair |
generateEncryptionSubkey()
Generate an encryption subkey.
|
abstract PGPKeyPair |
generateLegacyEd25519KeyPair()
Generate a legacy elliptic curve signing key pair over the twisted Edwards curve25519.
|
abstract PGPKeyPair |
generateLegacyX25519KeyPair()
Generate a legacy elliptic curve Diffie-Hellman encryption key pair over curve25519.
|
PGPKeyPair |
generateMLDSA65Ed25519KeyPair()
Generate an ML-DSA-65 + Ed25519 composite signing key pair
(
PublicKeyAlgorithmTags.MLDSA65_Ed25519, RFC 9980 sec. 5). |
PGPKeyPair |
generateMLDSA87Ed448KeyPair()
Generate an ML-DSA-87 + Ed448 composite signing key pair
(
PublicKeyAlgorithmTags.MLDSA87_Ed448, RFC 9980 sec. 5). |
PGPKeyPair |
generateMLKEM1024X448KeyPair()
Generate an ML-KEM-1024 + X448 composite encryption key pair
(
PublicKeyAlgorithmTags.MLKEM1024_X448, RFC 9980 sec. 4). |
PGPKeyPair |
generateMLKEM768X25519KeyPair()
Generate an ML-KEM-768 + X25519 composite encryption key pair
(
PublicKeyAlgorithmTags.MLKEM768_X25519, RFC 9980 sec. 4). |
PGPKeyPair |
generateNistP256ECDHKeyPair()
Generate an ECDH elliptic curve encryption key over the NIST p-256 curve.
|
PGPKeyPair |
generateNistP256ECDSAKeyPair()
Generate an ECDSA elliptic curve signing key over the NIST p-256 curve.
|
PGPKeyPair |
generateNistP384ECDHKeyPair()
Generate an ECDH elliptic curve encryption key over the NIST p-384 curve.
|
PGPKeyPair |
generateNistP384ECDSAKeyPair()
Generate an ECDSA elliptic curve signing key over the NIST p-384 curve.
|
PGPKeyPair |
generateNistP521ECDHKeyPair()
Generate an ECDH elliptic curve encryption key over the NIST p-521 curve.
|
PGPKeyPair |
generateNistP521ECDSAKeyPair()
Generate an ECDSA elliptic curve signing key over the NIST p-521 curve.
|
PGPKeyPair |
generatePrimaryKey()
Generate a primary key.
|
abstract PGPKeyPair |
generateRsaKeyPair(java.math.BigInteger exponent,
int bitStrength)
Generate a RSA key pair with the given bit-strength over a custom exponent.
|
PGPKeyPair |
generateRsaKeyPair(int bitStrength)
Generate a RSA key pair with the given bit-strength.
|
PGPKeyPair |
generateSigningSubkey()
Generate a signing subkey.
|
PGPKeyPair |
generateSLHDSAShake128fKeyPair()
Generate an SLH-DSA-SHAKE-128f signing key pair (
PublicKeyAlgorithmTags.SLHDSA_SHAKE_128f,
RFC 9980 sec. 6). |
PGPKeyPair |
generateSLHDSAShake128sKeyPair()
Generate an SLH-DSA-SHAKE-128s signing key pair (
PublicKeyAlgorithmTags.SLHDSA_SHAKE_128s,
RFC 9980 sec. 6). |
PGPKeyPair |
generateSLHDSAShake256sKeyPair()
Generate an SLH-DSA-SHAKE-256s signing key pair (
PublicKeyAlgorithmTags.SLHDSA_SHAKE_256s,
RFC 9980 sec. 6). |
abstract PGPKeyPair |
generateX25519KeyPair()
Generate an elliptic curve Diffie-Hellman encryption key over curve25519.
|
abstract PGPKeyPair |
generateX448KeyPair()
Generate an elliptic curve Diffie-Hellman encryption key over curve448.
|
protected final java.util.Date creationTime
protected final int version
protected java.security.SecureRandom random
protected final KeyFingerPrintCalculator fingerPrintCalculator
public PGPKeyPairGenerator(int version,
java.util.Date creationTime,
java.security.SecureRandom random,
KeyFingerPrintCalculator fingerPrintCalculator)
version - public key version (PublicKeyPacket.VERSION_4
or PublicKeyPacket.VERSION_6).creationTime - key creation timerandom - secure random number generatorpublic PGPKeyPair generatePrimaryKey() throws PGPException
PGPException - if the key pair cannot be generatedpublic PGPKeyPair generateEncryptionSubkey() throws PGPException
PGPException - if the key pair cannot be generatedpublic PGPKeyPair generateSigningSubkey() throws PGPException
PGPException - if the key pair cannot be generatedpublic PGPKeyPair generateRsaKeyPair(int bitStrength) throws PGPException
65537.
RSA keys are deprecated for OpenPGP v6.bitStrength - strength of the key pair in bitsPGPException - if the key pair cannot be generatedpublic abstract PGPKeyPair generateRsaKeyPair(java.math.BigInteger exponent, int bitStrength) throws PGPException
exponent - RSA exponent ebitStrength - strength of the key pair in bitsPGPException - if the key pair cannot be generatedpublic abstract PGPKeyPair generateEd25519KeyPair() throws PGPException
PublicKeyAlgorithmTags.Ed25519 which was introduced with RFC9580.
For legacy Ed25519 keys use generateLegacyEd25519KeyPair().PGPException - if the key pair cannot be generatedpublic abstract PGPKeyPair generateEd448KeyPair() throws PGPException
PublicKeyAlgorithmTags.Ed448 which was introduced with RFC9580.PGPException - if the key pair cannot be generatedpublic abstract PGPKeyPair generateX25519KeyPair() throws PGPException
PublicKeyAlgorithmTags.X25519 which was introduced with RFC9580.
For legacy X25519 keys use generateLegacyX25519KeyPair() instead.PGPException - if the key pair cannot be generatedpublic abstract PGPKeyPair generateX448KeyPair() throws PGPException
PublicKeyAlgorithmTags.X448 which was introduced with RFC9580.PGPException - if the key pair cannot be generatedpublic abstract PGPKeyPair generateLegacyEd25519KeyPair() throws PGPException
PublicKeyAlgorithmTags.EDDSA_LEGACY as algorithm ID.
For OpenPGP v6 (RFC9580) use generateEd25519KeyPair() instead.PGPException - if the key pair cannot be generatedpublic abstract PGPKeyPair generateLegacyX25519KeyPair() throws PGPException
PublicKeyAlgorithmTags.ECDH as algorithm ID.
For OpenPGP v6 (RFC9580) use generateX25519KeyPair() instead.PGPException - if the key pair cannot be generatedpublic PGPKeyPair generateNistP256ECDHKeyPair() throws PGPException
NIST P-256 is equivalent to prime256v1 and secp256r1.PGPException - if the key pair cannot be generatedpublic PGPKeyPair generateNistP384ECDHKeyPair() throws PGPException
NIST P-384 is equivalent to secp384r1.PGPException - if the key pair cannot be generatedpublic PGPKeyPair generateNistP521ECDHKeyPair() throws PGPException
NIST P-521 is equivalent to secp521r1.PGPException - if the key pair cannot be generatedpublic PGPKeyPair generateBrainpoolP256r1ECDHKeyPair() throws PGPException
PGPException - if the key pair cannot be generatedpublic PGPKeyPair generateBrainpoolP384r1ECDHKeyPair() throws PGPException
PGPException - if the key pair cannot be generatedpublic PGPKeyPair generateBrainpoolP512r1ECDHKeyPair() throws PGPException
PGPException - if the key pair cannot be generatedpublic PGPKeyPair generateNistP256ECDSAKeyPair() throws PGPException
NIST P-256 is equivalent to prime256v1 and secp256r1.PGPException - if the key pair cannot be generatedpublic PGPKeyPair generateNistP384ECDSAKeyPair() throws PGPException
NIST P-384 is equivalent to secp384r1.PGPException - if the key pair cannot be generatedpublic PGPKeyPair generateNistP521ECDSAKeyPair() throws PGPException
NIST P-521 is equivalent to secp521r1.PGPException - if the key pair cannot be generatedpublic PGPKeyPair generateBrainpoolP256r1ECDSAKeyPair() throws PGPException
PGPException - if the key pair cannot be generatedpublic PGPKeyPair generateBrainpoolP384r1ECDSAKeyPair() throws PGPException
PGPException - if the key pair cannot be generatedpublic PGPKeyPair generateBrainpoolP512r1ECDSAKeyPair() throws PGPException
PGPException - if the key pair cannot be generatedpublic PGPKeyPair generateMLDSA65Ed25519KeyPair() throws PGPException
PublicKeyAlgorithmTags.MLDSA65_Ed25519, RFC 9980 sec. 5). The two component keys are generated
independently, as RFC 9980 sec. 5.2.1 requires. Only version 6 keys may use this algorithm.PGPException - if the key pair cannot be generated, or the generator is for a key version other than 6public PGPKeyPair generateMLDSA87Ed448KeyPair() throws PGPException
PublicKeyAlgorithmTags.MLDSA87_Ed448, RFC 9980 sec. 5). The two component keys are generated
independently, as RFC 9980 sec. 5.2.1 requires. Only version 6 keys may use this algorithm.PGPException - if the key pair cannot be generated, or the generator is for a key version other than 6public PGPKeyPair generateSLHDSAShake128sKeyPair() throws PGPException
PublicKeyAlgorithmTags.SLHDSA_SHAKE_128s,
RFC 9980 sec. 6). Only version 6 keys may use this algorithm.PGPException - if the key pair cannot be generated, or the generator is for a key version other than 6public PGPKeyPair generateSLHDSAShake128fKeyPair() throws PGPException
PublicKeyAlgorithmTags.SLHDSA_SHAKE_128f,
RFC 9980 sec. 6). Only version 6 keys may use this algorithm.PGPException - if the key pair cannot be generated, or the generator is for a key version other than 6public PGPKeyPair generateSLHDSAShake256sKeyPair() throws PGPException
PublicKeyAlgorithmTags.SLHDSA_SHAKE_256s,
RFC 9980 sec. 6). Only version 6 keys may use this algorithm.PGPException - if the key pair cannot be generated, or the generator is for a key version other than 6public PGPKeyPair generateMLKEM768X25519KeyPair() throws PGPException
PublicKeyAlgorithmTags.MLKEM768_X25519, RFC 9980 sec. 4). The two component keys are generated
independently, as RFC 9980 sec. 4.2.2 requires. The algorithm may be used with version 6 keys and, as the
single exception among the PQ(/T) algorithms, with version 4 encryption subkeys.PGPException - if the key pair cannot be generated, or the generator is for a key version other than 4 or 6public PGPKeyPair generateMLKEM1024X448KeyPair() throws PGPException
PublicKeyAlgorithmTags.MLKEM1024_X448, RFC 9980 sec. 4). The two component keys are generated
independently, as RFC 9980 sec. 4.2.2 requires. Only version 6 keys may use this algorithm.PGPException - if the key pair cannot be generated, or the generator is for a key version other than 6protected void checkPQCKeyVersion(int algorithm)
throws PGPException
algorithm - public key algorithm IDPGPException - if the key version is not permitted for the algorithmpublic abstract PGPKeyPair generateECDHKeyPair(org.bouncycastle.asn1.ASN1ObjectIdentifier curveOID) throws PGPException
curveOID - OID of the elliptic curvePGPException - if the key pair cannot be generatedpublic abstract PGPKeyPair generateECDSAKeyPair(org.bouncycastle.asn1.ASN1ObjectIdentifier curveOID) throws PGPException
curveOID - OID of the elliptic curvePGPException - if the key pair cannot be generated