Fold a few panics

Removes a few panics we don't need by folding them in the Error case of their enclosing Result return.
This commit is contained in:
François Garillot
2020-12-09 13:10:05 -08:00
parent 94630dff7c
commit 6b22064863
4 changed files with 35 additions and 48 deletions
+2 -1
View File
@@ -35,7 +35,8 @@ 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(15, 8, 1).unwrap();
let params =
scrypt::ScryptParams::new(15, 8, 1).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)?;