Package com.yubico.yubikit.core.otp
Class OtpProtocol
java.lang.Object
com.yubico.yubikit.core.otp.OtpProtocol
- All Implemented Interfaces:
Closeable,AutoCloseable
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()byte[]Receive status bytes from YubiKeybyte[]sendAndReceive(byte slot, byte[] data, CommandState state) Sends a command to the YubiKey, and reads the response.
-
Constructor Details
-
OtpProtocol
- Throws:
IOException
-
-
Method Details
-
getVersion
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
sendAndReceive
public byte[] sendAndReceive(byte slot, @Nullable byte[] data, @Nullable CommandState state) throws IOException, CommandException Sends a command to the YubiKey, and reads the response. If the command results in a configuration update, the programming sequence number is verified and the updated status bytes are returned.- Parameters:
slot- the slot to send todata- the data payload to sendstate- optional CommandState for listening for user presence requirement and for cancelling a command- Returns:
- response data (including CRC) in the case of data, or an updated status struct
- Throws:
IOException- in case of communication errorCommandException- in case the command failed
-
readStatus
Receive status bytes from YubiKey- Returns:
- status bytes (first 3 bytes are the firmware version)
- Throws:
IOException- in case of communication error
-