Module libreauth::oath

source ·
Expand description

Implementation of standards which are part of the OATH Reference Architecture.

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

Enums

  • Errors used for the Rust interface.
  • Error codes used in the C interface.
  • Defines the base policy for showing or hiding parameters in a Key URI.

Functions