Skip to content

Commit

Permalink
Update default configuration for SCryptPasswordEncoder
Browse files Browse the repository at this point in the history
The recommended minimums for scrypt, as per OWASP Cheat Sheet Series (https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html), are:
Use scrypt with a minimum CPU/memory cost parameter of (2^16), a minimum block size of 8 (1024 bytes), and a parallelization parameter of 1.

Previous default configuration:
cpuCost=16384, memoryCost=8, parallelism=1

New default configuration:
cpuCost=65536, memoryCost=8, parallelism=1

The default salt length was also updated from 64 to 16.

Issue spring-projectsgh-10506
  • Loading branch information
jgrandja committed Oct 4, 2022
1 parent e0c49a4 commit e81a30b
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -58,6 +58,16 @@
*/
public class SCryptPasswordEncoder implements PasswordEncoder {

private static final int DEFAULT_CPU_COST = 65536;

private static final int DEFAULT_MEMORY_COST = 8;

private static final int DEFAULT_PARALLELISM = 1;

private static final int DEFAULT_KEY_LENGTH = 32;

private static final int DEFAULT_SALT_LENGTH = 16;

private final Log logger = LogFactory.getLog(getClass());

private final int cpuCost;
Expand All @@ -71,7 +81,7 @@ public class SCryptPasswordEncoder implements PasswordEncoder {
private final BytesKeyGenerator saltGenerator;

public SCryptPasswordEncoder() {
this(16384, 8, 1, 32, 64);
this(DEFAULT_CPU_COST, DEFAULT_MEMORY_COST, DEFAULT_PARALLELISM, DEFAULT_KEY_LENGTH, DEFAULT_SALT_LENGTH);
}

/**
Expand Down

0 comments on commit e81a30b

Please sign in to comment.