Bouncy Castle Cryptography Library 1.40

## org.bouncycastle.openpgp
Class PGPSecretKeyRing

    java.lang.Object
      org.bouncycastle.openpgp.PGPKeyRing
          org.bouncycastle.openpgp.PGPSecretKeyRing

    public class PGPSecretKeyRing

extends PGPKeyRing

Class to hold a single master secret key and its subkeys.

Often PGP keyring files consist of multiple master keys, if you are trying to process or construct one of these you should use the PGPSecretKeyRingCollection class.

Constructor Summary
`PGPSecretKeyRing(byte[] encoding)`
`PGPSecretKeyRing(java.io.InputStream in)`

Method Summary
`void` `encode(java.io.OutputStream outStream)`
`byte[]` `getEncoded()`
`PGPPublicKey` `getPublicKey()` Return the public key for the master key.
`PGPSecretKey` `getSecretKey()` Return the master private key.
`PGPSecretKey` `getSecretKey(long keyId)`
`java.util.Iterator` `getSecretKeys()` Return an iterator containing all the secret keys.
`static PGPSecretKeyRing` `insertSecretKey(PGPSecretKeyRing secRing, PGPSecretKey secKey)` Returns a new key ring with the secret key passed in either added or replacing an existing one with the same key ID.
`static PGPSecretKeyRing` `removeSecretKey(PGPSecretKeyRing secRing, PGPSecretKey secKey)` Returns a new key ring with the secret key passed in removed from the key ring.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### PGPSecretKeyRing

    public PGPSecretKeyRing(byte[] encoding)
                     throws java.io.IOException,
                            PGPException

Throws:
  `java.io.IOException`
  `PGPException`

### PGPSecretKeyRing

    public PGPSecretKeyRing(java.io.InputStream in)
                     throws java.io.IOException,
                            PGPException

Throws:
  `java.io.IOException`
  `PGPException`

Method Detail

### getPublicKey

    public PGPPublicKey getPublicKey()

  Return the public key for the master key.

  Returns:
    PGPPublicKey

### getSecretKey

    public PGPSecretKey getSecretKey()

  Return the master private key.

  Returns:
    PGPSecretKey

### getSecretKeys

    public java.util.Iterator getSecretKeys()

  Return an iterator containing all the secret keys.

  Returns:
    Iterator

### getSecretKey

    public PGPSecretKey getSecretKey(long keyId)

### getEncoded

    public byte[] getEncoded()
                      throws java.io.IOException

  Throws:
    `java.io.IOException`

### encode

    public void encode(java.io.OutputStream outStream)
                throws java.io.IOException

  Throws:
    `java.io.IOException`

### insertSecretKey

    public static PGPSecretKeyRing insertSecretKey(PGPSecretKeyRing secRing,
                                                   PGPSecretKey secKey)

  Returns a new key ring with the secret key passed in either added or replacing an existing one with the same key ID.

  Parameters:
    `secRing` - the secret key ring to be modified.
    `secKey` - the secret key to be added.
  Returns:
    a new secret key ring.

### removeSecretKey

    public static PGPSecretKeyRing removeSecretKey(PGPSecretKeyRing secRing,
                                                   PGPSecretKey secKey)

  Returns a new key ring with the secret key passed in removed from the key ring.

  Parameters:
    `secRing` - the secret key ring to be modified.
    `secKey` - the secret key to be removed.
  Returns:
    a new secret key ring, or null if secKey is not found.

Bouncy Castle Cryptography Library 1.40