Fix #94 + Add slow-hash to CI (#96)

* Fixes #94

* add slow-hash testing to CI
This commit is contained in:
François Garillot
2020-12-04 18:32:23 -08:00
committed by GitHub
parent 9f414d4a82
commit 2794dfaaa9
2 changed files with 40 additions and 22 deletions
+4 -2
View File
@@ -7,6 +7,8 @@
use crate::{errors::InternalPakeError, hash::Hash};
use digest::Digest;
#[cfg(feature = "slow-hash")]
use generic_array::typenum::Unsigned;
use generic_array::GenericArray;
/// Used for the slow hashing function in OPAQUE
@@ -34,9 +36,9 @@ impl<D: Hash> SlowHash<D> for scrypt::ScryptParams {
input: GenericArray<u8, <D as Digest>::OutputSize>,
) -> Result<Vec<u8>, InternalPakeError> {
let params = scrypt::ScryptParams::new(15, 8, 1).unwrap();
let mut output = [0u8; <D as Digest>::OutputSize::to_usize()];
let mut output = vec![0u8; <D as Digest>::OutputSize::to_usize()];
scrypt::scrypt(&input, &[], &params, &mut output)
.map_err(|_| InternalPakeError::SlowHashError)?;
Ok(output.to_vec())
Ok(output)
}
}