Package org.bouncycastle.openpgp.api
Class OpenPGPKeyGenerator
java.lang.Object
org.bouncycastle.openpgp.api.AbstractOpenPGPKeySignatureGenerator
org.bouncycastle.openpgp.api.OpenPGPKeyGenerator
- Direct Known Subclasses:
BcOpenPGPKeyGenerator,JcaOpenPGPKeyGenerator
High-level generator class for OpenPGP v6 keys.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassIntermediate builder class. -
Field Summary
Fields inherited from class org.bouncycastle.openpgp.api.AbstractOpenPGPKeySignatureGenerator
defaultAeadAlgorithmPreferences, defaultCompressionAlgorithmPreferences, defaultFeatures, defaultHashAlgorithmPreferences, defaultSymmetricKeyPreferences, directKeySignatureSubpackets, encryptionSubkeySubpackets, signingSubkeySubpackets -
Constructor Summary
ConstructorsConstructorDescriptionOpenPGPKeyGenerator(OpenPGPImplementation implementation, boolean aead, Date creationTime) OpenPGPKeyGenerator(OpenPGPImplementation implementationProvider, int version, boolean aead, Date creationTime) OpenPGPKeyGenerator(OpenPGPImplementation implementationProvider, int keyVersion, PGPKeyPairGeneratorProvider kpGenProvider, PGPDigestCalculatorProvider digestCalculatorProvider, PBESecretKeyEncryptorFactory keyEncryptionBuilderProvider, KeyFingerPrintCalculator keyFingerPrintCalculator, Date creationTime) Generate a new OpenPGP key generator for v6 keys. -
Method Summary
Modifier and TypeMethodDescriptionclassicKey(String userId) Generate an OpenPGP key consisting of a certify-only primary key, a dedicated signing-subkey and dedicated encryption-subkey.ed25519x25519Key(String userId) Generate an OpenPGP key consisting of an Ed25519 certify-only primary key, a dedicated Ed25519 sign-only subkey and dedicated X25519 encryption-only subkey.ed448x448Key(String userId) Generate an OpenPGP key consisting of an Ed448 certify-only primary key, a dedicated Ed448 sign-only subkey and dedicated X448 encryption-only subkey.Generate a sign-only OpenPGP key.Generate an OpenPGP key with a certification-capable primary key.withPrimaryKey(KeyPairGeneratorCallback keyGenCallback) Generate an OpenPGP key with a certification-capable primary key.withPrimaryKey(KeyPairGeneratorCallback keyGenCallback, SignatureParameters.Callback preferenceSignatureCallback) Generate an OpenPGP key with a certification-capable primary key.Methods inherited from class org.bouncycastle.openpgp.api.AbstractOpenPGPKeySignatureGenerator
setDefaultAeadAlgorithmPreferences, setDefaultCompressionAlgorithmPreferences, setDefaultFeatures, setDefaultHashAlgorithmPreferences, setDefaultSymmetricKeyPreferences, setDirectKeySignatureSubpackets, setEncryptionSubkeySubpackets, setSigningSubkeySubpackets
-
Constructor Details
-
OpenPGPKeyGenerator
public OpenPGPKeyGenerator(OpenPGPImplementation implementation, boolean aead, Date creationTime) throws PGPException - Throws:
PGPException
-
OpenPGPKeyGenerator
public OpenPGPKeyGenerator(OpenPGPImplementation implementationProvider, int version, boolean aead, Date creationTime) throws PGPException - Throws:
PGPException
-
OpenPGPKeyGenerator
public OpenPGPKeyGenerator(OpenPGPImplementation implementationProvider, int keyVersion, PGPKeyPairGeneratorProvider kpGenProvider, PGPDigestCalculatorProvider digestCalculatorProvider, PBESecretKeyEncryptorFactory keyEncryptionBuilderProvider, KeyFingerPrintCalculator keyFingerPrintCalculator, Date creationTime) Generate a new OpenPGP key generator for v6 keys.- Parameters:
kpGenProvider- key pair generator providerdigestCalculatorProvider- digest calculator providerkeyEncryptionBuilderProvider- secret key encryption builder provider (AEAD)keyFingerPrintCalculator- calculator for key fingerprintscreationTime- key creation time
-
-
Method Details
-
classicKey
Generate an OpenPGP key consisting of a certify-only primary key, a dedicated signing-subkey and dedicated encryption-subkey. The key will optionally carry the provided user-id. SeePGPKeyPairGenerator.generatePrimaryKey()for the primary key type,PGPKeyPairGenerator.generateSigningSubkey()for the signing-subkey type andPGPKeyPairGenerator.generateEncryptionSubkey()for the encryption-subkey key type.- Parameters:
userId- nullable user id- Returns:
- OpenPGP key
- Throws:
PGPException- if the key cannot be prepared
-
ed25519x25519Key
Generate an OpenPGP key consisting of an Ed25519 certify-only primary key, a dedicated Ed25519 sign-only subkey and dedicated X25519 encryption-only subkey. The key will optionally carry the provided user-id.- Parameters:
userId- nullable user id- Returns:
- OpenPGP key
- Throws:
PGPException- if the key cannot be generated
-
ed448x448Key
Generate an OpenPGP key consisting of an Ed448 certify-only primary key, a dedicated Ed448 sign-only subkey and dedicated X448 encryption-only subkey. The key will optionally carry the provided user-id.- Parameters:
userId- nullable user id- Returns:
- OpenPGP key
- Throws:
PGPException- if the key cannot be generated
-
signOnlyKey
Generate a sign-only OpenPGP key. The key consists of a single, user-id-less primary key, which is capable of signing and certifying. SeePGPKeyPairGenerator.generatePrimaryKey()for the key type.- Returns:
- sign-only (+certify) OpenPGP key
- Throws:
PGPException- if the key cannot be generated
-
withPrimaryKey
Generate an OpenPGP key with a certification-capable primary key. SeePGPKeyPairGenerator.generatePrimaryKey()for the primary key type- Returns:
- builder
- Throws:
PGPException- if the key cannot be generated
-
withPrimaryKey
public OpenPGPKeyGenerator.WithPrimaryKey withPrimaryKey(KeyPairGeneratorCallback keyGenCallback) throws PGPException Generate an OpenPGP key with a certification-capable primary key. The primary key type can be decided using theKeyPairGeneratorCallback.- Parameters:
keyGenCallback- callback to decide the key type- Returns:
- builder
- Throws:
PGPException- if the key cannot be generated
-
withPrimaryKey
public OpenPGPKeyGenerator.WithPrimaryKey withPrimaryKey(KeyPairGeneratorCallback keyGenCallback, SignatureParameters.Callback preferenceSignatureCallback) throws PGPException Generate an OpenPGP key with a certification-capable primary key. The primary key type can be decided using theKeyPairGeneratorCallback. TheSignatureParameters.Callbackcan be used to modify the preferences in the direct-key self signature. If the callback itself is null, the generator will create a default direct-key signature. If the result ofSignatureParameters.Callback.apply(SignatureParameters)is null, no direct-key signature will be generated for the key.- Parameters:
keyGenCallback- callback to decide the key typepreferenceSignatureCallback- callback to modify the direct-key signature- Returns:
- builder
- Throws:
PGPException- if the key cannot be generated
-