Class Ctap1Session

java.lang.Object
com.yubico.yubikit.core.application.ApplicationSession<CtapSession>
com.yubico.yubikit.fido.ctap.CtapSession
com.yubico.yubikit.fido.ctap.Ctap1Session
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
Ctap2Session

public class Ctap1Session extends CtapSession
Implementation of the CTAP1 (U2F) specification.

This class provides methods for U2F registration and authentication operations using the legacy CTAP1 protocol, also known as FIDO U2F.

See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Binary response data for a CTAP1 (U2F) registration.
    static class 
    Binary response data for a CTAP1 (U2F) authentication.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Ctap1Session(com.yubico.yubikit.core.fido.FidoConnection connection)
    Creates a new CTAP1 session from a FIDO connection.
    Ctap1Session(com.yubico.yubikit.core.smartcard.SmartCardConnection connection)
     
    Ctap1Session(com.yubico.yubikit.core.smartcard.SmartCardConnection connection, @Nullable com.yubico.yubikit.core.smartcard.scp.ScpKeyParams scpKeyParams)
    Creates a new CTAP1 session from a SmartCard connection.
  • Method Summary

    Modifier and Type
    Method
    Description
    authenticate(byte[] clientParam, byte[] appParam, byte[] keyHandle, boolean checkOnly)
    Authenticates a previously registered credential.
    void
     
    Gets the U2F version implemented by the authenticator.
    com.yubico.yubikit.core.Version
    Gets the version of the YubiKey firmware.
    register(byte[] clientParam, byte[] appParam)
    Registers a new U2F credential.

    Methods inherited from class com.yubico.yubikit.core.application.ApplicationSession

    require, supports

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Ctap1Session

      public Ctap1Session(com.yubico.yubikit.core.smartcard.SmartCardConnection connection) throws IOException, com.yubico.yubikit.core.application.CommandException
      Throws:
      IOException
      com.yubico.yubikit.core.application.CommandException
    • Ctap1Session

      public Ctap1Session(com.yubico.yubikit.core.smartcard.SmartCardConnection connection, @Nullable com.yubico.yubikit.core.smartcard.scp.ScpKeyParams scpKeyParams) throws IOException, com.yubico.yubikit.core.application.CommandException
      Creates a new CTAP1 session from a SmartCard connection.
      Parameters:
      connection - a SmartCard/NFC connection
      Throws:
      IOException - if communication with the device fails
      com.yubico.yubikit.core.application.ApplicationNotAvailableException - if the FIDO application is not available
      com.yubico.yubikit.core.application.CommandException
    • Ctap1Session

      public Ctap1Session(com.yubico.yubikit.core.fido.FidoConnection connection) throws IOException, com.yubico.yubikit.core.application.CommandException
      Creates a new CTAP1 session from a FIDO connection.
      Parameters:
      connection - a FIDO HID connection
      Throws:
      IOException - if communication with the device fails
      com.yubico.yubikit.core.application.CommandException
  • Method Details

    • close

      public void close() throws IOException
      Throws:
      IOException
    • getVersion

      public com.yubico.yubikit.core.Version getVersion()
      Gets the version of the YubiKey firmware.

      For USB connections, this returns the version from the HID device. For NFC connections, version information is not available and returns 0.0.0.

      Specified by:
      getVersion in class com.yubico.yubikit.core.application.ApplicationSession<CtapSession>
      Returns:
      the YubiKey firmware version
    • getU2fVersion

      public String getU2fVersion() throws IOException, com.yubico.yubikit.core.smartcard.ApduException, com.yubico.yubikit.core.fido.CtapException
      Gets the U2F version implemented by the authenticator. The only version specified is "U2F_V2".
      Returns:
      a U2F version string
      Throws:
      IOException - if communication fails
      com.yubico.yubikit.core.smartcard.ApduException - if the command returns an error status
      com.yubico.yubikit.core.fido.CtapException
    • register

      public Ctap1Session.RegistrationData register(byte[] clientParam, byte[] appParam) throws IOException, com.yubico.yubikit.core.smartcard.ApduException, com.yubico.yubikit.core.fido.CtapException
      Registers a new U2F credential.
      Parameters:
      clientParam - SHA256 hash of the ClientData used for the request
      appParam - SHA256 hash of the app ID used for the request
      Returns:
      the registration response from the authenticator
      Throws:
      IOException - if communication fails
      com.yubico.yubikit.core.smartcard.ApduException - if the command returns an error status
      com.yubico.yubikit.core.fido.CtapException
      See Also:
    • authenticate

      public Ctap1Session.SignatureData authenticate(byte[] clientParam, byte[] appParam, byte[] keyHandle, boolean checkOnly) throws IOException, com.yubico.yubikit.core.smartcard.ApduException, com.yubico.yubikit.core.fido.CtapException
      Authenticates a previously registered credential.
      Parameters:
      clientParam - SHA256 hash of the ClientData used for the request
      appParam - SHA256 hash of the app ID used for the request
      keyHandle - the binary key handle of the credential
      checkOnly - true to send a "check-only" request to determine if a key handle is known
      Returns:
      the authentication response from the authenticator
      Throws:
      IOException - if communication fails
      com.yubico.yubikit.core.smartcard.ApduException - if the command returns an error status
      com.yubico.yubikit.core.fido.CtapException
      See Also: