Class PGPKeyPair

java.lang.Object
org.bouncycastle.openpgp.PGPKeyPair
Direct Known Subclasses:
BcPGPKeyPair, JcaPGPKeyPair

public class PGPKeyPair extends Object
Class to hold an unlocked PGP key pair. Note: the private key might be null, e.g. for PGP keys with external/removed private key material.
  • Field Details

  • Constructor Details

    • PGPKeyPair

      public PGPKeyPair(PGPPublicKey pub, PGPPrivateKey priv)
      Create a key pair from a PGPPrivateKey and a PGPPublicKey.
      Parameters:
      pub - the public key
      priv - the private key
    • PGPKeyPair

      protected PGPKeyPair()
  • Method Details

    • getKeyID

      public long getKeyID()
      Return the keyID associated with this key pair.
      Returns:
      keyID
    • getKeyIdentifier

      public KeyIdentifier getKeyIdentifier()
      Return the KeyIdentifier associated with the public key.
      Returns:
      key identifier
    • getPublicKey

      public PGPPublicKey getPublicKey()
    • getPrivateKey

      public PGPPrivateKey getPrivateKey()
    • asSubkey

      public PGPKeyPair asSubkey(KeyFingerPrintCalculator fingerPrintCalculator) throws PGPException
      Return this PGP key pair as a subkey pair. The public and private key packets get reconstructed into subkey packets.
      Parameters:
      fingerPrintCalculator - for fingerprint calculations
      Returns:
      subkey pair
      Throws:
      PGPException - if a subkey packet cannot be constructed properly