public boolean verifyTimeoutCode(String timeoutCode,
                                   long currentInterval,
                                   int pastIntervals,
                                   int futureIntervals) throws GeneralSecurityException {
    // Ensure that look-ahead and look-back counts are not negative.
    pastIntervals = Math.max(pastIntervals, 0);
    futureIntervals = Math.max(futureIntervals, 0);

    // Try upto "pastIntervals" before current time, and upto "futureIntervals" after.
    for (int i = -pastIntervals; i <= futureIntervals; ++i) {
      String candidate = generateResponseCode(currentInterval - i, null);
      if (candidate.equals(timeoutCode)) {
        return true;
      }
    }

    return false;
  }
Verify a timeout code. The timeout code will be valid for a time
determined by the interval period and the number of adjacent intervals
checked.

@param timeoutCode The timeout code
@param pastIntervals The number of past intervals to check
@param futureIntervals The number of future intervals to check
@return True if the timeout code is valid
java/com/google/android/apps/authenticator/otp/PasscodeGenerator.java