Fix totp_url export
* base32 unexported * Secret comparison is now constant_time
This commit is contained in:
parent
5abd752db8
commit
26416df28b
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "totp-rs"
|
name = "totp-rs"
|
||||||
version = "3.0.0"
|
version = "3.0.1"
|
||||||
authors = ["Cleo Rebert <cleo.rebert@gmail.com>"]
|
authors = ["Cleo Rebert <cleo.rebert@gmail.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
|
@ -52,9 +52,9 @@ mod rfc;
|
||||||
mod url_error;
|
mod url_error;
|
||||||
|
|
||||||
pub use secret::{Secret, SecretParseError};
|
pub use secret::{Secret, SecretParseError};
|
||||||
use url_error::TotpUrlError;
|
pub use url_error::TotpUrlError;
|
||||||
pub use rfc::{Rfc6238, Rfc6238Error};
|
pub use rfc::{Rfc6238, Rfc6238Error};
|
||||||
pub use base32;
|
use base32;
|
||||||
|
|
||||||
use constant_time_eq::constant_time_eq;
|
use constant_time_eq::constant_time_eq;
|
||||||
|
|
||||||
|
|
|
@ -80,13 +80,15 @@
|
||||||
use std::string::FromUtf8Error;
|
use std::string::FromUtf8Error;
|
||||||
use base32::{self, Alphabet};
|
use base32::{self, Alphabet};
|
||||||
|
|
||||||
|
use constant_time_eq::constant_time_eq;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum SecretParseError {
|
pub enum SecretParseError {
|
||||||
ParseBase32,
|
ParseBase32,
|
||||||
Utf8Error(FromUtf8Error),
|
Utf8Error(FromUtf8Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, Eq)]
|
||||||
pub enum Secret {
|
pub enum Secret {
|
||||||
/// represent a non-encoded "raw" secret
|
/// represent a non-encoded "raw" secret
|
||||||
Raw(Vec<u8>),
|
Raw(Vec<u8>),
|
||||||
|
@ -94,6 +96,14 @@ pub enum Secret {
|
||||||
Encoded(String),
|
Encoded(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PartialEq for Secret {
|
||||||
|
/// Will check that to_bytes() returns the same
|
||||||
|
/// One secret can be Raw, and the other Encoded
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
constant_time_eq(&self.to_bytes().unwrap(), &other.to_bytes().unwrap())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "gen_secret")]
|
#[cfg(feature = "gen_secret")]
|
||||||
impl Default for Secret {
|
impl Default for Secret {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
|
|
Loading…
Reference in New Issue