Package org.bouncycastle.openpgp.api
Class OpenPGPV6KeyGenerator.WithPrimaryKey
java.lang.Object
org.bouncycastle.openpgp.api.OpenPGPV6KeyGenerator.WithPrimaryKey
- Enclosing class:
OpenPGPV6KeyGenerator
Intermediate builder class.
Constructs an OpenPGP key from a specified primary key.
-
Method Summary
Modifier and TypeMethodDescriptionAdd an encryption-capable subkey to the OpenPGP key.addEncryptionSubkey(char[] passphrase) Add an encryption-capable subkey to the OpenPGP key.addEncryptionSubkey(KeyPairGeneratorCallback keyGenCallback) Add an encryption-capable subkey to the OpenPGP key.addEncryptionSubkey(KeyPairGeneratorCallback keyGenCallback, char[] passphrase) Add an encryption-capable subkey to the OpenPGP key.addEncryptionSubkey(KeyPairGeneratorCallback generatorCallback, SignatureSubpacketsFunction bindingSubpacketsCallback) Add an encryption-capable subkey to the OpenPGP key.addEncryptionSubkey(KeyPairGeneratorCallback keyGenCallback, SignatureSubpacketsFunction bindingSignatureCallback, char[] passphrase) Add an encryption-capable subkey to the OpenPGP key.addEncryptionSubkey(PGPKeyPair encryptionSubkey, SignatureSubpacketsFunction bindingSubpacketsCallback, PBESecretKeyEncryptor keyEncryptor) Add an encryption-capable subkey to the OpenPGP key.Add a signing-capable subkey to the OpenPGP key.addSigningSubkey(char[] passphrase) Add a signing-capable subkey to the OpenPGP key.addSigningSubkey(KeyPairGeneratorCallback keyGenCallback) Add a signing-capable subkey to the OpenPGP key.addSigningSubkey(KeyPairGeneratorCallback keyGenCallback, char[] passphrase) Add a signing-capable subkey to the OpenPGP key.addSigningSubkey(KeyPairGeneratorCallback keyGenCallback, SignatureSubpacketsFunction bindingSignatureCallback, SignatureSubpacketsFunction backSignatureCallback, char[] passphrase) Add a signing-capable subkey to the OpenPGP key.addSigningSubkey(PGPKeyPair signingSubkey, SignatureSubpacketsFunction bindingSignatureCallback, SignatureSubpacketsFunction backSignatureCallback, PBESecretKeyEncryptor keyEncryptor) Add a signing-capable subkey to the OpenPGP key.Attach a User-ID with a positive certification to the key.addUserId(String userId, int certificationType, SignatureSubpacketsFunction userIdSubpackets) Attach a User-ID with a positive certification to the key.addUserId(String userId, SignatureSubpacketsFunction userIdSubpackets) Attach a User-ID with a positive certification to the key.build()Build theOpenPGP key, allowing individual passphrases for the subkeys.build(char[] passphrase) Build theOpenPGP keyusing a single passphrase used to protect all subkeys.protected voidsanitizeKeyEncryptor(PBESecretKeyEncryptor keyEncryptor)
-
Method Details
-
addUserId
Attach a User-ID with a positive certification to the key.- Parameters:
userId- user-id- Returns:
- builder
- Throws:
PGPException- if the user-id cannot be added
-
addUserId
public OpenPGPV6KeyGenerator.WithPrimaryKey addUserId(String userId, SignatureSubpacketsFunction userIdSubpackets) throws PGPException Attach a User-ID with a positive certification to the key. The subpackets of the user-id certification can be modified using the userIdSubpackets callback.- Parameters:
userId- user-iduserIdSubpackets- callback to modify the certification subpackets- Returns:
- builder
- Throws:
PGPException- if the user-id cannot be added
-
addUserId
public OpenPGPV6KeyGenerator.WithPrimaryKey addUserId(String userId, int certificationType, SignatureSubpacketsFunction userIdSubpackets) throws PGPException Attach a User-ID with a positive certification to the key. The subpackets of the user-id certification can be modified using the userIdSubpackets callback.- Parameters:
userId- user-idcertificationType- signature typeuserIdSubpackets- callback to modify the certification subpackets- Returns:
- builder
- Throws:
PGPException- if the user-id cannot be added
-
addEncryptionSubkey
Add an encryption-capable subkey to the OpenPGP key. SeePGPKeyPairGenerator.generateEncryptionSubkey()for the key type.- Returns:
- builder
- Throws:
PGPException- if the key cannot be generated
-
addEncryptionSubkey
public OpenPGPV6KeyGenerator.WithPrimaryKey addEncryptionSubkey(KeyPairGeneratorCallback keyGenCallback) throws PGPException Add an encryption-capable subkey to the OpenPGP key. The type of the subkey can be decided by implementing theKeyPairGeneratorCallback.- Parameters:
keyGenCallback- callback to decide the encryption subkey type- Returns:
- builder
- Throws:
PGPException- if the key cannot be generated
-
addEncryptionSubkey
public OpenPGPV6KeyGenerator.WithPrimaryKey addEncryptionSubkey(KeyPairGeneratorCallback generatorCallback, SignatureSubpacketsFunction bindingSubpacketsCallback) throws PGPException Add an encryption-capable subkey to the OpenPGP key. The type of the subkey can be decided by implementing theKeyPairGeneratorCallback. The binding signature can be modified by implementing theSignatureSubpacketsFunction.- Parameters:
generatorCallback- callback to specify the encryption key type.bindingSubpacketsCallback- nullable callback to modify the binding signature subpackets- Returns:
- builder
- Throws:
PGPException- if the key cannot be generated
-
addEncryptionSubkey
public OpenPGPV6KeyGenerator.WithPrimaryKey addEncryptionSubkey(char[] passphrase) throws PGPException Add an encryption-capable subkey to the OpenPGP key. The subkey will be protected using the provided subkey passphrase. IMPORTANT: The custom subkey passphrase will only be used, if in the final step the key is retrieved usingbuild(). If insteadbuild(char[])is used, the key-specific passphrase is overwritten with the argument passed intobuild(char[]). SeePGPKeyPairGenerator.generateEncryptionSubkey()for the key type.- Parameters:
passphrase- nullable subkey passphrase- Returns:
- builder
- Throws:
PGPException- if the key cannot be generated
-
addEncryptionSubkey
public OpenPGPV6KeyGenerator.WithPrimaryKey addEncryptionSubkey(KeyPairGeneratorCallback keyGenCallback, char[] passphrase) throws PGPException Add an encryption-capable subkey to the OpenPGP key. The key type can be specified by overridingKeyPairGeneratorCallback. The subkey will be protected using the provided subkey passphrase. IMPORTANT: The custom subkey passphrase will only be used, if in the final step the key is retrieved usingbuild(). If insteadbuild(char[])is used, the key-specific passphrase is overwritten with the argument passed intobuild(char[]).- Parameters:
keyGenCallback- callback to specify the key typepassphrase- nullable passphrase for the encryption subkey- Returns:
- builder
- Throws:
PGPException- if the key cannot be generated
-
addEncryptionSubkey
public OpenPGPV6KeyGenerator.WithPrimaryKey addEncryptionSubkey(KeyPairGeneratorCallback keyGenCallback, SignatureSubpacketsFunction bindingSignatureCallback, char[] passphrase) throws PGPException Add an encryption-capable subkey to the OpenPGP key. The key type can be specified by overridingKeyPairGeneratorCallback. The binding signatures subpackets can be modified by overriding theSignatureSubpacketsFunction. The subkey will be protected using the provided subkey passphrase. IMPORTANT: The custom subkey passphrase will only be used, if in the final step the key is retrieved usingbuild(). If insteadbuild(char[])is used, the key-specific passphrase is overwritten with the argument passed intobuild(char[]).- Parameters:
keyGenCallback- callback to specify the key typebindingSignatureCallback- nullable callback to modify the binding signature subpacketspassphrase- nullable passphrase for the encryption subkey- Returns:
- builder
- Throws:
PGPException- if the key cannot be generated
-
addEncryptionSubkey
public OpenPGPV6KeyGenerator.WithPrimaryKey addEncryptionSubkey(PGPKeyPair encryptionSubkey, SignatureSubpacketsFunction bindingSubpacketsCallback, PBESecretKeyEncryptor keyEncryptor) throws PGPException Add an encryption-capable subkey to the OpenPGP key. IMPORTANT: The custom key encryptor will only be used, if in the final step the key is retrieved usingbuild(). If insteadbuild(char[])is used, the key-specific encryptor is overwritten with an encryptor built from the argument passed intobuild(char[]).- Parameters:
encryptionSubkey- encryption subkeybindingSubpacketsCallback- nullable callback to modify the subkey binding signature subpacketskeyEncryptor- nullable encryptor to encrypt the encryption subkey- Returns:
- builder
- Throws:
PGPException- if the key cannot be generated
-
addSigningSubkey
Add a signing-capable subkey to the OpenPGP key. The binding signature will contain a primary-key back-signature. SeePGPKeyPairGenerator.generateSigningSubkey()for the key type.- Returns:
- builder
- Throws:
PGPException- if the key cannot be generated
-
addSigningSubkey
public OpenPGPV6KeyGenerator.WithPrimaryKey addSigningSubkey(KeyPairGeneratorCallback keyGenCallback) throws PGPException Add a signing-capable subkey to the OpenPGP key. The binding signature will contain a primary-key back-signature. The key type can be specified by overridingKeyPairGeneratorCallback.- Parameters:
keyGenCallback- callback to specify the signing-subkey type- Returns:
- builder
- Throws:
PGPException- if the key cannot be generated
-
addSigningSubkey
Add a signing-capable subkey to the OpenPGP key. SeePGPKeyPairGenerator.generateSigningSubkey()for the key type. The binding signature will contain a primary-key back-signature. IMPORTANT: The custom subkey passphrase will only be used, if in the final step the key is retrieved usingbuild(). If insteadbuild(char[])is used, the key-specific passphrase is overwritten with the argument passed intobuild(char[]).- Parameters:
passphrase- nullable passphrase- Returns:
- builder
- Throws:
PGPException- if the key cannot be generated
-
addSigningSubkey
public OpenPGPV6KeyGenerator.WithPrimaryKey addSigningSubkey(KeyPairGeneratorCallback keyGenCallback, char[] passphrase) throws PGPException Add a signing-capable subkey to the OpenPGP key. The signing-key type can be specified by overriding theKeyPairGeneratorCallback. The binding signature will contain a primary-key back-signature. IMPORTANT: The custom subkey passphrase will only be used, if in the final step the key is retrieved usingbuild(). If insteadbuild(char[])is used, the key-specific passphrase is overwritten with the argument passed intobuild(char[]).- Parameters:
keyGenCallback- callback to specify the signing-key typepassphrase- nullable passphrase- Returns:
- builder
- Throws:
PGPException- if the key cannot be generated
-
addSigningSubkey
public OpenPGPV6KeyGenerator.WithPrimaryKey addSigningSubkey(KeyPairGeneratorCallback keyGenCallback, SignatureSubpacketsFunction bindingSignatureCallback, SignatureSubpacketsFunction backSignatureCallback, char[] passphrase) throws PGPException Add a signing-capable subkey to the OpenPGP key. The signing-key type can be specified by overriding theKeyPairGeneratorCallback. The binding signature will contain a primary-key back-signature. The contents of the binding signature(s) can be modified by overriding the respectiveSignatureSubpacketsFunctioninstances. IMPORTANT: The custom subkey passphrase will only be used, if in the final step the key is retrieved usingbuild(). If insteadbuild(char[])is used, the key-specific passphrase is overwritten with the argument passed intobuild(char[]).- Parameters:
keyGenCallback- callback to specify the signing-key typebindingSignatureCallback- callback to modify the contents of the signing subkey binding signaturebackSignatureCallback- callback to modify the contents of the embedded primary key binding signaturepassphrase- nullable passphrase- Returns:
- builder
- Throws:
PGPException- if the key cannot be generated
-
addSigningSubkey
public OpenPGPV6KeyGenerator.WithPrimaryKey addSigningSubkey(PGPKeyPair signingSubkey, SignatureSubpacketsFunction bindingSignatureCallback, SignatureSubpacketsFunction backSignatureCallback, PBESecretKeyEncryptor keyEncryptor) throws PGPException Add a signing-capable subkey to the OpenPGP key. The signing-key type can be specified by overriding theKeyPairGeneratorCallback. The binding signature will contain a primary-key back-signature. The contents of the binding signature(s) can be modified by overriding the respectiveSignatureSubpacketsFunctioninstances. IMPORTANT: The custom key encryptor will only be used, if in the final step the key is retrieved usingbuild(). If insteadbuild(char[])is used, the key-specific encryptor is overwritten with an encryptor built from the argument passed intobuild(char[]).- Parameters:
signingSubkey- signing subkeybindingSignatureCallback- callback to modify the contents of the signing subkey binding signaturebackSignatureCallback- callback to modify the contents of the embedded primary key binding signaturekeyEncryptor- nullable encryptor to protect the signing subkey- Returns:
- builder
- Throws:
PGPException- if the key cannot be generated
-
build
Build theOpenPGP key, allowing individual passphrases for the subkeys.- Returns:
- OpenPGP key
- Throws:
PGPException- if the key cannot be generated
-
build
Build theOpenPGP keyusing a single passphrase used to protect all subkeys. The passphrase will override whichever key protectors were specified in previous builder steps.- Parameters:
passphrase- nullable passphrase- Returns:
- OpenPGP key
- Throws:
PGPException- if the key cannot be generated
-
sanitizeKeyEncryptor
-