Package org.cryptacular.generator
Class AbstractOTPGenerator
java.lang.Object
org.cryptacular.generator.AbstractOTPGenerator
- Direct Known Subclasses:
HOTPGenerator,TOTPGenerator
- Author:
- Middleware Services
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intDefault number of digits to generate. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new abstract OTP generator.AbstractOTPGenerator(int numberOfDigits) Creates a new abstract OTP generator. -
Method Summary
Modifier and TypeMethodDescriptionprotected intgenerateInternal(byte[] key, long count) Internal OTP generation method.protected abstract org.bouncycastle.crypto.Digestint
-
Field Details
-
DEFAULT_NUMBER_OF_DIGITS
protected static final int DEFAULT_NUMBER_OF_DIGITSDefault number of digits to generate.- See Also:
-
-
Constructor Details
-
AbstractOTPGenerator
public AbstractOTPGenerator()Creates a new abstract OTP generator. -
AbstractOTPGenerator
public AbstractOTPGenerator(int numberOfDigits) Creates a new abstract OTP generator.- Parameters:
numberOfDigits- Number of digits in generated OTP. MUST be in the range 6 - 9.
-
-
Method Details
-
getNumberOfDigits
public int getNumberOfDigits()- Returns:
- Number of digits in generated OTP.
-
generateInternal
protected int generateInternal(byte[] key, long count) Internal OTP generation method.- Parameters:
key- Per-user key.count- Counter moving factor.- Returns:
- Integer OTP.
-
getDigest
protected abstract org.bouncycastle.crypto.Digest getDigest()- Returns:
- Digest algorithm used for HMAC operation.
-