Package 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 | Description
    --- | ---
    `PGPKeyRingGenerator​(int certificationLevel, PGPKeyPair masterKey, java.lang.String id, PGPDigestCalculator checksumCalculator, PGPSignatureSubpacketVector hashedPcks, PGPSignatureSubpacketVector unhashedPcks, PGPContentSignerBuilder keySignerBuilder, PBESecretKeyEncryptor keyEncryptor)` | Create a new key ring generator.
    `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

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `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,
                                     PGPDigestCalculator checksumCalculator,
                                     PGPSignatureSubpacketVector hashedPcks,
                                     PGPSignatureSubpacketVector unhashedPcks,
                                     PGPContentSignerBuilder keySignerBuilder,
                                     PBESecretKeyEncryptor keyEncryptor)
                              throws PGPException

      Create a new key ring generator.
      Parameters:
        `certificationLevel` -
        `masterKey` -
        `id` - id to associate with the key.
        `checksumCalculator` - key checksum calculator
        `hashedPcks` -
        `unhashedPcks` -
        `keySignerBuilder` - builder for key certifications - will be initialised with master secret key.
        `keyEncryptor` - encryptor for secret subkeys.
      Throws:
        `PGPException`

    - #### 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 master 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 master key.
        `checksumCalculator` - key checksum calculator
        `keySignerBuilder` - builder for key certifications - will be initialised with master secret key.
        `keyEncryptor` - encryptor for secret subkeys.
      Throws:
        `PGPException`

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