[SHIRO-290] Implement BCrypt (and possibly other unix crypt formats like scrypt)#273
Closed
bmarwell wants to merge 11 commits intoapache:masterfrom
bmarwell:SHIRO-290
Closed
[SHIRO-290] Implement BCrypt (and possibly other unix crypt formats like scrypt)#273bmarwell wants to merge 11 commits intoapache:masterfrom bmarwell:SHIRO-290
bmarwell wants to merge 11 commits intoapache:masterfrom
bmarwell:SHIRO-290
Conversation
Contributor
Author
|
About
and
my +1 for dropping them:
|
bdemers
reviewed
Jan 8, 2021
bdemers
reviewed
Jan 8, 2021
crypto/hash/src/main/java/org/apache/shiro/crypto/hash/ConfigurableHashService.java
Show resolved
Hide resolved
bdemers
reviewed
Jan 8, 2021
crypto/hash/src/main/java/org/apache/shiro/crypto/hash/ConfigurableHashService.java
Show resolved
Hide resolved
bdemers
reviewed
Jan 8, 2021
crypto/hash/src/main/java/org/apache/shiro/crypto/hash/DefaultHashService.java
Outdated
Show resolved
Hide resolved
bdemers
reviewed
Jan 8, 2021
crypto/hash/src/main/java/org/apache/shiro/crypto/hash/HashProvider.java
Outdated
Show resolved
Hide resolved
bdemers
reviewed
Jan 8, 2021
crypto/hash/src/main/java/org/apache/shiro/crypto/hash/Md2Hash.java
Outdated
Show resolved
Hide resolved
bdemers
reviewed
Jan 8, 2021
...hashes/bcrypt/src/main/java/org/apache/shiro/crypto/support/hashes/bcrypt/OpenBSDBase64.java
Show resolved
Hide resolved
bdemers
reviewed
Jan 8, 2021
bdemers
reviewed
Jan 8, 2021
- TBD: HashRequest - TBD: PasswortMatcher doesn’t know about the new hash format yet
- Hashes can now compare themselves to a given password.
Reviwers: Review method placement and HAsh class description.
- removed hashrequest
- removed UnixCryptFormat
- API change: made salt not-nullable.
Additional constructor is supplied for hashing without or with
default salt, the former and other methods/fields using
SimpleByteSource.empty().
Reviewers: Pay attention to method logic, so no empty salt is
being used where a former `null` value would have created a
new, random salt.
- Modified tests to not expect exceptions in certain cases.
- Modified tests to not expect passwordService calls when supplying an
existing hash.
- TBD: Fix Javadocs
- TBD: Fix Hasher utility
- TBD: Deprecate old non-KDF hash classes
- BCrypt iterations vs cost: make iterations return iterations - add validate methods
- expand iterations field to take a comma separated list. Maybe just create a Shiro2CryptFormat instead? - Hex and Base64 formats are not fixed. Maybe we can drop them? - Fixed parameter "algorithm name" not taken into account for bcrypt. - Allow Hasher to read from stdin - Added a short test for Hasher.java. - Changed default DefaultPasswordService.java algorithm to "Argon2id".
- Only fields 1 and two are defined, rest is defined by the hash implementation - Therefore fully backwards-compatible to Shiro1CryptFormat.java. - Loads formats from ProvidedKdfHashes.java. We could also think of a pluggable mechanism, like using service loaders to hide classes like OpenBSDBase64. - In AbstractCryptHash.java, renamed `version` to `algorithmName`. - Removed iterations from AbstractCryptHash.java, they are possibly an implementation detail not present in other implementations (like bcrypt). - Signature change: `PasswordService.encryptPassword(Object plaintext)` will now throw a NullPointerException on `null` parameter. It was never specified how this method would behave.
- fix invalid cost factor for bcrypt when input is 0. - output Hasher messages using slf4j.
- Move BCrypt and Argon2 into their own modules - Add a SPI - Remove hardcoded parameters, replace with ParameterMap for the hashRequest
- remove at least MD2, MD5 and Sha1 - Remove unused support-hashes module - changed group and artifact-ids for new modules - fixed compilation issue in Hasher (needs more work though) - add "since 2.0" comments
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reviwers: Review method placement and HAsh class description.
Additional constructor is supplied for hashing without or with
default salt, the former and other methods/fields using
SimpleByteSource.empty().
Reviewers: Pay attention to method logic, so no empty salt is
being used where a former
nullvalue would have created anew, random salt.
existing hash.
Also print warnings when encountering the old hashesgetBytes()return? There is no overridden Javadoc. Currently, only the hashed data is returned, but maybe it was meant to also return the hash here? If not, why even implementCodecSupport? This needs to be clarified before merging.=> This is more important if we want to retain Hex and Base64 formats. They need all parameters encoded.
getIterations()? Currently I return the cost. But we could also return the real iterations (which is2^cost) it that made sense.How to store argon2 parameters in Shiro1CryptFormat? Maybe create a Shiro2 CryptFormat?Argon2 outputs this:
$argon2i$v=19$m=65536,t=2,p=4$c29tZXNhbHQ$RdescudvJCsgt3ub+b+dWRWJTmaaJObG.The Shiro1 crypt format only has: prefix(shiro1), algo, iterationcount, salt, hash.
We would also need version and parameters or so, which could be empty for others.
The current working copy uses a comma separated list for the iterationCount field, but I am not happy with that.
Can we drop Hex and Base64 Formats?=> Can be done in another PR.Tune Argon2 default parameters. Target computation time on servers: ~ 0.1s as per RFC recommendation.Add scrypt. It is better than bcrypt.=> Another PR.DefaultPasswordService.testStringComparisonWhenNotUsingAParsableHashFormatactually test? It only works if specific parameters are set.API Changes
PasswordService.encryptPassword(Object plaintext)will now throwa NullPointerException on
nullparameter. It was never specified how this method would behave.Following this checklist to help us incorporate your contribution quickly and easily:
for the change (usually before you start working on it). Trivial changes like typos do not
require a JIRA issue. Your pull request should address just this issue, without pulling in other changes.
[SHIRO-XXX] - Fixes bug in SessionManager,where you replace
SHIRO-XXXwith the appropriate JIRA issue. Best practiceis to use the JIRA issue title in the pull request title and in the first line of the commit message.
mvn clean install apache-rat:checkto make sure basic checks pass. A more thorough check will be performed on your pull request automatically.git rebase -i.Trivial changes like typos do not require a JIRA issue (javadoc, comments...).
In this case, just format the pull request title like
(DOC) - Add javadoc in SessionManager.If this is your first contribution, you have to read the Contribution Guidelines
If your pull request is about ~20 lines of code you don't need to sign an Individual Contributor License Agreement
if you are unsure please ask on the developers list.
To make clear that you license your contribution under the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.