Class OtpProtocol

java.lang.Object
com.yubico.yubikit.core.otp.OtpProtocol
All Implemented Interfaces:
Closeable, AutoCloseable

public class OtpProtocol extends Object implements Closeable
  • Constructor Details

  • Method Details

    • getVersion

      public Version getVersion()
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      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 to
      data - the data payload to send
      state - 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 error
      CommandException - in case the command failed
    • readStatus

      public byte[] readStatus() throws IOException
      Receive status bytes from YubiKey
      Returns:
      status bytes (first 3 bytes are the firmware version)
      Throws:
      IOException - in case of communication error