Top Description Fields Constructors Methods
org.bouncycastle.openpgp

public Class PGPKeyRingGenerator

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Iterator, .List, org.bouncycastle.asn1.cryptlib.CryptlibObjectIdentifiers, org.bouncycastle.bcpg.ECPublicBCPGKey, .PublicKeyAlgorithmTags, .PublicKeyPacket, .PublicSubkeyPacket, .SignatureSubpacket, .SignatureSubpacketTags, org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor, .PBESecretKeyEncryptor, .PGPContentSignerBuilder, .PGPDigestCalculator

Generator for a PGP primary and subkey ring. This class will generate both the secret and public key rings

Field Summary

Modifier and TypeField and Description
private final PGPDigestCalculator
private final PGPSignatureSubpacketVector
private final PBESecretKeyEncryptor
private final List<PGPSecretKey>
private final PGPContentSignerBuilder
private final PGPKeyPair
private final PGPSignatureSubpacketVector

Constructor Summary

AccessConstructor and Description
public
PGPKeyRingGenerator(int
certification level for user-ids
certificationLevel
,
PGPKeyPair
primary key
primaryKey
,
String
id to associate with the key.
id
,
PGPDigestCalculator
key checksum calculator
checksumCalculator
,
PGPSignatureSubpacketVector
hashed signature subpackets
hashedPcks
,
PGPSignatureSubpacketVector
unhashed signature subpackets
unhashedPcks
,
PGPContentSignerBuilder
builder for key certifications - will be initialised with primary secret key.
keySignerBuilder
,
PBESecretKeyEncryptor
encryptor for secret subkeys.
keyEncryptor
)

Create a new key ring generator.

public
PGPKeyRingGenerator(PGPKeyPair
primary key
primaryKey
,
PGPDigestCalculator
checksum calculator
checksumCalculator
,
PGPSignatureSubpacketVector
hashed signature subpackets
hashedPcks
,
PGPSignatureSubpacketVector
unhashed signature subpackets
unhashedPcks
,
PGPContentSignerBuilder
signer builder
keySignerBuilder
,
PBESecretKeyEncryptor
key encryptor
keyEncryptor
)

Create a new key ring generator without a user-id, but instead with a primary key carrying a direct-key signature.

public
PGPKeyRingGenerator(PGPSecretKeyRing
the secret key ring we want to add a subkeyto,
originalSecretRing
,
PBESecretKeyDecryptor
a decryptor for the signing primary key.
secretKeyDecryptor
,
PGPDigestCalculator
key checksum calculator
checksumCalculator
,
PGPContentSignerBuilder
builder for key certifications - will be initialised with primary secret key.
keySignerBuilder
,
PBESecretKeyEncryptor
encryptor for secret subkeys.
keyEncryptor
)

Create a new key ring generator based on an original secret key ring.

Method Summary

