mricon/totp-cgi

Cannot verify bcrypt or md5 hashes

Closed this issue · 10 comments

I am trying to use your wonderful totpcgi project and I hit a snag. I have this working on one setup against an LDAP backend perfectly. I have another place where I'd like to just use a table in the postgres database that has the pincodes there, however I get an error on login saying "Unsupported hashcode format". Can you point me to where I might be wrong? I know this is pretty generic stuff here but I'm not sure what info you might find useful.

I entered the pincode as I would expect my user to type it in. I set the hash type to md5. I'm wondering if I have to actually create a hash of the password and put that in the table?

I did try creating an MD5 hash of the password also and using that in the table didn't seem to make a difference.

The entries in the database should match one of the supported password hashes, not plaintext. If you want to generate a compatible md5 password hash, run the following: "openssl passwd -1" and type in the password to hash.

FYI, you can also use "totpprov set-user-pincode username", if you set up your provisioning.conf.

Thanks for that pointer. I removed the manual entries I made and tried again with the command you provided. I changed the hash to bcrypt and md5 but I still get the same exact error message (even when trying to provision the user with totpprov) Unsupported hashcode format.

BTW it does make the entries in the database, it's failing on the verify step.

I did verify I have bcrypt installed, and when I go into python at the command prompt and run import bcrypt it returns as I would expect for a module that is installed.

I started trying other hash algorithms and I got to sha256 which seems to be working. Not sure why md5 and bcrypt didn't work but at this point I don't care either.

Thanks for the tip on the provisioning command that will save me headaches :)

I think you found an actual bug, so I'll keep this open. Looks like we don't do the right thing verifying md5 or bcrypt hashes.

FYI, I recommend you use sha512 instead of sha256.

Will do, thanks!

Should be fixed and will be out with 0.5.6