diff --git a/src/_bcrypt/Cargo.lock b/src/_bcrypt/Cargo.lock index 30d2b46e..87cf5bb7 100644 --- a/src/_bcrypt/Cargo.lock +++ b/src/_bcrypt/Cargo.lock @@ -8,12 +8,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - [[package]] name = "base64" version = "0.21.2" @@ -26,7 +20,7 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28d1c9c15093eb224f0baa400f38fcd713fc1391a6f1c389d886beef146d60a3" dependencies = [ - "base64 0.21.2", + "base64", "blowfish", "getrandom", "subtle", @@ -48,7 +42,7 @@ dependencies = [ name = "bcrypt-rust" version = "0.1.0" dependencies = [ - "base64 0.13.1", + "base64", "bcrypt", "bcrypt-pbkdf", "pyo3", diff --git a/src/_bcrypt/Cargo.toml b/src/_bcrypt/Cargo.toml index bcf078a7..e4a32505 100644 --- a/src/_bcrypt/Cargo.toml +++ b/src/_bcrypt/Cargo.toml @@ -9,7 +9,7 @@ publish = false pyo3 = { version = "0.19.1" } bcrypt = "0.15" bcrypt-pbkdf = "0.10.0" -base64 = "0.13.1" +base64 = "0.21.1" [features] extension-module = ["pyo3/extension-module"] diff --git a/src/_bcrypt/src/lib.rs b/src/_bcrypt/src/lib.rs index b323e326..eea540f5 100644 --- a/src/_bcrypt/src/lib.rs +++ b/src/_bcrypt/src/lib.rs @@ -4,11 +4,17 @@ #![deny(rust_2018_idioms)] +use base64::Engine; use std::convert::TryInto; +pub const BASE64_ENGINE: base64::engine::GeneralPurpose = base64::engine::GeneralPurpose::new( + &base64::alphabet::BCRYPT, + base64::engine::general_purpose::NO_PAD, +); + #[pyo3::prelude::pyfunction] fn encode_base64<'p>(py: pyo3::Python<'p>, data: &[u8]) -> &'p pyo3::types::PyBytes { - let output = base64::encode_config(data, base64::BCRYPT); + let output = BASE64_ENGINE.encode(data); pyo3::types::PyBytes::new(py, output.as_bytes()) } @@ -44,7 +50,8 @@ fn hashpass<'p>( // The last component can contain either just the salt, or the salt and // the result hash, depending on if the `salt` value come from `hashpw` or // `gensalt`. - let raw_salt = base64::decode_config(&raw_parts[2][..22], base64::BCRYPT) + let raw_salt = BASE64_ENGINE + .decode(&raw_parts[2][..22]) .map_err(|_| pyo3::exceptions::PyValueError::new_err("Invalid salt"))? .try_into() .map_err(|_| pyo3::exceptions::PyValueError::new_err("Invalid salt"))?;