diff --git a/Cargo.lock b/Cargo.lock index 4345d7e91..fb0d51376 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -371,6 +371,12 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +[[package]] +name = "base64" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea22880d78093b0cbe17c89f64a7d457941e65759157ec6cb31a31d652b05e5" + [[package]] name = "base64ct" version = "1.5.1" @@ -877,7 +883,7 @@ dependencies = [ "async-smtp", "async_zip", "backtrace", - "base64 0.13.1", + "base64 0.20.0", "bitflags", "chrono", "criterion", diff --git a/Cargo.toml b/Cargo.toml index 91d56d4af..e8f36abe3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ trust-dns-resolver = "0.22" tokio = { version = "1", features = ["fs", "rt-multi-thread", "macros"] } tokio-tar = { version = "0.3" } # TODO: integrate tokio into async-tar backtrace = "0.3" -base64 = "0.13" +base64 = "0.20" bitflags = "1.3" chrono = { version = "0.4", default-features=false, features = ["clock", "std"] } dirs = { version = "4", optional=true } diff --git a/src/tools.rs b/src/tools.rs index b766dc73e..b02ed2fea 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -277,6 +277,12 @@ async fn maybe_warn_on_outdated(context: &Context, now: i64, approx_compile_time /// - for INCOMING messages, the ID is taken from the Chat-Group-ID-header or from the Message-ID in the In-Reply-To: or References:-Header /// - the group-id should be a string with the characters [a-zA-Z0-9\-_] pub(crate) fn create_id() -> String { + const URL_SAFE_ENGINE: base64::engine::fast_portable::FastPortable = + base64::engine::fast_portable::FastPortable::from( + &base64::alphabet::URL_SAFE, + base64::engine::fast_portable::NO_PAD, + ); + // ThreadRng implements CryptoRng trait and is supposed to be cryptographically secure. let mut rng = thread_rng(); @@ -285,7 +291,7 @@ pub(crate) fn create_id() -> String { rng.fill(&mut arr[..]); // Take 11 base64 characters containing 66 random bits. - base64::encode_config(arr, base64::URL_SAFE) + base64::encode_engine(arr, &URL_SAFE_ENGINE) .chars() .take(11) .collect()