From e4e055dedddc012cd691dc7156ee707843dd8105 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9o=20REBERT?= Date: Tue, 28 Mar 2023 10:47:52 +0200 Subject: [PATCH 1/4] 5.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cléo REBERT --- CHANGELOG.md | 17 ++++++++++++++++- Cargo.toml | 12 ++++++------ examples/steam.rs | 9 ++------- src/secret.rs | 12 ++++++++++-- 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0beeb99..1b3fcf7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,18 @@ +# [5.0](https://github.com/constantoine/totp-rs/releases/tag/v4.2) (28/03/2023) +### Breaking changes. +- MSRV has been set to Rust `1.61`. +- Removed `SecretParseError::Utf8Error`. + +### Changes +- Updated `url` to `2.3`. +- Updated `zeroize` to `1.6`. + +### Note +This major release is a very small one, and is mostly here to respect semver. No major change was done, it is mostly maintenance and cleanup. + +### Special thanks +* [@bestia-dev](https://github.com/bestia-dev) for opening #55. + # [4.2](https://github.com/constantoine/totp-rs/releases/tag/v4.2) (14/01/2023) ### Changes - Optionnals parameters in generated URLs are no longer present if their're the default value. (#49) @@ -22,7 +37,7 @@ - Default features have been set to none. ### Changes -- MSRV have been set to Rust `1.59`. +- MSRV has been set to Rust `1.59`. - Updated `base64` crate to `0.20`. ### Breaking changes diff --git a/Cargo.toml b/Cargo.toml index 7aea3df..4349276 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "totp-rs" -version = "4.2.0" +version = "5.0.0" authors = ["Cleo Rebert "] -rust-version = "1.59" +rust-version = "1.61" edition = "2021" readme = "README.md" license = "MIT" @@ -16,7 +16,7 @@ categories = ["authentication", "web-programming"] features = [ "qr", "serde_support", "gen_secret" ] [features] -default = [] +default = ["qr"] otpauth = ["url", "urlencoding"] qr = ["qrcodegen", "image", "base64", "otpauth"] serde_support = ["serde"] @@ -30,10 +30,10 @@ sha1 = "~0.10.5" hmac = "~0.12.1" base32 = "~0.4" urlencoding = { version = "^2.1.0", optional = true} -url = { version = "^2.2.2", optional = true } +url = { version = "^2.3.1", optional = true } constant_time_eq = "0.2.4" qrcodegen = { version = "~1.8", optional = true } image = { version = "~0.24.2", features = ["png"], optional = true, default-features = false} -base64 = { version = "~0.20", optional = true } +base64 = { version = "~0.21", optional = true } rand = { version = "~0.8.5", features = ["std_rng", "std"], optional = true, default-features = false } -zeroize = { version = "1.5.7", features = ["alloc", "derive"], optional = true } \ No newline at end of file +zeroize = { version = "1.6.0", features = ["alloc", "derive"], optional = true } \ No newline at end of file diff --git a/examples/steam.rs b/examples/steam.rs index 45536b6..5c2d20a 100644 --- a/examples/steam.rs +++ b/examples/steam.rs @@ -6,10 +6,7 @@ use totp_rs::{Secret, TOTP}; fn main() { // create TOTP from base32 secret let secret_b32 = Secret::Encoded(String::from("OBWGC2LOFVZXI4TJNZTS243FMNZGK5BNGEZDG")); - let totp_b32 = TOTP::new_steam( - secret_b32.to_bytes().unwrap(), - "user-account".to_string(), - ); + let totp_b32 = TOTP::new_steam(secret_b32.to_bytes().unwrap(), "user-account".to_string()); println!( "base32 {} ; raw {}", @@ -41,6 +38,4 @@ fn main() { } #[cfg(not(feature = "steam"))] -fn main() { - -} \ No newline at end of file +fn main() {} diff --git a/src/secret.rs b/src/secret.rs index 9dabf89..4fbdfc1 100644 --- a/src/secret.rs +++ b/src/secret.rs @@ -78,16 +78,24 @@ //! ``` use base32::{self, Alphabet}; -use std::string::FromUtf8Error; use constant_time_eq::constant_time_eq; #[derive(Debug, Clone, PartialEq, Eq)] pub enum SecretParseError { ParseBase32, - Utf8Error(FromUtf8Error), } +impl std::fmt::Display for SecretParseError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + SecretParseError::ParseBase32 => write!(f, "Could not decode base32 secret."), + } + } +} + +impl std::error::Error for Secret {} + #[derive(Debug, Clone, Eq)] #[cfg_attr(feature = "zeroize", derive(zeroize::Zeroize, zeroize::ZeroizeOnDrop))] pub enum Secret { From c2ba6d190b2a4f626d93ace26bddf3974e041889 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9o=20REBERT?= Date: Tue, 28 Mar 2023 10:58:39 +0200 Subject: [PATCH 2/4] Replace deprecated base64 call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cléo REBERT --- src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 4c21243..c6a9b14 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -699,6 +699,7 @@ impl TOTP { #[cfg(feature = "qr")] pub fn get_qr(&self) -> Result { use image::ImageEncoder; + use base64::{Engine as _, engine::general_purpose}; let url = self.get_url(); let mut vec = Vec::new(); @@ -729,7 +730,7 @@ impl TOTP { image_size, image::ColorType::L8, ) { - Ok(_) => Ok(base64::encode(vec)), + Ok(_) => Ok(general_purpose::STANDARD.encode(vec)), Err(err) => Err(err.to_string()), } } From 08c24dae9666b5aafb0630d25b97dd17c6c36375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9o=20REBERT?= Date: Tue, 28 Mar 2023 11:03:04 +0200 Subject: [PATCH 3/4] Removed default feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cléo REBERT --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 4349276..fc7700f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ categories = ["authentication", "web-programming"] features = [ "qr", "serde_support", "gen_secret" ] [features] -default = ["qr"] +default = [] otpauth = ["url", "urlencoding"] qr = ["qrcodegen", "image", "base64", "otpauth"] serde_support = ["serde"] From f7d0f136d145ec02e72e6bc160a9b174135cd108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9o=20REBERT?= Date: Tue, 28 Mar 2023 11:04:15 +0200 Subject: [PATCH 4/4] Updated changelog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cléo REBERT --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b3fcf7..e531014 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Removed `SecretParseError::Utf8Error`. ### Changes +- Updated `base64` to `0.21`. - Updated `url` to `2.3`. - Updated `zeroize` to `1.6`.