Skip to content
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

Inputing a 2y salt should output a 2y hash #84

Merged
merged 1 commit into from
Jun 30, 2016

Conversation

dstufft
Copy link
Member

@dstufft dstufft commented Jun 30, 2016

Currently using bcrypt 3.0 with passlib is a bit broken, because it it inputs a precomputed $2y$ salt and expects to get back out a $2y$ hash (and it verifies that it does that), however instead it's getting back a $2b$ hash. Giving a $2b$ output when you give it a $2y$ input also means it breaks the most logical way to verify a bcrypt'd password since:

import bcrypt

assert bcrypt.hashpw(plaintext, hashed_with_2y) == hashed_with_2y

would fail because instead of a $2y$ we'd return a $2b$.

So this change will ensure that hashpw() returns the same prefix it was given originally. We still don't support the $2y$ prefix when passed into gensalt(), so getting a $2y$ out of hashpw() will still require either pre-existing data or manually constructing your own salt.

This also means our checkpw gets to be a little simpler since it no longer needs to deal with the fact that the output may differ only by the prefix.

@reaperhulk reaperhulk mentioned this pull request Jun 30, 2016
9 tasks
@reaperhulk
Copy link
Member

👍

@reaperhulk
Copy link
Member

This needs a rebase

@dstufft
Copy link
Member Author

dstufft commented Jun 30, 2016

Rebased!

@reaperhulk reaperhulk merged commit c959669 into pyca:master Jun 30, 2016
@dstufft dstufft deleted the input-is-output branch June 30, 2016 17:06
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants