Package org.bouncycastle.openpgp.api
Class OpenPGPV6KeyGenerator.WithPrimaryKey
- java.lang.Object
-
- org.bouncycastle.openpgp.api.OpenPGPV6KeyGenerator.WithPrimaryKey
-
- Enclosing class:
- OpenPGPV6KeyGenerator
public static class OpenPGPV6KeyGenerator.WithPrimaryKey extends java.lang.ObjectIntermediate builder class. Constructs an OpenPGP key from a specified primary key.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description OpenPGPV6KeyGenerator.WithPrimaryKeyaddEncryptionSubkey()Add an encryption-capable subkey to the OpenPGP key.OpenPGPV6KeyGenerator.WithPrimaryKeyaddEncryptionSubkey(char[] passphrase)Add an encryption-capable subkey to the OpenPGP key.OpenPGPV6KeyGenerator.WithPrimaryKeyaddEncryptionSubkey(KeyPairGeneratorCallback keyGenCallback)Add an encryption-capable subkey to the OpenPGP key.OpenPGPV6KeyGenerator.WithPrimaryKeyaddEncryptionSubkey(KeyPairGeneratorCallback keyGenCallback, char[] passphrase)Add an encryption-capable subkey to the OpenPGP key.OpenPGPV6KeyGenerator.WithPrimaryKeyaddEncryptionSubkey(KeyPairGeneratorCallback generatorCallback, SignatureSubpacketsFunction bindingSubpacketsCallback)Add an encryption-capable subkey to the OpenPGP key.OpenPGPV6KeyGenerator.WithPrimaryKeyaddEncryptionSubkey(KeyPairGeneratorCallback keyGenCallback, SignatureSubpacketsFunction bindingSignatureCallback, char[] passphrase)Add an encryption-capable subkey to the OpenPGP key.OpenPGPV6KeyGenerator.WithPrimaryKeyaddEncryptionSubkey(PGPKeyPair encryptionSubkey, SignatureSubpacketsFunction bindingSubpacketsCallback, PBESecretKeyEncryptor keyEncryptor)Add an encryption-capable subkey to the OpenPGP key.OpenPGPV6KeyGenerator.WithPrimaryKeyaddSigningSubkey()Add a signing-capable subkey to the OpenPGP key.OpenPGPV6KeyGenerator.WithPrimaryKeyaddSigningSubkey(char[] passphrase)Add a signing-capable subkey to the OpenPGP key.OpenPGPV6KeyGenerator.WithPrimaryKeyaddSigningSubkey(KeyPairGeneratorCallback keyGenCallback)Add a signing-capable subkey to the OpenPGP key.OpenPGPV6KeyGenerator.WithPrimaryKeyaddSigningSubkey(KeyPairGeneratorCallback keyGenCallback, char[] passphrase)Add a signing-capable subkey to the OpenPGP key.OpenPGPV6KeyGenerator.WithPrimaryKeyaddSigningSubkey(KeyPairGeneratorCallback keyGenCallback, SignatureSubpacketsFunction bindingSignatureCallback, SignatureSubpacketsFunction backSignatureCallback, char[] passphrase)Add a signing-capable subkey to the OpenPGP key.OpenPGPV6KeyGenerator.WithPrimaryKeyaddSigningSubkey(PGPKeyPair signingSubkey, SignatureSubpacketsFunction bindingSignatureCallback, SignatureSubpacketsFunction backSignatureCallback, PBESecretKeyEncryptor keyEncryptor)Add a signing-capable subkey to the OpenPGP key.OpenPGPV6KeyGenerator.WithPrimaryKeyaddUserId(java.lang.String userId)Attach a User-ID with a positive certification to the key.OpenPGPV6KeyGenerator.WithPrimaryKeyaddUserId(java.lang.String userId, int certificationType, SignatureSubpacketsFunction userIdSubpackets)Attach a User-ID with a positive certification to the key.OpenPGPV6KeyGenerator.WithPrimaryKeyaddUserId(java.lang.String userId, SignatureSubpacketsFunction userIdSubpackets)Attach a User-ID with a positive certification to the key.PGPSecretKeyRingbuild()Build theOpenPGP key, allowing individual passphrases for the subkeys.PGPSecretKeyRingbuild(char[] passphrase)Build theOpenPGP keyusing a single passphrase used to protect all subkeys.protected voidsanitizeKeyEncryptor(PBESecretKeyEncryptor keyEncryptor)
-
-
-
Method Detail
-
addUserId
public OpenPGPV6KeyGenerator.WithPrimaryKey addUserId(java.lang.String userId) throws PGPException
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(java.lang.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(java.lang.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
public OpenPGPV6KeyGenerator.WithPrimaryKey addEncryptionSubkey() throws PGPException
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
public OpenPGPV6KeyGenerator.WithPrimaryKey addSigningSubkey() throws PGPException
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
public OpenPGPV6KeyGenerator.WithPrimaryKey addSigningSubkey(char[] passphrase) throws PGPException
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
public PGPSecretKeyRing build() throws PGPException
Build theOpenPGP key, allowing individual passphrases for the subkeys.- Returns:
- OpenPGP key
- Throws:
PGPException- if the key cannot be generated
-
build
public PGPSecretKeyRing build(char[] passphrase) throws PGPException
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
protected void sanitizeKeyEncryptor(PBESecretKeyEncryptor keyEncryptor)
-
-