Class OpenPGPHardwareKey

java.lang.Object
org.bouncycastle.openpgp.smartcard.OpenPGPHardwareKey

public class OpenPGPHardwareKey extends Object
An OpenPGP key stored on a OpenPGPSmartCard.
  • Field Details

    • KEY_REF_SIGNATURE

      public static final byte KEY_REF_SIGNATURE
      Key used to generate signatures.

      Presumably related to KeyFlags.SIGN_DATA.

      See Also:
    • KEY_REF_DECRYPTION

      public static final byte KEY_REF_DECRYPTION
      Key used to decrypt messages.

      Presumably related to KeyFlags.ENCRYPT_COMMS and KeyFlags.ENCRYPT_STORAGE.

      See Also:
    • KEY_REF_AUTHENTICATION

      public static final byte KEY_REF_AUTHENTICATION
      Key used for authentication.

      Presumably related to KeyFlags.AUTHENTICATION.

      See Also:
    • STATE_GENERATED

      public static final byte STATE_GENERATED
      Key was generated on the device itself.
      See Also:
    • STATE_IMPORTED

      public static final byte STATE_IMPORTED
      Key was generated somewhere else and was imported onto the device. A copy of the private key MAY exist somewhere else.
      See Also:
  • Constructor Details

    • OpenPGPHardwareKey

      public OpenPGPHardwareKey(OpenPGPSmartCard smartCard, byte keyRef, byte state, byte[] fingerprint, Date generationTime)
  • Method Details

    • getFingerprint

      public byte[] getFingerprint()
      Return the contents of the fingerprint field. Note: The fingerprint field of OpenPGP smart cards is a 20-octet field that can contain arbitrary data. Since the smart card does not make use of this field and does not validate its contents, you MUST NOT rely on this field to identify keys. Notably OpenPGP v6 keys, which have a 32-octet fingerprint, will cause mismatches with the 20-octet field.
      Returns:
      content of fingerprint field
    • reconstructFullFingerprint

      public byte[] reconstructFullFingerprint() throws org.bouncycastle.openpgp.PGPException, CardException
      Retrieve the full OpenPGP key fingerprint by reconstructing the PGPPublicKey and retrieving its fingerprint.
      Returns:
      full fingerprint
      Throws:
      org.bouncycastle.openpgp.PGPException - if the key cannot be reconstructed
      CardException - if communication with the card fails
    • getFullKeyIdentifier

      public org.bouncycastle.bcpg.KeyIdentifier getFullKeyIdentifier() throws org.bouncycastle.openpgp.PGPException, CardException
      Return the KeyIdentifier based on the reconstructed full key fingerprint.
      Returns:
      key identifier
      Throws:
      org.bouncycastle.openpgp.PGPException - if the key cannot be reconstructed
      CardException - if communication with the card fails
    • getCreationTime

      public Date getCreationTime()
      Return the creation time of the key.
      Returns:
      creation time
    • getKeyRef

      public byte getKeyRef()
      Return the key reference (keyRef) of this key.
      Returns:
      key ref
    • getSmartCard

      public OpenPGPSmartCard getSmartCard()
      Return the OpenPGPSmartCard this key is stored on.
      Returns:
      smart card
    • isImported

      public boolean isImported()
      Return true if the key has been imported onto the device. Note: A copy of the private key MAY still exist somewhere else.
      Returns:
      true if key was imported
    • isGenerated

      public boolean isGenerated()
      Return true if the key was generated on/by the device itself.
      Returns:
      true if key was generated