From 2794dfaaa9b40266c801b850cb3059485936cdcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Garillot?= <4142+huitseeker@users.noreply.github.com> Date: Fri, 4 Dec 2020 21:32:23 -0500 Subject: [PATCH] Fix #94 + Add slow-hash to CI (#96) * Fixes #94 * add slow-hash testing to CI --- .github/workflows/main.yml | 56 ++++++++++++++++++++++++-------------- src/slow_hash.rs | 6 ++-- 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 49f1755..9bc2047 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -35,26 +35,6 @@ jobs: command: test args: --no-default-features --features ${{ matrix.backend_feature }} - simple-login-test: - runs-on: ubuntu-latest - strategy: - fail-fast: false - name: test simple_login command-line example - steps: - - name: install expect - run: sudo apt-get install expect - - name: Checkout sources - uses: actions/checkout@v2 - - name: install rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - override: true - components: rustfmt, clippy - - name: Run expect (which then runs cargo run) - run: expect -f scripts/simple_login.exp - cross-test: name: Test on ${{ matrix.target }} (using cross) runs-on: ubuntu-latest @@ -75,6 +55,42 @@ jobs: # pass the `--target=${{ matrix.target }}` arg. (Yes, really). - run: cross test --verbose --target=${{ matrix.target }} --no-default-features --features ${{ matrix.backend_feature }} + + slow-hash-test: + name: Test on ${{ matrix.target }} with slow hash + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + backend_feature: + - u64_backend + - u32_backend + steps: + - uses: actions/checkout@v2 + - uses: hecrj/setup-rust-action@v1 + - run: cargo test --verbose --features slow-hash --no-default-features --features ${{ matrix.backend_feature }} + + + simple-login-test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + name: test simple_login command-line example + steps: + - name: install expect + run: sudo apt-get install expect + - name: Checkout sources + uses: actions/checkout@v2 + - name: install rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + override: true + components: rustfmt, clippy + - name: Run expect (which then runs cargo run) + run: expect -f scripts/simple_login.exp + benches: name: cargo bench compilation runs-on: ubuntu-latest diff --git a/src/slow_hash.rs b/src/slow_hash.rs index 5c51df8..8c94acf 100644 --- a/src/slow_hash.rs +++ b/src/slow_hash.rs @@ -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 SlowHash for scrypt::ScryptParams { input: GenericArray::OutputSize>, ) -> Result, InternalPakeError> { let params = scrypt::ScryptParams::new(15, 8, 1).unwrap(); - let mut output = [0u8; ::OutputSize::to_usize()]; + let mut output = vec![0u8; ::OutputSize::to_usize()]; scrypt::scrypt(&input, &[], ¶ms, &mut output) .map_err(|_| InternalPakeError::SlowHashError)?; - Ok(output.to_vec()) + Ok(output) } }