Struct otpshka::TOTP[][src]

pub struct TOTP {
    pub skew: u8,
    pub window: u64,
    // some fields omitted
}

Modification of Htop algorithm that uses unix timestamp within window

Fields

skew: u8

Number of seconds allowed as network delay.

Default and recommended is 1.

window: u64

Time window in seconds.

Default and recommended is 30.

Implementations

impl TOTP[src]

pub fn new<T: AsRef<[u8]>>(algorithm: Algorithm, secret: T) -> Self[src]

Initializes algorithm using provided algorithm and secret

  • algorithm - Generally acceptable are HMAC based on sha-1, sha-256 and sha-512
  • secret - Raw bytes used to derive HMAC key. User is responsible to decode it before passing.

pub fn sign(&self, time: u64) -> impl AsRef<[u8]> + Clone + Copy[src]

Signs provided time value using stored HMAC key.

pub fn generate_num(&self, time: u64, digits: u8) -> u32[src]

Generates password as number from provided counter value with length of digits.

Note that in this case you must handle missing padding yourself.

pub fn generate_to<T: AsMut<[u8]>>(&self, time: u64, dest: T)[src]

Generates pass based on provided time and writes it into provided dest.

This always writes dest.as_ref().len().

Recommended buffer length is be within 6..8

pub fn generate_to_now<T: AsMut<[u8]>>(&self, dest: T)[src]

Generates pass using current system time from std

pub fn verify(&self, token: &str, time: u64) -> bool[src]

Checks whether provided token corresponds to time.

pub fn verify_now(&self, token: &str) -> bool[src]

Checks whether provided token corresponds to current system time.

Auto Trait Implementations

impl RefUnwindSafe for TOTP

impl Send for TOTP

impl Sync for TOTP

impl Unpin for TOTP

impl UnwindSafe for TOTP

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.