-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Make salt length configurable in Pbkdf2PasswordEncoder #9147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Can you please remove any unrelated changes. For example, the changes for matches
test is not related https://github.com/spring-projects/spring-security/pull/9147/files#diff-b33c45ec3428094cc83f413049097a5d95d3cf54f43d7f13d372be66e82cdd0dR46-R52
I modified the tests to ensure that the "default" instance and the custom salt length instance pass same kind of tests with success. I think that simply adding But if you want, i can revert changes on |
@rikles Thanks for the response. I'd like existing tests to stay the same, so let's leave |
Hello @rwinch. It's my first PR on Spring Security, so i've to adjust my work to this project test philosophy... My approach is to group tests by aims like before (ex: What do you think about this ? If you prefer seperate methods, i plan to add those methods, is that OK ? :
|
Thanks. I do prefer adding the additional methods. That ensures that we know exactly what broke just by seeing the name of the test failure. The test method names you have proposed look good to me. Thanks! |
Add constructors with a salt length input parameter. Default salt length is still 8-byte long like before when saltGenerator was initialized with call to KeyGenerators#secureRandom() which use SecureRandomBytesKeyGenerator#DEFAULT_KEY_LENGTH. Closes spring-projectsgh-4372
Hello @rwinch, I've rebased my branch on current
Maybe a change on CI/tests configuration occured since my previous commit ? |
Thanks the changes look good to me. I think we should now consider implementing the |
For now, the salt length is not extracted from the encoded password in
But i never used the What do you think ? |
In hindsight I don't think we can calculate the salt length based on the size of the output because that also changes based on the hash width parameter. Also it is not quite clear how/when to upgrade with iterations, hash width, and salt length. I agree with your your thoughts about revisiting |
Hello @rwinch, |
- Add @author Loïc Guibert - Add @SInCE 5.5 to new constructors See PR spring-projectsgh-9147
No. We follow semantic versioning. Generally, enhancements are only included in the latest branch. The other branches are for patches only to reduce risk. |
Add constructors with a salt length input parameter.
Default salt length is still 8-byte long like before when
saltGenerator was initialized with call to
KeyGenerators#secureRandom() which use
SecureRandomBytesKeyGenerator#DEFAULT_KEY_LENGTH.
Closes gh-4372
This PR is related to #4372 to make salt length configurable in Pbkdf2PasswordEncoder.
Like mention in the #4372 issue, NIST Special Publication 800-132 section 5.1 said that salt length shall be at least 128 bits (16 bytes). Current
Pbkdf2PasswordEncoder
use a 8-byte (64-bit) random salt with no possibility to configure its length.Users that want to conform to NIST Special Publication 800-132 (or other rules requiring different that 8-byte random salt) for password storage with PBKDF2 algorithm, have no choice to develop their own PBKDF2 PasswordEncoder from scratch. They can't inherit from current
Pbkdf2PasswordEncoder
class because thesaltGenerator
attribute isprivate final
and not initialized in a at least protected constructor.This could be a security problem in case of bad implementation or if a new spring-security version fix a security issue in the
Pbkdf2PasswordEncoder
class an the user not apply this fix to its own PasswordEncoder.PS : I've not added
@since
annotation yet because i don't know if constructors are concerned by this annotation and the target version.PS : I've submitted the CLA