Package org.bouncycastle.openpgp
Class PGPKeyRingGenerator
java.lang.Object
org.bouncycastle.openpgp.PGPKeyRingGenerator
Generator for a PGP primary and subkey ring. This class will generate
both the secret and public key rings
-
Constructor Summary
ConstructorsConstructorDescriptionPGPKeyRingGenerator(int certificationLevel, PGPKeyPair primaryKey, String id, PGPDigestCalculator checksumCalculator, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks, PGPContentSignerBuilder keySignerBuilder, PBESecretKeyEncryptor keyEncryptor) Create a new key ring generator.PGPKeyRingGenerator(PGPKeyPair primaryKey, PGPDigestCalculator checksumCalculator, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks, PGPContentSignerBuilder keySignerBuilder, PBESecretKeyEncryptor keyEncryptor) Create a new key ring generator without a user-id, but instead with a primary key carrying a direct-key signature.PGPKeyRingGenerator(PGPSecretKeyRing originalSecretRing, PBESecretKeyDecryptor secretKeyDecryptor, PGPDigestCalculator checksumCalculator, PGPContentSignerBuilder keySignerBuilder, PBESecretKeyEncryptor keyEncryptor) Create a new key ring generator based on an original secret key ring. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSubKey(PGPKeyPair keyPair) Add a sub key to the key ring to be generated with default certification and inheriting the hashed/unhashed packets of the primary key.voidaddSubKey(PGPKeyPair keyPair, PGPContentSignerBuilder bindingSignerBldr) Add a sub key to the key ring to be generated with default certification and inheriting the hashed/unhashed packets of the primary key.voidaddSubKey(PGPKeyPair keyPair, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks) Add a subkey with specific hashed and unhashed packets associated with it and default certification.voidaddSubKey(PGPKeyPair keyPair, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks, PGPContentSignerBuilder bindingSignerBldr) Add a subkey with specific hashed and unhashed packets associated with it and default certification.Return the public key ring that corresponds to the secret key ring.Return the secret key ring.
-
Constructor Details
-
PGPKeyRingGenerator
public PGPKeyRingGenerator(int certificationLevel, PGPKeyPair primaryKey, String id, PGPDigestCalculator checksumCalculator, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks, PGPContentSignerBuilder keySignerBuilder, PBESecretKeyEncryptor keyEncryptor) throws PGPException Create a new key ring generator.- Parameters:
certificationLevel- certification level for user-idsprimaryKey- primary keyid- id to associate with the key.checksumCalculator- key checksum calculatorhashedPcks- hashed signature subpacketsunhashedPcks- unhashed signature subpacketskeySignerBuilder- builder for key certifications - will be initialised with primary secret key.keyEncryptor- encryptor for secret subkeys.- Throws:
PGPException- error during signature generation
-
PGPKeyRingGenerator
public PGPKeyRingGenerator(PGPKeyPair primaryKey, PGPDigestCalculator checksumCalculator, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks, PGPContentSignerBuilder keySignerBuilder, PBESecretKeyEncryptor keyEncryptor) throws PGPException Create a new key ring generator without a user-id, but instead with a primary key carrying a direct-key signature.- Parameters:
primaryKey- primary keychecksumCalculator- checksum calculatorhashedPcks- hashed signature subpacketsunhashedPcks- unhashed signature subpacketskeySignerBuilder- signer builderkeyEncryptor- key encryptor- Throws:
PGPException- error during signature generation
-
PGPKeyRingGenerator
public PGPKeyRingGenerator(PGPSecretKeyRing originalSecretRing, PBESecretKeyDecryptor secretKeyDecryptor, PGPDigestCalculator checksumCalculator, PGPContentSignerBuilder keySignerBuilder, PBESecretKeyEncryptor keyEncryptor) throws PGPException Create a new key ring generator based on an original secret key ring. The default hashed/unhashed sub-packets for subkey signatures will be inherited from the first signature on the primary key (other than CREATION-TIME which will be ignored).- Parameters:
originalSecretRing- the secret key ring we want to add a subkeyto,secretKeyDecryptor- a decryptor for the signing primary key.checksumCalculator- key checksum calculatorkeySignerBuilder- builder for key certifications - will be initialised with primary secret key.keyEncryptor- encryptor for secret subkeys.- Throws:
PGPException- error during signature generation
-
-
Method Details
-
addSubKey
Add a sub key to the key ring to be generated with default certification and inheriting the hashed/unhashed packets of the primary key.- Parameters:
keyPair- the key pair to add.- Throws:
PGPException- error during signature generation
-
addSubKey
public void addSubKey(PGPKeyPair keyPair, PGPContentSignerBuilder bindingSignerBldr) throws PGPException Add a sub key to the key ring to be generated with default certification and inheriting the hashed/unhashed packets of the primary key. If bindingSignerBldr is not null it will be used to add a Primary Key Binding signature (type 0x19) into the hashedPcks for the key (required for signing subkeys).- Parameters:
keyPair- the key pair to add.bindingSignerBldr- provide a signing builder to create the Primary Key signature.- Throws:
PGPException- error during signature generation
-
addSubKey
public void addSubKey(PGPKeyPair keyPair, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks) throws PGPException Add a subkey with specific hashed and unhashed packets associated with it and default certification.- Parameters:
keyPair- public/private key pair.hashedPcks- hashed packet values to be included in certification.unhashedPcks- unhashed packets values to be included in certification.- Throws:
PGPException- error during signature generation
-
addSubKey
public void addSubKey(PGPKeyPair keyPair, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks, PGPContentSignerBuilder bindingSignerBldr) throws PGPException Add a subkey with specific hashed and unhashed packets associated with it and default certification. If bindingSignerBldr is not null it will be used to add a Primary Key Binding signature (type 0x19) into the hashedPcks for the key (required for signing subkeys).- Parameters:
keyPair- public/private key pair.hashedPcks- hashed packet values to be included in certification.unhashedPcks- unhashed packets values to be included in certification.bindingSignerBldr- provide a signing builder to create the Primary Key signature.- Throws:
PGPException- error during signature generation
-
generateSecretKeyRing
Return the secret key ring.- Returns:
- a secret key ring.
-
generatePublicKeyRing
Return the public key ring that corresponds to the secret key ring.- Returns:
- a public key ring.
-