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 ofSmartCardProtocol
and selects the application for useSmartCardProtocol
(SmartCardConnection connection, byte insSendRemaining) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
Enable all relevant settings and workarounds given the firmware version of the YubiKey.void
enableWorkarounds
(Version firmwareVersion) Deprecated.initScp
(ScpKeyParams keyParams) byte[]
select
(byte[] aid) Sends an APDU to SELECT an Application.byte[]
sendAndReceive
(Apdu command) Sends APDU command and receives byte array from connectionvoid
setApduFormat
(ApduFormat apduFormat) Deprecated.useconfigure(Version)
instead.void
setEnableTouchWorkaround
(boolean enableTouchWorkaround) Deprecated.useconfigure(Version)
instead.
-
Constructor Details
-
SmartCardProtocol
Create new instance ofSmartCardProtocol
and selects the application for use- Parameters:
connection
- connection to the YubiKey
-
SmartCardProtocol
-
-
Method Details
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
configure
Enable all relevant settings and workarounds given the firmware version of the YubiKey.- Parameters:
firmwareVersion
- the firmware version to use to configure relevant settings- Throws:
IOException
-
enableWorkarounds
Deprecated.useconfigure(Version)
instead.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
Deprecated.useconfigure(Version)
instead.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
Deprecated.useconfigure(Version)
instead.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 connectionIn 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
-
initScp
@Nullable public DataEncryptor initScp(ScpKeyParams keyParams) throws IOException, ApduException, BadResponseException
-
configure(Version)
instead.