Help with pbkdf2_hmac_'sha512' hashes
#2
you first script (the hash generator) doesn't use the binary input, while your second script hex-decodes it and converts it to base64.

This line
Code:
salt = b"2213dcd3820c18c559cc389c8bd22e6b3b0b3f410f01ecf1aac95faf1716e169"

should be this:
Code:
salt = "2213dcd3820c18c559cc389c8bd22e6b3b0b3f410f01ecf1aac95faf1716e169".decode ('hex')

and then it should work fine.


What this means is that your 2 scripts are not currently interpreting the salt the same way. One says the salt is already AS-IS and using the raw bytes, while the other one says it should be converted to binary first (and then base64 decoded).


BTW: just concatenating salt and digests/hashes without a separator might also be quite dangerous, because what happens if there should be some leading zeros (but they are omitted because python doesn't have a fixed size for every hex string) etc... you would at least need to zero-pad it to a fixed size... (btw: there are a couple of projects that made this same error and lost a lot of money for doing these strange let's-just-concat-everything strategies).
I understand that you think that the first 64 bytes are always the salt, but what happens if the salt consist of 4 leading zeros (if the salt changes too, which should be the case of course for every different hash) and they do not end up in the output because of the non-fixed-hex-length?
Reply


Messages In This Thread
Help with pbkdf2_hmac_'sha512' hashes - by rappy - 02-03-2019, 04:18 AM
RE: Help with pbkdf2_hmac_'sha512' hashes - by philsmd - 02-03-2019, 09:35 AM