feat(auth): Implement passlib base64 salt decoding for legacy pbkdf2#793
Open
ymh1874 wants to merge 1 commit into
Open
feat(auth): Implement passlib base64 salt decoding for legacy pbkdf2#793ymh1874 wants to merge 1 commit into
ymh1874 wants to merge 1 commit into
Conversation
Note: This commit was done with the help of AI.
39a9006 to
136efdb
Compare
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.
The Problem:
During the migration of legacy Python Passlib PBKDF2 hashes, standard Rust cryptographic crates failed to verify the passwords. This is because the modern PHC standard feeds the raw ASCII string of the salt directly into the HMAC algorithm, whereas legacy Python Passlib base64-decodes the salt first.
The Solution:
Implemented a custom, inline unpadded base64 decoder specifically designed for Passlib's legacy dialect (which uses . instead of +). This decodes the salt back into raw bytes before hashing, perfectly matching the legacy Python behavior without adding heavy external dependencies.
Testing & Verification:
Unit Tests Added: Added passlib_migration_tests to ensure both standard Scrypt and legacy PBKDF2 hashes resolve correctly.
Python Reference Hashes: The tests validate against hardcoded reference hashes that were generated using a standard Python script running passlib. This guarantees 1:1 compatibility with the old OpenStack database values.
Closes #748