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

AbstractCompareAuthenticationHandler uses the wrong format string when PasswordScheme contains a "-" character #121

Closed
binsys opened this Issue May 29, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@binsys
Copy link

binsys commented May 29, 2017

In class AbstractCompareAuthenticationHandler
passwordScheme = "SHA-256"

https://github.com/vt-middleware/ldaptive/blob/master/core/src/main/java/org/ldaptive/auth/AbstractCompareAuthenticationHandler.java#L86
final MessageDigest md = MessageDigest.getInstance(passwordScheme);
This is correct.

https://github.com/vt-middleware/ldaptive/blob/master/core/src/main/java/org/ldaptive/auth/AbstractCompareAuthenticationHandler.java#L95
String.format("{%s}%s", passwordScheme, LdapUtils.base64Encode(hash)).getBytes());
This is not considered when the passwordScheme contains the '-' character.

Ref:
https://tools.ietf.org/id/draft-stroeder-hashed-userpassword-values-01.html

For example:

On LDAP Server,store userPassword (encode by SHA-256) format is:
{SHA256}BsSOzvGznv4K7yvNA9vnqI701/MSMd/fyNcfNy07YN0=

({HASH_NAME_WITHOUT '-'} + BASE64(HASH))

dfish3r added a commit that referenced this issue May 31, 2017

Support both name and algorithm for compare scheme.
Continue to support string input for API compatability.
Refactor digesting into separate method.
Fixes #121
@serac

This comment has been minimized.

Copy link
Member

serac commented May 31, 2017

Just tying to clarify the usage @binsys would need with the fix proposed in #122.

final CompareAuthenticationHandler handler = new CompareAuthenticationHandler();
handler.setPasswordScheme("SHA256:SHA-256");

Is that correct?

@dfish3r

This comment has been minimized.

Copy link
Member

dfish3r commented May 31, 2017

That's what I had in mind. No API breakage, but still no first class support for salted hashes.

@serac serac closed this in #122 May 31, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment