[−][src]Module libreauth::oath
HOTP and TOTP authentication module.
Examples
let key_ascii = "12345678901234567890".to_owned(); let mut hotp = libreauth::oath::HOTPBuilder::new() .ascii_key(&key_ascii) .finalize() .unwrap(); let code = hotp.generate(); assert_eq!(code, "755224"); assert!(hotp.is_valid(&"755224".to_owned())); let code = hotp.increment_counter().generate(); assert_eq!(code, "287082"); assert!(hotp.is_valid(&"287082".to_owned()));
let key_base32 = "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ".to_owned(); let mut totp = libreauth::oath::TOTPBuilder::new() .base32_key(&key_base32) .finalize() .unwrap(); let code = totp.generate(); println!("TOTP code: {}", code); assert!(totp.is_valid(&code));
Structs
HOTP | Generates, manipulates and checks HOTP codes. |
HOTPBuilder | Builds an HOTP object. |
HOTPcfg | [C binding] HOTP configuration storage |
KeyUriBuilder | Creates the Key Uri Format according to the Google authenticator
specification by calling
|
TOTP | Generates and checks TOTP codes. |
TOTPBuilder | Builds a TOTP object. |
TOTPcfg | [C binding] TOTP configuration storage |
Enums
ErrorCode | Error codes used both in the rust and C interfaces. |
HashFunction | Hash functions used for the code's computation. |
ParametersVisibility | Defines the base policy for showing or hiding parameters in a Key URI. |
Functions
libreauth_hotp_generate | [C binding] Generate an HOTP code according to the given configuration and stores it in the supplied buffer. |
libreauth_hotp_init | [C binding] Initialize a |
libreauth_hotp_is_valid | [C binding] Check whether or not the supplied HOTP code is valid. |
libreauth_totp_generate | [C binding] Generate a TOTP code according to the given configuration and stores it in the supplied buffer. |
libreauth_totp_init | [C binding] Initialize a |
libreauth_totp_is_valid | [C binding] Initialize a |