Package org.jboss.security.otp
Class HOTP
- java.lang.Object
-
- org.jboss.security.otp.HOTP
-
public class HOTP extends Object
Based on IETF RFC 4226 (http://tools.ietf.org/html/rfc4226) Code is derived from OATH HOTP algorithm- Since:
- Sep 13, 2010
- Author:
- Anil.Saldhana@redhat.com
-
-
Constructor Summary
Constructors Constructor Description HOTP()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
generateOTP(byte[] secret, long movingFactor, int codeDigits, boolean addChecksum, int truncationOffset)
This method generates an OTP value for the given set of parameters.
-
-
-
Method Detail
-
generateOTP
public static String generateOTP(byte[] secret, long movingFactor, int codeDigits, boolean addChecksum, int truncationOffset) throws NoSuchAlgorithmException, InvalidKeyException
This method generates an OTP value for the given set of parameters.- Parameters:
secret
- the shared secretmovingFactor
- the counter, time, or other value that changes on a per use basis.codeDigits
- the number of digits in the OTP, not including the checksum, if any.addChecksum
- a flag that indicates if a checksum digit should be appended to the OTP.truncationOffset
- the offset into the MAC result to begin truncation. If this value is out of the range of 0 ... 15, then dynamic truncation will be used. Dynamic truncation is when the last 4 bits of the last byte of the MAC are used to determine the start offset.- Returns:
- A numeric String in base 10 that includes
codeDigits
digits plus the optional checksum digit if requested. - Throws:
NoSuchAlgorithmException
- if no provider makes either HmacSHA1 or HMAC-SHA-1 digest algorithms available.InvalidKeyException
- The secret provided was not a valid HMAC-SHA-1 key.
-
-