Class OpenPGPHardwareKey
java.lang.Object
org.bouncycastle.openpgp.smartcard.OpenPGPHardwareKey
An OpenPGP key stored on a
OpenPGPSmartCard.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byteKey used for authentication.static final byteKey used to decrypt messages.static final byteKey used to generate signatures.static final byteKey was generated on the device itself.static final byteKey was generated somewhere else and was imported onto the device. -
Constructor Summary
ConstructorsConstructorDescriptionOpenPGPHardwareKey(OpenPGPSmartCard smartCard, byte keyRef, byte state, byte[] fingerprint, Date generationTime) -
Method Summary
Modifier and TypeMethodDescriptionReturn the creation time of the key.byte[]Return the contents of the fingerprint field.org.bouncycastle.bcpg.KeyIdentifierReturn theKeyIdentifierbased on the reconstructed full key fingerprint.byteReturn the key reference (keyRef) of this key.Return theOpenPGPSmartCardthis key is stored on.booleanReturn true if the key was generated on/by the device itself.booleanReturn true if the key has been imported onto the device.byte[]Retrieve the full OpenPGP key fingerprint by reconstructing thePGPPublicKeyand retrieving its fingerprint.
-
Field Details
-
KEY_REF_SIGNATURE
public static final byte KEY_REF_SIGNATUREKey used to generate signatures.Presumably related to
KeyFlags.SIGN_DATA.- See Also:
-
KEY_REF_DECRYPTION
public static final byte KEY_REF_DECRYPTIONKey used to decrypt messages.Presumably related to
KeyFlags.ENCRYPT_COMMSandKeyFlags.ENCRYPT_STORAGE.- See Also:
-
KEY_REF_AUTHENTICATION
public static final byte KEY_REF_AUTHENTICATIONKey used for authentication.Presumably related to
KeyFlags.AUTHENTICATION.- See Also:
-
STATE_GENERATED
public static final byte STATE_GENERATEDKey was generated on the device itself.- See Also:
-
STATE_IMPORTED
public static final byte STATE_IMPORTEDKey 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, CardExceptionRetrieve the full OpenPGP key fingerprint by reconstructing thePGPPublicKeyand retrieving its fingerprint.- Returns:
- full fingerprint
- Throws:
org.bouncycastle.openpgp.PGPException- if the key cannot be reconstructedCardException- if communication with the card fails
-
getFullKeyIdentifier
public org.bouncycastle.bcpg.KeyIdentifier getFullKeyIdentifier() throws org.bouncycastle.openpgp.PGPException, CardExceptionReturn theKeyIdentifierbased on the reconstructed full key fingerprint.- Returns:
- key identifier
- Throws:
org.bouncycastle.openpgp.PGPException- if the key cannot be reconstructedCardException- if communication with the card fails
-
getCreationTime
-
getKeyRef
public byte getKeyRef()Return the key reference (keyRef) of this key.- Returns:
- key ref
-
getSmartCard
Return theOpenPGPSmartCardthis 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
-