Skip to content
Snippets Groups Projects
Commit a556e6971f0c authored by Alex Gaynor's avatar Alex Gaynor
Browse files

Update Rust bcrypt to 0.13 (#327)

parent efa78c7e8d07
No related branches found
No related tags found
No related merge requests found
......@@ -16,5 +16,5 @@
[[package]]
name = "bcrypt"
version = "0.12.1"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
......@@ -20,5 +20,5 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fe4fef31efb0f76133ae8e3576a88e58edb7cfc5584c81c758c349ba46b43fc"
checksum = "a7e7c93a3fb23b2fdde989b2c9ec4dd153063ec81f408507f84c090cd91c6641"
dependencies = [
"base64",
"blowfish",
......
......@@ -7,7 +7,7 @@
[dependencies]
pyo3 = { version = "0.15.2" }
bcrypt = "0.12"
bcrypt = "0.13"
bcrypt-pbkdf = "0.8.1"
base64 = "0.13.0"
......
......@@ -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,5 +43,7 @@
// 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"))?;
......@@ -44,6 +48,6 @@
.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(),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment