Skip to content

feat(auth): Implement passlib base64 salt decoding for legacy pbkdf2#793

Open
ymh1874 wants to merge 1 commit into
openstack-experimental:mainfrom
ymh1874:feature/password-hashing
Open

feat(auth): Implement passlib base64 salt decoding for legacy pbkdf2#793
ymh1874 wants to merge 1 commit into
openstack-experimental:mainfrom
ymh1874:feature/password-hashing

Conversation

@ymh1874

@ymh1874 ymh1874 commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

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

Note: This commit was done with the help of AI.
@ymh1874 ymh1874 force-pushed the feature/password-hashing branch from 39a9006 to 136efdb Compare June 13, 2026 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement remaining password hashing algorithms

1 participant