Generating an OTP using PIN mode

This section describes how to generate an OATH OTP using the PIN mode.

  1. Get the token device to be used to generate the OTP.
  2. Generate an OTP by passing the authentication: PIN

For OTP type: HOTP/TOTP/DCVV

The following sample code snippet shows how to generate the OTP using different OATH OTP types (HOTP/TOTP/DCVV):

// 1. Get Token Device to be used to generate OTP
String currentTokenName = "OATHTokenName";
OathTokenDevice oathTokenDevice = mOathMobileProtector.getTokenDevice(currentTokenName, null);

// 2. Generate OTP by passing the authentication: PIN
String pin = "1234";
String otp = oathTokenDevice.getOtp(pin);

For OTP type: OCRA

The following sample code snippet shows how to generate the OTP using an OATH OTP type, OCRA:

// 1. Get Token Device to be used to generate OTP
String currentTokenName = "OATHTokenName";
OathTokenDevice oathTokenDevice = mOathMobileProtector.getTokenDevice(currentTokenName, null);

// Sample data to generate OTP for OCRA
String serverChallenge = "000000003";
String clientChallenge = "000000003";
String password = "password";
String session = "\u20ac" + "10"; // (Euro) E2 82 AC + 31 + 30
byte[] passwordHash = oathTokenDevice.getOcraPasswordHash(password);
String pin = "1234";

// 2. Generate OTP by passing the authentication: PIN
String ocraOtp = oathTokenDevice.getOcraOtp(pin, serverChallenge, clientChallenge, passwordHash, session);

Supporting inputs from Secure Keypad

Since V6.0, Fast Track API supports PIN inputs from Secure KeyPad.

Application need to convert from Core Object PinAuthInput to Fast Track type ProtectorAuthInput by using OathMobileProtector.getProtectorAuthInput() function.

The following code snippet demonstrates how to use Secure Keypad in Fast Track for PIN input then generate OTP

  // The callback from SecureKeypad after end used has input the 
	@Override
  public void onFinish(PinAuthInput pin1, PinAuthInput pin2) {
    try {
      //region 1.1 Switch the data type
      ProtectorAuthInput pinInput = null;
      switch (mCurrentOtpType) {
        case OATH_OCRA:
        case OATH_TOTP:
            pinInput = mOathMobileProtector.getProtectorAuthInput(pin1);
            break;
      }
      //endregion

      //region 1.2 Use the PIN input to generate TOTP
      switch (mCurrentOtpType) {
        case OATH_TOTP:
          OathTokenDevice tokenDevice = mOathMobileProtector.getTokenDevice(tkDeviceName, null);
          String otp = tokenDevice.getOtp(pinInput);
          break;

        case OATH_OCRA:
          OathTokenDevice oathTokenDevice = mOathMobileProtector.getTokenDevice(tkDeviceName, null);
          
          String serverChallenge = "000000003";
          String clientChallenge = "000000003";
          String password = "password";
          String session = "\u20ac" + "10"; // (Euro) E2 82 AC + 31 + 30
          byte[] passwordHash = oathTokenDevice.getOcraPasswordHash(password);
          
          String ocraOtp = oathTokenDevice.getOcraOtp(pinInput, serverChallenge, clientChallenge, passwordHash, session);
          break;
      }
      //endregion 
    } catch (FastTrackException ex) {
      // Handle error
    }
  }
Secure Keypad Usage

Refer to Secure keypad for further information regarding the usage of the Secure keypad.