public class TOTPGenerator extends AbstractOTPGenerator
Constructor and Description |
---|
TOTPGenerator() |
Modifier and Type | Method and Description |
---|---|
protected long |
currentTime() |
int |
generate(byte[] key)
Generates the OTP given a per-user key.
|
protected org.bouncycastle.crypto.Digest |
getDigest() |
Spec<org.bouncycastle.crypto.Digest> |
getDigestSpecification() |
int |
getStartTime() |
int |
getTimeStep() |
protected void |
setCurrentTime(long epochSeconds)
Sets the current time (supports testing).
|
void |
setDigestSpecification(Spec<org.bouncycastle.crypto.Digest> specification)
Sets the digest algorithm used with the HMAC function.
|
void |
setStartTime(int seconds)
Sets the reference start time, T0.
|
void |
setTimeStep(int seconds)
Sets the time step, X.
|
generateInternal, getNumberOfDigits, setNumberOfDigits
public Spec<org.bouncycastle.crypto.Digest> getDigestSpecification()
public void setDigestSpecification(Spec<org.bouncycastle.crypto.Digest> specification)
specification
- SHA-1, SHA-256, or SHA-512 digest specification.public int getStartTime()
public void setStartTime(int seconds)
seconds
- Start time in seconds.public int getTimeStep()
public void setTimeStep(int seconds)
seconds
- Time step in seconds. Default is 30. This value determines the validity window of generated OTP
values.public int generate(byte[] key)
key
- Per-user key.protected org.bouncycastle.crypto.Digest getDigest()
getDigest
in class AbstractOTPGenerator
protected void setCurrentTime(long epochSeconds)
epochSeconds
- Seconds since the start of the epoch, 1970-01-01T00:00:00.protected long currentTime()
Copyright © 2003-2024 Virginia Tech. All Rights Reserved.