diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2022-05-04 08:03:21 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-04 09:03:21 -0500 |
commit | b18c8c31a3090a069be6121b9a8193856191d783 (patch) | |
tree | 5804266a8c6ce499ab34715d36364ccbfcf21b28 | |
parent | d808f5de21ff13f43ddb0492ea34a6d49004d9a7 (diff) | |
download | py-bcrypt-git-b18c8c31a3090a069be6121b9a8193856191d783.tar.gz |
Update Rust bcrypt to 0.13 (#327)
-rw-r--r-- | src/_bcrypt/Cargo.lock | 4 | ||||
-rw-r--r-- | src/_bcrypt/Cargo.toml | 2 | ||||
-rw-r--r-- | src/_bcrypt/src/lib.rs | 6 |
3 files changed, 8 insertions, 4 deletions
diff --git a/src/_bcrypt/Cargo.lock b/src/_bcrypt/Cargo.lock index 5847cd5..32795a8 100644 --- a/src/_bcrypt/Cargo.lock +++ b/src/_bcrypt/Cargo.lock @@ -16,9 +16,9 @@ checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[package]] name = "bcrypt" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fe4fef31efb0f76133ae8e3576a88e58edb7cfc5584c81c758c349ba46b43fc" +checksum = "a7e7c93a3fb23b2fdde989b2c9ec4dd153063ec81f408507f84c090cd91c6641" dependencies = [ "base64", "blowfish", diff --git a/src/_bcrypt/Cargo.toml b/src/_bcrypt/Cargo.toml index 64b8af6..6c75126 100644 --- a/src/_bcrypt/Cargo.toml +++ b/src/_bcrypt/Cargo.toml @@ -7,7 +7,7 @@ publish = false [dependencies] pyo3 = { version = "0.15.2" } -bcrypt = "0.12" +bcrypt = "0.13" bcrypt-pbkdf = "0.8.1" base64 = "0.13.0" diff --git a/src/_bcrypt/src/lib.rs b/src/_bcrypt/src/lib.rs index 1a72c3f..ba54c3a 100644 --- a/src/_bcrypt/src/lib.rs +++ b/src/_bcrypt/src/lib.rs @@ -4,6 +4,8 @@ #![deny(rust_2018_idioms)] +use std::convert::TryInto; + #[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); @@ -41,9 +43,11 @@ fn hashpass<'p>( // 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) + .map_err(|_| pyo3::exceptions::PyValueError::new_err("Invalid salt"))? + .try_into() .map_err(|_| pyo3::exceptions::PyValueError::new_err("Invalid salt"))?; - let hashed = bcrypt::hash_with_salt(password, cost, &raw_salt).unwrap(); + let hashed = bcrypt::hash_with_salt(password, cost, raw_salt).unwrap(); Ok(pyo3::types::PyBytes::new( py, hashed.format_for_version(bcrypt::Version::TwoB).as_bytes(), |