Adding slow-hash feature
This commit is contained in:
+4
-1
@@ -9,6 +9,9 @@ license = "MIT"
|
||||
edition = "2018"
|
||||
readme = "README.md"
|
||||
|
||||
[features]
|
||||
slow-hash = ["scrypt"]
|
||||
|
||||
[dependencies]
|
||||
aead = "0.2.0"
|
||||
curve25519-dalek = "2.0.0"
|
||||
@@ -16,7 +19,7 @@ generic-array = "0.12.3"
|
||||
hkdf = "0.8.0"
|
||||
hmac = "0.7.1"
|
||||
rand_core = "0.5.1"
|
||||
scrypt = "0.2.0"
|
||||
scrypt = {version = "0.2.0", optional = true}
|
||||
sha2 = "0.8"
|
||||
thiserror = "1"
|
||||
x25519-dalek = "0.6.0"
|
||||
|
||||
+5
-6
@@ -6,7 +6,6 @@
|
||||
use crate::errors::InternalPakeError;
|
||||
|
||||
use generic_array::GenericArray;
|
||||
use scrypt::{scrypt, ScryptParams};
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
pub trait SlowHash {
|
||||
@@ -25,15 +24,15 @@ impl SlowHash for NoOpHash {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Scrypt;
|
||||
|
||||
impl SlowHash for Scrypt {
|
||||
#[cfg(feature = "slow-hash")]
|
||||
impl SlowHash for scrypt::ScryptParams {
|
||||
fn hash(
|
||||
input: GenericArray<u8, <Sha256 as Digest>::OutputSize>,
|
||||
) -> Result<Vec<u8>, InternalPakeError> {
|
||||
let params = ScryptParams::new(15, 8, 1).unwrap();
|
||||
let params = scrypt::ScryptParams::new(15, 8, 1).unwrap();
|
||||
let mut output = [0u8; 32];
|
||||
scrypt(&input, &[], ¶ms, &mut output).map_err(|_| InternalPakeError::SlowHashError)?;
|
||||
scrypt::scrypt(&input, &[], ¶ms, &mut output)
|
||||
.map_err(|_| InternalPakeError::SlowHashError)?;
|
||||
Ok(output.to_vec())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user