clarifies doc for `secret`: should be non-encoded
This commit is contained in:
parent
181d17edcc
commit
3bdb91fad7
13
src/lib.rs
13
src/lib.rs
|
@ -45,6 +45,8 @@
|
||||||
//! # }
|
//! # }
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
|
pub use base32;
|
||||||
|
|
||||||
use constant_time_eq::constant_time_eq;
|
use constant_time_eq::constant_time_eq;
|
||||||
|
|
||||||
#[cfg(feature = "serde_support")]
|
#[cfg(feature = "serde_support")]
|
||||||
|
@ -144,6 +146,8 @@ pub struct TOTP<T = Vec<u8>> {
|
||||||
/// Duration in seconds of a step. The recommended value per [rfc-6238](https://tools.ietf.org/html/rfc6238#section-5.2) is 30 seconds
|
/// Duration in seconds of a step. The recommended value per [rfc-6238](https://tools.ietf.org/html/rfc6238#section-5.2) is 30 seconds
|
||||||
pub step: u64,
|
pub step: u64,
|
||||||
/// As per [rfc-4226](https://tools.ietf.org/html/rfc4226#section-4) the secret should come from a strong source, most likely a CSPRNG. It should be at least 128 bits, but 160 are recommended
|
/// As per [rfc-4226](https://tools.ietf.org/html/rfc4226#section-4) the secret should come from a strong source, most likely a CSPRNG. It should be at least 128 bits, but 160 are recommended
|
||||||
|
///
|
||||||
|
/// non-encoded value
|
||||||
pub secret: T,
|
pub secret: T,
|
||||||
/// The "Github" part of "Github:constantoine@github.com". Must not contain a colon `:`
|
/// The "Github" part of "Github:constantoine@github.com". Must not contain a colon `:`
|
||||||
/// For example, the name of your service/website.
|
/// For example, the name of your service/website.
|
||||||
|
@ -177,6 +181,15 @@ impl <T: AsRef<[u8]>> PartialEq for TOTP<T> {
|
||||||
impl<T: AsRef<[u8]>> TOTP<T> {
|
impl<T: AsRef<[u8]>> TOTP<T> {
|
||||||
/// Will create a new instance of TOTP with given parameters. See [the doc](struct.TOTP.html#fields) for reference as to how to choose those values
|
/// Will create a new instance of TOTP with given parameters. See [the doc](struct.TOTP.html#fields) for reference as to how to choose those values
|
||||||
///
|
///
|
||||||
|
/// # Description
|
||||||
|
/// * `secret`: expect a non-encoded value, base32 encoded values should be decoded beforehand
|
||||||
|
/// ```
|
||||||
|
/// use totp_rs::{base32, TOTP, Algorithm};
|
||||||
|
/// let secret = String::from("NV4S243FMNZGK5A");
|
||||||
|
/// let decoded = base32::decode(base32::Alphabet::RFC4648 { padding: false }, &secret).unwrap();
|
||||||
|
/// let totp = TOTP::new(Algorithm::SHA1, 6, 1, 30, decoded, None, "".to_string()).unwrap();
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
///
|
///
|
||||||
/// Will return an error in case issuer or label contain the character ':'
|
/// Will return an error in case issuer or label contain the character ':'
|
||||||
|
|
Loading…
Reference in New Issue