Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.apache.shiro.crypto.hash.format.HashFormatFactory;
import org.apache.shiro.crypto.hash.format.HexFormat;
import org.apache.shiro.crypto.hash.format.Shiro2CryptFormat;
import org.apache.shiro.crypto.support.hashes.argon2.Argon2HashProvider;
import org.apache.shiro.lang.codec.Base64;
import org.apache.shiro.lang.codec.Hex;
import org.apache.shiro.lang.io.ResourceUtils;
Expand Down Expand Up @@ -75,7 +74,7 @@ public final class Hasher {
private static final String DEFAULT_PASSWORD_ALGORITHM_NAME = DefaultPasswordService.DEFAULT_HASH_ALGORITHM;
private static final int DEFAULT_GENERATED_SALT_SIZE = 128;
private static final int DEFAULT_NUM_ITERATIONS = 1;
private static final int DEFAULT_PASSWORD_NUM_ITERATIONS = Argon2HashProvider.Parameters.DEFAULT_ITERATIONS;
private static final int DEFAULT_PASSWORD_NUM_ITERATIONS = 350_000;

private static final Option ALGORITHM =
new Option("a", "algorithm", true,
Expand Down Expand Up @@ -255,10 +254,9 @@ public static void main(String[] args) {
} else {
iterations = DEFAULT_NUM_ITERATIONS;
}
} else {
//Iterations were specified, so add the iterations parameter:
parameters.put(SimpleHashProvider.Parameters.PARAMETER_ITERATIONS, iterations);
}
//Iterations were specified, so add the iterations parameter:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me this not correct because we want to insure that the iterations parameter specified by the user is not too weak.

parameters.put(SimpleHashProvider.Parameters.PARAMETER_ITERATIONS, iterations);

ByteSource publicSalt = getSalt(saltString, saltBytesString, generateSalt, generatedSaltSize);
HashRequest hashRequest = new SimpleHashRequest(algorithm, ByteSource.Util.bytes(source), publicSalt, parameters);
Expand Down