org.bouncycastle.openpgp

## Class PGPKeyRingGenerator

- java.lang.Object
- - org.bouncycastle.openpgp.PGPKeyRingGenerator

    public class PGPKeyRingGenerator
    extends java.lang.Object

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

### Constructor Summary

Constructors
Constructor and Description
`PGPKeyRingGenerator(int certificationLevel, PGPKeyPair masterKey, java.lang.String id, int encAlgorithm, char[] passPhrase, boolean useSHA1, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks, java.security.SecureRandom rand, java.security.Provider provider)` Create a new key ring generator.
`PGPKeyRingGenerator(int certificationLevel, PGPKeyPair masterKey, java.lang.String id, int encAlgorithm, char[] passPhrase, boolean useSHA1, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks, java.security.SecureRandom rand, java.lang.String provider)` Create a new key ring generator.
`PGPKeyRingGenerator(int certificationLevel, PGPKeyPair masterKey, java.lang.String id, int encAlgorithm, char[] passPhrase, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks, java.security.SecureRandom rand, java.lang.String provider)` Create a new key ring generator using old style checksumming.

### Method Summary

Methods
`void` `addSubKey(PGPKeyPair keyPair)` Add a sub key to the key ring to be generated with default certification and inheriting the hashed/unhashed packets of the master key.
`void` `addSubKey(PGPKeyPair keyPair, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks)` Add a subkey with specific hashed and unhashed packets associated with it and default certification.
`PGPPublicKeyRing` `generatePublicKeyRing()` Return the public key ring that corresponds to the secret key ring.
`PGPSecretKeyRing` `generateSecretKeyRing()` Return the secret key ring.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### PGPKeyRingGenerator

    public PGPKeyRingGenerator(int certificationLevel,
                       PGPKeyPair masterKey,
                       java.lang.String id,
                       int encAlgorithm,
                       char[] passPhrase,
                       PGPSignatureSubpacketVector hashedPcks,
                       PGPSignatureSubpacketVector unhashedPcks,
                       java.security.SecureRandom rand,
                       java.lang.String provider)
                        throws PGPException,
                               java.security.NoSuchProviderException

Create a new key ring generator using old style checksumming. It is recommended to use SHA1 checksumming where possible.

Parameters:
  `certificationLevel` - the certification level for keys on this ring.
  `masterKey` - the master key pair.
  `id` - the id to be associated with the ring.
  `encAlgorithm` - the algorithm to be used to protect secret keys.
  `passPhrase` - the passPhrase to be used to protect secret keys.
  `hashedPcks` - packets to be included in the certification hash.
  `unhashedPcks` - packets to be attached unhashed to the certification.
  `rand` - input secured random
  `provider` - the provider to use for encryption.
Throws:
  `PGPException`
  `java.security.NoSuchProviderException`

#### PGPKeyRingGenerator

    public PGPKeyRingGenerator(int certificationLevel,
                       PGPKeyPair masterKey,
                       java.lang.String id,
                       int encAlgorithm,
                       char[] passPhrase,
                       boolean useSHA1,
                       PGPSignatureSubpacketVector hashedPcks,
                       PGPSignatureSubpacketVector unhashedPcks,
                       java.security.SecureRandom rand,
                       java.lang.String provider)
                        throws PGPException,
                               java.security.NoSuchProviderException

Create a new key ring generator.

Parameters:
  `certificationLevel` - the certification level for keys on this ring.
  `masterKey` - the master key pair.
  `id` - the id to be associated with the ring.
  `encAlgorithm` - the algorithm to be used to protect secret keys.
  `passPhrase` - the passPhrase to be used to protect secret keys.
  `useSHA1` - checksum the secret keys with SHA1 rather than the older 16 bit checksum.
  `hashedPcks` - packets to be included in the certification hash.
  `unhashedPcks` - packets to be attached unhashed to the certification.
  `rand` - input secured random
  `provider` - the provider to use for encryption.
Throws:
  `PGPException`
  `java.security.NoSuchProviderException`

#### PGPKeyRingGenerator

    public PGPKeyRingGenerator(int certificationLevel,
                       PGPKeyPair masterKey,
                       java.lang.String id,
                       int encAlgorithm,
                       char[] passPhrase,
                       boolean useSHA1,
                       PGPSignatureSubpacketVector hashedPcks,
                       PGPSignatureSubpacketVector unhashedPcks,
                       java.security.SecureRandom rand,
                       java.security.Provider provider)
                        throws PGPException,
                               java.security.NoSuchProviderException

Create a new key ring generator.

Parameters:
  `certificationLevel` - the certification level for keys on this ring.
  `masterKey` - the master key pair.
  `id` - the id to be associated with the ring.
  `encAlgorithm` - the algorithm to be used to protect secret keys.
  `passPhrase` - the passPhrase to be used to protect secret keys.
  `useSHA1` - checksum the secret keys with SHA1 rather than the older 16 bit checksum.
  `hashedPcks` - packets to be included in the certification hash.
  `unhashedPcks` - packets to be attached unhashed to the certification.
  `rand` - input secured random
  `provider` - the provider to use for encryption.
Throws:
  `PGPException`
  `java.security.NoSuchProviderException`

### Method Detail

#### addSubKey

    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 master key.

Parameters:
  `keyPair` -
Throws:
  `PGPException`

#### 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`

#### generateSecretKeyRing

    public PGPSecretKeyRing generateSecretKeyRing()

Return the secret key ring.

Returns:
  a secret key ring.

#### generatePublicKeyRing

    public PGPPublicKeyRing generatePublicKeyRing()

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

Returns:
  a public key ring.