Fix totp_url export

* base32 unexported
* Secret comparison is now constant_time
This commit is contained in:
Cléo Rebert 2022-08-13 11:23:03 +02:00
parent 5abd752db8
commit 26416df28b
No known key found for this signature in database
GPG Key ID: 74E461C12B6038A3
3 changed files with 14 additions and 4 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "totp-rs"
version = "3.0.0"
version = "3.0.1"
authors = ["Cleo Rebert <cleo.rebert@gmail.com>"]
edition = "2021"
readme = "README.md"

View File

@ -52,9 +52,9 @@ mod rfc;
mod url_error;
pub use secret::{Secret, SecretParseError};
use url_error::TotpUrlError;
pub use url_error::TotpUrlError;
pub use rfc::{Rfc6238, Rfc6238Error};
pub use base32;
use base32;
use constant_time_eq::constant_time_eq;

View File

@ -80,13 +80,15 @@
use std::string::FromUtf8Error;
use base32::{self, Alphabet};
use constant_time_eq::constant_time_eq;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum SecretParseError {
ParseBase32,
Utf8Error(FromUtf8Error),
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, Eq)]
pub enum Secret {
/// represent a non-encoded "raw" secret
Raw(Vec<u8>),
@ -94,6 +96,14 @@ pub enum Secret {
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")]
impl Default for Secret {
fn default() -> Self {