Class SmartCardProtocol
java.lang.Object
com.yubico.yubikit.core.smartcard.SmartCardProtocol
- All Implemented Interfaces:
Closeable,AutoCloseable
Support class for communication over a SmartCardConnection.
This class handles APDU encoding and chaining, and implements workarounds for known issues.
-
Constructor Summary
ConstructorsConstructorDescriptionSmartCardProtocol(SmartCardConnection connection) Create new instance ofSmartCardProtocoland selects the application for useSmartCardProtocol(SmartCardConnection connection, byte insSendRemaining) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidenableWorkarounds(Version firmwareVersion) Enable all relevant workarounds given the firmware version of the YubiKey.byte[]select(byte[] aid) Sends an APDU to SELECT an Application.byte[]sendAndReceive(Apdu command) Sends APDU command and receives byte array from connection In case if output has status code that it has remaining info sends another APDU command to receive what's remainingvoidsetApduFormat(ApduFormat apduFormat) YubiKey NEO doesn't support extended APDU's for most applications.voidsetEnableTouchWorkaround(boolean enableTouchWorkaround) YubiKey 4.2.0 - 4.2.6 have an issue with the touch timeout being too short in certain cases.
-
Constructor Details
-
SmartCardProtocol
Create new instance ofSmartCardProtocoland selects the application for use- Parameters:
connection- connection to the YubiKey
-
SmartCardProtocol
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
enableWorkarounds
Enable all relevant workarounds given the firmware version of the YubiKey.- Parameters:
firmwareVersion- the firmware version to use for detection to enable the workarounds
-
setEnableTouchWorkaround
public void setEnableTouchWorkaround(boolean enableTouchWorkaround) YubiKey 4.2.0 - 4.2.6 have an issue with the touch timeout being too short in certain cases. Enable this workaround on such devices to trigger sending a dummy command which mitigates the issue.- Parameters:
enableTouchWorkaround- true to enable the workaround, false to disable it
-
setApduFormat
YubiKey NEO doesn't support extended APDU's for most applications.- Parameters:
apduFormat- the APDU encoding to use when sending commands
-
getConnection
- Returns:
- the underlying connection
-
select
Sends an APDU to SELECT an Application.- Parameters:
aid- the AID to select.- Returns:
- the response data from selecting the Application
- Throws:
IOException- in case of connection or communication errorApplicationNotAvailableException- in case the AID doesn't match an available application
-
sendAndReceive
Sends APDU command and receives byte array from connection In case if output has status code that it has remaining info sends another APDU command to receive what's remaining- Parameters:
command- well structured command that needs to be send- Returns:
- data blob concatenated from all APDU commands that were sent *set of output commands and send remaining commands)
- Throws:
IOException- in case of connection and communication errorApduException- in case if received error in APDU response
-