diff --git a/src/argon2.rs b/src/argon2.rs index 9bfb425..ef694f1 100644 --- a/src/argon2.rs +++ b/src/argon2.rs @@ -69,6 +69,7 @@ fn h0(lanes: u32, hash_length: u32, memory_kib: u32, passes: u32, version: u32, /// Main entry point for running Argon2 on customized parameters (cf. note for /// `Argon2::new`). +#[derive(Debug, Eq, PartialEq)] pub struct Argon2 { passes: u32, lanes: u32, diff --git a/src/verifier.rs b/src/verifier.rs index edf48ce..580f50c 100644 --- a/src/verifier.rs +++ b/src/verifier.rs @@ -203,6 +203,7 @@ impl Error for DecodeError { /// Represents a single Argon2 hashing session. A hash session comprises of the /// hash algorithm parameters, salt, key, and data used to hash a given input. +#[derive(Debug, Eq, PartialEq)] pub struct Encoded { params: Argon2, hash: Vec, @@ -438,6 +439,16 @@ mod test { } } + #[test] + fn encode_decode() { + for &(s, _) in BASE64_CASES.iter() { + let salt = b"Yum! Extra salty"; + let key = b"ff5dfa4d7a048f9db4ad0caad82e75c"; + let enc = Encoded::default2i(s, salt, key, &[]); + assert_eq!(Encoded::from_u8(&enc.to_u8()), Ok(enc)); + } + } + #[test] fn bad_encoded() { use super::DecodeError::*; diff --git a/travis.sh b/travis.sh index bfce6fc..b4b60d3 100755 --- a/travis.sh +++ b/travis.sh @@ -1,3 +1,5 @@ +#!/bin/sh +set -e cargo build cargo test