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
+1 -1
View File
@@ -70,7 +70,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: hecrj/setup-rust-action@v1
- run: cargo test --verbose --features scrypt,argon --no-default-features --features ${{ matrix.backend_feature }}
- run: cargo test --verbose --features slow-hash --no-default-features --features ${{ matrix.backend_feature }}
serde-test:
name: Test on ${{ matrix.target }} with serde support
Generated
-35
View File
@@ -624,7 +624,6 @@ dependencies = [
"proptest",
"rand 0.8.3",
"rustyline",
"scrypt",
"serde",
"serde_json",
"sha2",
@@ -644,15 +643,6 @@ dependencies = [
"subtle",
]
[[package]]
name = "pbkdf2"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3b8c0d71734018084da0c0354193a5edfb81b20d2d57a92c5b154aefc554a4a"
dependencies = [
"crypto-mac 0.10.0",
]
[[package]]
name = "plotters"
version = "0.3.0"
@@ -954,15 +944,6 @@ version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
[[package]]
name = "salsa20"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "399f290ffc409596022fce5ea5d4138184be4784f2b28c62c59f0d8389059a15"
dependencies = [
"cipher",
]
[[package]]
name = "same-file"
version = "1.0.6"
@@ -978,22 +959,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "scrypt"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8da492dab03f925d977776a0b7233d7b934d6dc2b94faead48928e2e9bacedb9"
dependencies = [
"base64",
"hmac",
"pbkdf2",
"rand 0.7.3",
"rand_core 0.5.1",
"salsa20",
"sha2",
"subtle",
]
[[package]]
name = "semver"
version = "0.9.0"
+1 -2
View File
@@ -11,7 +11,7 @@ readme = "README.md"
[features]
default = ["u64_backend", "serialize"]
argon = ["argon2"]
slow-hash = ["argon2"]
bench = []
u64_backend = ["curve25519-dalek/u64_backend"]
u32_backend = ["curve25519-dalek/u32_backend"]
@@ -28,7 +28,6 @@ generic-bytes = { version = "0.1.0" }
hkdf = "0.10.0"
hmac = "0.10.1"
rand = "0.8"
scrypt = { version = "0.5.0", optional = true }
serde = { version = "1", optional = true }
subtle = { version = "2.3.0", default-features = false }
thiserror = "1.0.22"
+3 -6
View File
@@ -32,8 +32,8 @@
//! for a working example of a simple password-based login using OPAQUE.
//!
//! Note that our choice of slow hashing function in this example, `NoOpHash`, is selected only to ensure
//! that the tests execute quickly. A real application should use an actual slow hashing function, such as `scrypt`,
//! which can be enabled through the `scrypt` feature. See more details in the [features](#features) section.
//! that the tests execute quickly. A real application should use an actual slow hashing function, such as `Argon2`,
//! which can be enabled through the `slow-hash` feature. See more details in the [features](#features) section.
//!
//! ## Setup
//! To set up the protocol, the server begins by creating a `ServerSetup` object:
@@ -718,16 +718,13 @@
//!
//! # Features
//!
//! - The `scrypt` feature, when enabled, introduces a dependency on `scrypt` and implements the `SlowHash` trait for `scrypt`
//! - The `slow-hash` feature, when enabled, introduces a dependency on `argon2` and implements the `SlowHash` trait for `Argon2`
//! with a set of default parameters. In general, secure instantiations should choose to invoke a memory-hard password
//! hashing function when the client's password is expected to have low entropy, instead of relying on [slow_hash::NoOpHash]
//! as done in the above example. The more computationally intensive the `SlowHash` function is, the more resistant the server's
//! password file records will be against offline dictionary and precomputation attacks; see
//! [the OPAQUE paper](https://eprint.iacr.org/2018/163.pdf) for more details.
//!
//! - The `argon` feature, when enabled, introduces a dependency on `argon2` and implements the `SlowHash` trait for `argon2`
//! with default parameters. This is an alternative to `scrypt`.
//!
//! - The `serialize` feature, enabled by default, provides convenience functions for serializing and deserializing with
//! [serde](https://serde.rs/).
//!
+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>,