Modifier and TypeMethod and Description
public void
addSubKey(PGPKeyPair
the key pair to add.
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.

public void
addSubKey(PGPKeyPair
the key pair to add.
keyPair
,
PGPContentSignerBuilder
provide a signing builder to create the Primary Key signature.
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.

public void
addSubKey(PGPKeyPair
public/private key pair.
keyPair
,
PGPSignatureSubpacketVector
hashed packet values to be included in certification.
hashedPcks
,
PGPSignatureSubpacketVector
unhashed packets values to be included in certification.
unhashedPcks
)

Add a subkey with specific hashed and unhashed packets associated with it and default certification.

public void
addSubKey(PGPKeyPair
public/private key pair.
keyPair
,
PGPSignatureSubpacketVector
hashed packet values to be included in certification.
hashedPcks
,
PGPSignatureSubpacketVector
unhashed packets values to be included in certification.
unhashedPcks
,
PGPContentSignerBuilder
provide a signing builder to create the Primary Key signature.
bindingSignerBldr
)

Add a subkey with specific hashed and unhashed packets associated with it and default certification.

public PGPPublicKeyRing

Returns:

a public key ring.
generatePublicKeyRing
()

Return the public key ring that corresponds to the secret key ring.

public PGPSecretKeyRing

Returns:

a secret key ring.
generateSecretKeyRing
()

Return the secret key ring.

private PGPKeyPair
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

checksumCalculatorback to summary
private final PGPDigestCalculator checksumCalculator
hashedPcksback to summary
private final PGPSignatureSubpacketVector hashedPcks
keyEncryptorback to summary
private final PBESecretKeyEncryptor keyEncryptor
keysback to summary
private final List<PGPSecretKey> keys
keySignerBuilderback to summary
private final PGPContentSignerBuilder keySignerBuilder
primaryKeyback to summary
private final PGPKeyPair primaryKey
unhashedPcksback to summary
private final PGPSignatureSubpacketVector unhashedPcks

Constructor Detail

PGPKeyRingGeneratorback to summary
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:int

certification level for user-ids

primaryKey:PGPKeyPair

primary key

id:String

id to associate with the key.

checksumCalculator:PGPDigestCalculator

key checksum calculator

hashedPcks:PGPSignatureSubpacketVector

hashed signature subpackets

unhashedPcks:PGPSignatureSubpacketVector

unhashed signature subpackets

keySignerBuilder:PGPContentSignerBuilder

builder for key certifications - will be initialised with primary secret key.

keyEncryptor:PBESecretKeyEncryptor

encryptor for secret subkeys.

Exceptions
PGPException:
error during signature generation
PGPKeyRingGeneratorback to summary
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:PGPKeyPair

primary key

checksumCalculator:PGPDigestCalculator

checksum calculator

hashedPcks:PGPSignatureSubpacketVector

hashed signature subpackets

unhashedPcks:PGPSignatureSubpacketVector

unhashed signature subpackets

keySignerBuilder:PGPContentSignerBuilder

signer builder

keyEncryptor:PBESecretKeyEncryptor

key encryptor

Exceptions
PGPException:
error during signature generation
PGPKeyRingGeneratorback to summary
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:PGPSecretKeyRing

the secret key ring we want to add a subkeyto,

secretKeyDecryptor:PBESecretKeyDecryptor

a decryptor for the signing primary key.

checksumCalculator:PGPDigestCalculator

key checksum calculator

keySignerBuilder:PGPContentSignerBuilder

builder for key certifications - will be initialised with primary secret key.

keyEncryptor:PBESecretKeyEncryptor

encryptor for secret subkeys.

Exceptions
PGPException:
error during signature generation

Method Detail

addSubKeyback to summary
public void addSubKey(PGPKeyPair keyPair) 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.

Parameters
keyPair:PGPKeyPair

the key pair to add.

Exceptions
PGPException:
error during signature generation
addSubKeyback to summary
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:PGPKeyPair

the key pair to add.

bindingSignerBldr:PGPContentSignerBuilder

provide a signing builder to create the Primary Key signature.

Exceptions
PGPException:
error during signature generation
addSubKeyback to summary
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:PGPKeyPair

public/private key pair.

hashedPcks:PGPSignatureSubpacketVector

hashed packet values to be included in certification.

unhashedPcks:PGPSignatureSubpacketVector

unhashed packets values to be included in certification.

Exceptions
PGPException:
error during signature generation
addSubKeyback to summary
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:PGPKeyPair

public/private key pair.

hashedPcks:PGPSignatureSubpacketVector

hashed packet values to be included in certification.

unhashedPcks:PGPSignatureSubpacketVector

unhashed packets values to be included in certification.

bindingSignerBldr:PGPContentSignerBuilder

provide a signing builder to create the Primary Key signature.

Exceptions
PGPException:
error during signature generation
generatePublicKeyRingback to summary
public PGPPublicKeyRing generatePublicKeyRing()

Return the public key ring that corresponds to the secret key ring.

Returns:PGPPublicKeyRing

a public key ring.

generateSecretKeyRingback to summary
public PGPSecretKeyRing generateSecretKeyRing()

Return the secret key ring.

Returns:PGPSecretKeyRing

a secret key ring.

sanitizeKeyPairback to summary
private PGPKeyPair sanitizeKeyPair(PGPKeyPair keyPair) throws PGPException