Struct libotp::HOTP
[−]
[src]
pub struct HOTP { /* fields omitted */ }
This is the secret that will be used to generate HMAC based one-time-passwords.
References
- This object implements utilities for RFC4226.
Methods
impl HOTP
[src]
fn new(algorithm: HOTPAlgorithm) -> Result<HOTP, Unspecified>
[src]
Creates a new HOTPSecret from OS generated random number.
Arguments
algorithm
- Algorithm to use for OTP generation.
fn from_base32(data: &str) -> Result<HOTP, ()>
[src]
fn from_bin(data: &[u8]) -> Result<HOTP, ()>
[src]
Loads the HOTP secret from a given [u8]
.
Arguments
data
- The shared secret.algorithm
- Algorithm used for OTP generation.
fn get_secret_base32(&self) -> String
[src]
Exports the HOTP Secret as base32 encoded string.
fn get_otp(&self, counter: &[u8], digits: u32) -> u32
[src]
Generates a One Time Password from the provided parameters.
Arguments
counter
- Password's counter. This counter value should never be reused for security reasons.digits
- Desired OTP length, this value should be at least 6.
fn validate(&self, counter: &[u8], digits: u32, guess: u32) -> bool
[src]
Validates the given OTP
Arguments
counter
- The counter to test against.digits
- The OTPs length.guess
- A user provided guess to validate.
Note
It is recommended to check the following counters in case the user skipped an OTP. You should verify that an OTP with the same counter was not already used.