Class YubikeyOpenPGPSmartCard
-
Field Summary
Fields inherited from class OpenPGPSmartCard
keys -
Constructor Summary
ConstructorsConstructorDescriptionYubikeyOpenPGPSmartCard(YubikeySmartCardBackend backend, com.yubico.yubikit.management.DeviceInfo deviceInfo, com.yubico.yubikit.core.YubiKeyDevice device) -
Method Summary
Modifier and TypeMethodDescriptioncom.yubico.yubikit.core.keys.PublicKeyValuesconvertPublicKey(org.bouncycastle.openpgp.PGPPublicKey pgpPublicKey) Return theOpenPGPSmartCardBackendthat manages this smart card.Return aStringrepresenting the card type.Return the serial number of this smart card.getSupportedAlgorithms(byte keyRef) Return all supported key algorithms of the slot identified by keyRef.Return the version number of this smart card.booleanisKeySupported(byte keyRef, org.bouncycastle.openpgp.api.OpenPGPCertificate.OpenPGPComponentKey key) Return true, if the smart card supports the givenOpenPGPCertificate.OpenPGPComponentKey.com.yubico.yubikit.openpgp.OpenPgpSessionorg.bouncycastle.openpgp.PGPPublicKeyreconstructPGPPublicKey(byte keyRefByte) Return thePGPPublicKeycomponent of the key in the slot identified by keyRef.reset()Reset the smart card, clearing all key slots and resetting the admin PIN, user PIN to their defaults.uploadKey(byte keyRefByte, org.bouncycastle.openpgp.api.OpenPGPKey.OpenPGPPrivateKey key, char[] adminPin) Upload the givenOpenPGPKey.OpenPGPPrivateKeyto the given keyRef slot on the card.uploadKey(byte keyRefByte, org.bouncycastle.openpgp.PGPKeyPair keyPair, char[] adminPin) Methods inherited from class OpenPGPSmartCard
getAuthenticationKey, getDecryptionKey, getKeyByFingerprint, getKeyByKeyRef, getKeys, getSignatureKey, hasAuthenticationKey, hasDecryptionKey, hasKey, hasKeyWithFingerprint, hasSignatureKey, putKey, toString, uploadAuthenticationKey, uploadDecryptionKey, uploadSigningKey
-
Constructor Details
-
YubikeyOpenPGPSmartCard
public YubikeyOpenPGPSmartCard(YubikeySmartCardBackend backend, com.yubico.yubikit.management.DeviceInfo deviceInfo, com.yubico.yubikit.core.YubiKeyDevice device) throws CardException - Throws:
CardException
-
-
Method Details
-
openSession
public com.yubico.yubikit.openpgp.OpenPgpSession openSession() throws IOException, com.yubico.yubikit.core.smartcard.ApduException, CardException- Throws:
IOExceptioncom.yubico.yubikit.core.smartcard.ApduExceptionCardException
-
getSerialNumber
Description copied from class:OpenPGPSmartCardReturn the serial number of this smart card.- Specified by:
getSerialNumberin classOpenPGPSmartCard- Returns:
- serial number
-
getVersion
Description copied from class:OpenPGPSmartCardReturn the version number of this smart card.- Specified by:
getVersionin classOpenPGPSmartCard- Returns:
- version number
-
isKeySupported
public boolean isKeySupported(byte keyRef, org.bouncycastle.openpgp.api.OpenPGPCertificate.OpenPGPComponentKey key) throws CardException Description copied from class:OpenPGPSmartCardReturn true, if the smart card supports the givenOpenPGPCertificate.OpenPGPComponentKey.- Specified by:
isKeySupportedin classOpenPGPSmartCard- Parameters:
keyRef- key referencekey- OpenPGP key- Returns:
- true if the card supports the key
- Throws:
CardException- if communication with the card fails
-
getSupportedAlgorithms
Return all supported key algorithms of the slot identified by keyRef.NOTE: yubikit's
AlgorithmAttributes.Rsa/.Ecsubclasses and theirgetAlgorithmId()/getNLen()/getCurve()accessors are all package-private incom.yubico.yubikit.openpgp, so the only way to read the attributes from outside that package is to parse thetoString()rendering. That rendering is not API and may change in any yubikit release, so every field here is optional: an attribute that cannot be parsed is skipped rather than allowed to throw, which degradesisKeySupported(byte, OpenPGPCertificate.OpenPGPComponentKey)to "not supported" instead of failing the whole card. Replace this with the typed accessors if yubikit ever publishes them.- Parameters:
keyRef- key reference- Returns:
SupportedAlgorithms
-
reset
Description copied from class:OpenPGPSmartCardReset the smart card, clearing all key slots and resetting the admin PIN, user PIN to their defaults.- Specified by:
resetin classOpenPGPSmartCard- Returns:
- this
- Throws:
CardException- if communication with the card failed
-
getBackend
Description copied from class:OpenPGPSmartCardReturn theOpenPGPSmartCardBackendthat manages this smart card.- Overrides:
getBackendin classOpenPGPSmartCard- Returns:
- backend
-
uploadKey
public YubikeyOpenPGPSmartCard uploadKey(byte keyRefByte, org.bouncycastle.openpgp.api.OpenPGPKey.OpenPGPPrivateKey key, char[] adminPin) throws CardException, org.bouncycastle.openpgp.PGPException Description copied from class:OpenPGPSmartCardUpload the givenOpenPGPKey.OpenPGPPrivateKeyto the given keyRef slot on the card.- Specified by:
uploadKeyin classOpenPGPSmartCard- Parameters:
keyRefByte- keyRefkey- OpenPGP private keyadminPin- admin pin of the card- Returns:
- card
- Throws:
CardException- if communication with the card failsorg.bouncycastle.openpgp.PGPException- if the key cannot be prepared for the card
-
uploadKey
public YubikeyOpenPGPSmartCard uploadKey(byte keyRefByte, org.bouncycastle.openpgp.PGPKeyPair keyPair, char[] adminPin) throws CardException, org.bouncycastle.openpgp.PGPException - Throws:
CardExceptionorg.bouncycastle.openpgp.PGPException
-
getCardType
Description copied from class:OpenPGPSmartCardReturn aStringrepresenting the card type. This is an informative description of the device.- Specified by:
getCardTypein classOpenPGPSmartCard- Returns:
- card type
-
convertPublicKey
public com.yubico.yubikit.core.keys.PublicKeyValues convertPublicKey(org.bouncycastle.openpgp.PGPPublicKey pgpPublicKey) throws org.bouncycastle.openpgp.PGPException - Throws:
org.bouncycastle.openpgp.PGPException
-
reconstructPGPPublicKey
public org.bouncycastle.openpgp.PGPPublicKey reconstructPGPPublicKey(byte keyRefByte) throws CardException, org.bouncycastle.openpgp.PGPException Description copied from class:OpenPGPSmartCardReturn thePGPPublicKeycomponent of the key in the slot identified by keyRef.Note: The key might be reconstructed on the fly. In this case,
Public key algorithmand version number might be brute-forced by comparing the resultingkeysfingerprint to the contents of the cardsOpenPGPHardwareKey.getFingerprint()field.- Specified by:
reconstructPGPPublicKeyin classOpenPGPSmartCard- Parameters:
keyRefByte- key reference- Returns:
- PGPPublicKey representation
- Throws:
CardException- if communication with the card failsorg.bouncycastle.openpgp.PGPException- if the key cannot be reconstructed
-