pub struct HOTP { /* private fields */ }
Expand description
Implementations§
Source§impl HOTP
impl HOTP
Sourcepub fn new(algorithm: HOTPAlgorithm) -> Result<HOTP, Unspecified>
pub fn new(algorithm: HOTPAlgorithm) -> Result<HOTP, Unspecified>
Creates a new HOTPSecret from OS generated random number.
§Arguments
algorithm
- Algorithm to use for OTP generation.
Sourcepub fn from_bin(data: &[u8]) -> Result<HOTP, ()>
pub fn from_bin(data: &[u8]) -> Result<HOTP, ()>
Loads the HOTP secret from a given [u8]
.
§Arguments
data
- The shared secret.algorithm
- Algorithm used for OTP generation.
Sourcepub fn get_secret_base32(&self) -> String
pub fn get_secret_base32(&self) -> String
Exports the HOTP Secret as base32 encoded string.
Sourcepub fn get_otp(&self, counter: &[u8], digits: u32) -> u32
pub fn get_otp(&self, counter: &[u8], digits: u32) -> u32
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.
Sourcepub fn validate(&self, counter: &[u8], digits: u32, guess: u32) -> bool
pub fn validate(&self, counter: &[u8], digits: u32, guess: u32) -> bool
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.
Auto Trait Implementations§
impl Freeze for HOTP
impl RefUnwindSafe for HOTP
impl Send for HOTP
impl Sync for HOTP
impl Unpin for HOTP
impl UnwindSafe for HOTP
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more