Class HotpSlotConfiguration

java.lang.Object
com.yubico.yubikit.yubiotp.HotpSlotConfiguration
All Implemented Interfaces:
SlotConfiguration

public class HotpSlotConfiguration extends Object
Configures the YubiKey to return an OATH-HOTP code on touch
  • Field Details

    • FIXED_SIZE

      protected static final int FIXED_SIZE
      See Also:
    • UID_SIZE

      protected static final int UID_SIZE
      See Also:
    • KEY_SIZE

      protected static final int KEY_SIZE
      See Also:
    • fixed

      protected byte[] fixed
    • uid

      protected final byte[] uid
    • key

      protected final byte[] key
  • Constructor Details

    • HotpSlotConfiguration

      public HotpSlotConfiguration(byte[] secret)
      Creates an OATH-HOTP configuration with default settings.
      Parameters:
      secret - the shared secret for the OATH-TOTP credential
  • Method Details

    • getThis

      protected HotpSlotConfiguration getThis()
    • digits8

      public HotpSlotConfiguration digits8(boolean digits8)
      If set, output an 8 digit OATH-HOTP code instead of a 6 digit code.
      Parameters:
      digits8 - true to use 8 digits of code output.
      Returns:
      the configuration for chaining
    • tokenId

      public HotpSlotConfiguration tokenId(byte[] tokenId, boolean fixedModhex1, boolean fixedModhex2)
      Configure OATH token id with a provided value. The standard OATH token id for a Yubico YubiKey is (MODHEX) OO=ub, TT=he, (BCD) UUUUUUUU=serial number.

      The reason for the decimal serial number is to make it easy for humans to correlate the serial number on the back of the YubiKey to an entry in a list of associated tokens for example.

      NOTE: If fixedModhex1 and fixedModhex2 are BOTH set, the entire token id will be output in MODHEX.

      Parameters:
      tokenId - the raw token ID value
      fixedModhex1 - output the first byte of the token ID as MODHEX
      fixedModhex2 - output the first two bytes of the token ID as MODHEX
      Returns:
      the configuration for chaining
    • imf

      public HotpSlotConfiguration imf(int imf)
      Set OATH Initial Moving Factor. This is the initial counter value for the YubiKey. This should be a value between 0 and 1048560, evenly dividable by 16.
      Parameters:
      imf - the initial counter value for the credential
      Returns:
      the configuration for chaining
    • appendCr

      public HotpSlotConfiguration appendCr(boolean appendCr)
      Appends a Carriage Return (Enter key press) at the end of the output.
      Parameters:
      appendCr - if true, the output of the slot will end with a CR (default: true)
      Returns:
      the configuration for chaining
    • fastTrigger

      public HotpSlotConfiguration fastTrigger(boolean fastTrigger)
      Faster triggering when only slot 1 is configured. This option is always in effect on firmware versions 3.0 and above.
      Parameters:
      fastTrigger - if true, trigger slot 1 quicker when slot 2 is not configured (default: true)
      Returns:
      the configuration for chaining
    • pacing

      public HotpSlotConfiguration pacing(boolean pacing10Ms, boolean pacing20Ms)
      Adds a delay between each key press when sending output. This may sometimes be needed if the host system isn't able to handle the default speed at which keystrokes are sent.

      NOTE: These two flags can be combined to maximize the delay.

      Parameters:
      pacing10Ms - Adds a ~10ms delay between keystrokes (default: false)
      pacing20Ms - Adds a ~20ms delay between keystrokes (default: false)
      Returns:
      the configuration for chaining
    • useNumeric

      public HotpSlotConfiguration useNumeric(boolean useNumeric)
      Send scancodes for numeric keypad key presses when sending digits - helps with some keyboard layouts.
      Parameters:
      useNumeric - true to use the numeric keypad (default: false)
      Returns:
      the configuration for chaining
    • getFlags

      protected final byte getFlags(SlotConfiguration.FlagType type)
    • updateFlags

      protected HotpSlotConfiguration updateFlags(SlotConfiguration.Flag flag, boolean value)
    • isSupportedBy

      public boolean isSupportedBy(com.yubico.yubikit.core.Version version)
      Description copied from interface: SlotConfiguration
      Checks the configuration against a YubiKey firmware version to see if it is supported
      Specified by:
      isSupportedBy in interface SlotConfiguration
      Parameters:
      version - the firmware version to check against
      Returns:
      true if the given YubiKey version supports this configuration
    • getConfig

      public byte[] getConfig(@Nullable byte[] accCode)
      Specified by:
      getConfig in interface SlotConfiguration
    • serialApiVisible

      public HotpSlotConfiguration serialApiVisible(boolean serialApiVisible)
    • serialUsbVisible

      public HotpSlotConfiguration serialUsbVisible(boolean serialUsbVisible)
    • allowUpdate

      public HotpSlotConfiguration allowUpdate(boolean allowUpdate)
    • dormant

      public HotpSlotConfiguration dormant(boolean dormant)
      Makes the configuration dormant (hidden from use). A dormant configuration needs to be updated and the dormant bit removed to be used.
      Parameters:
      dormant - if true, the configuration cannot be used
      Returns:
      the configuration for chaining
    • invertLed

      public HotpSlotConfiguration invertLed(boolean invertLed)
      Inverts the behaviour of the led on the YubiKey.
      Parameters:
      invertLed - if true, the LED behavior is inverted
      Returns:
      the configuration for chaining
    • protectSlot2

      public HotpSlotConfiguration protectSlot2(boolean protectSlot2)
      When set for slot 1, access to modify slot 2 is blocked (even if slot 2 is empty).
      Parameters:
      protectSlot2 - If true, slot 2 cannot be modified.
      Returns:
      the configuration for chaining