Remove scrypt

This commit is contained in:
daxpedda
2021-06-21 12:26:22 -07:00
committed by Kevin Lewi
parent 535b9b8ee4
commit ca50d92f96
5 changed files with 7 additions and 68 deletions
+2 -24
View File
@@ -7,7 +7,7 @@
use crate::{errors::InternalPakeError, hash::Hash};
use digest::Digest;
#[cfg(any(feature = "argon", feature = "scrypt"))]
#[cfg(feature = "slow-hash")]
use generic_array::typenum::Unsigned;
use generic_array::GenericArray;
@@ -30,29 +30,7 @@ impl<D: Hash> SlowHash<D> for NoOpHash {
}
}
#[cfg(feature = "scrypt")]
const DEFAULT_SCRYPT_LOG_N: u8 = 15u8;
#[cfg(feature = "scrypt")]
const DEFAULT_SCRYPT_R: u32 = 8u32;
#[cfg(feature = "scrypt")]
const DEFAULT_SCRYPT_P: u32 = 1u32;
#[cfg(feature = "scrypt")]
impl<D: Hash> SlowHash<D> for scrypt::ScryptParams {
fn hash(
input: GenericArray<u8, <D as Digest>::OutputSize>,
) -> Result<Vec<u8>, InternalPakeError> {
let params =
scrypt::ScryptParams::new(DEFAULT_SCRYPT_LOG_N, DEFAULT_SCRYPT_R, DEFAULT_SCRYPT_P)
.map_err(|_| InternalPakeError::SlowHashError)?;
let mut output = vec![0u8; <D as Digest>::OutputSize::to_usize()];
scrypt::scrypt(&input, &[], &params, &mut output)
.map_err(|_| InternalPakeError::SlowHashError)?;
Ok(output)
}
}
#[cfg(feature = "argon")]
#[cfg(feature = "slow-hash")]
impl<D: Hash> SlowHash<D> for argon2::Argon2<'_> {
fn hash(
input: GenericArray<u8, <D as Digest>::OutputSize>,