Class PublicKeyPacket

All Implemented Interfaces:
PacketTags, PublicKeyAlgorithmTags, org.bouncycastle.util.Encodable
Direct Known Subclasses:
PublicSubkeyPacket

public class PublicKeyPacket extends ContainedPacket implements PublicKeyAlgorithmTags
Base class for OpenPGP public (primary) keys. The public key packet holds the public parameters of an OpenPGP key pair. An OpenPGP certificate (transferable public key) consists of one primary key and optionally multiple subkey packets.
See Also:
  • Field Details

  • Constructor Details

    • PublicKeyPacket

      @Deprecated public PublicKeyPacket(int algorithm, Date time, BCPGKey key)
      Deprecated.
      Construct version 4 public primary key packet.
      Parameters:
      algorithm - public key algorithm id
      time - creation time
      key - key object
    • PublicKeyPacket

      public PublicKeyPacket(int version, int algorithm, Date time, BCPGKey key)
      Construct an OpenPGP public primary key packet.
      Parameters:
      version - packet version
      algorithm - public key algorithm id
      time - creation time
      key - key object
  • Method Details

    • getVersion

      public int getVersion()
      Return the packet version.
      Returns:
      packet version
    • getAlgorithm

      public int getAlgorithm()
      Return the algorithm id of the public key.
      Returns:
      algorithm id
    • getValidDays

      public int getValidDays()
      Deprecated.
      v4 and v6 keys instead signal their expiration time via the KeyExpirationTime signature subpacket.
      Only for v3 keys - The time in days since the keys creation, during which the key is valid.
      Returns:
      v3 key validity period in days since creation.
    • getTime

      public Date getTime()
      Return the keys creation time.
      Returns:
      creation time of the key
    • getKey

      public BCPGKey getKey()
      Return the key object.
      Returns:
      key
    • getEncodedContents

      public byte[] getEncodedContents() throws IOException
      Return the encoded packet contents without the packet frame.
      Returns:
      encoded packet contents
      Throws:
      IOException
    • encode

      public void encode(BCPGOutputStream out) throws IOException
      Encode the packet to the OpenPGP BCPGOutputStream. If the BCPGOutputStream packet format is set to PacketFormat.ROUNDTRIP, the result of Packet.hasNewPacketFormat() determines, which packet format is used to encode the packet. Otherwise, the BCPGOutputStream dictates which format to use.
      Specified by:
      encode in class ContainedPacket
      Parameters:
      out - packet output stream
      Throws:
      IOException
    • getKeyID

      public static long getKeyID(PublicKeyPacket publicPk, byte[] fingerprint)