Post
Topic
Board Bitcoin Technical Support
Re: get sha-512 of wallet.dat
by
NotATether
on 24/06/2021, 19:55:12 UTC
It must be my eyes or something.
I just can't see any PBKDF2 anywhere.
Surely i can see openssl's EVP BytesToKey and SHA512 functions but no PBKDF2.
I guess i'm getting old.

The PBKDF2 function in Bitcoin Core is not called "PBKDF2" or "KDF" or anything else obvious, it's literally "SetKeyFromPassphrase", and it has all the parameters that an ordinary PBKDF2 function would take:

Number of rounds i.e. iterations? Check: nRounds parameter (this is the number of times SHA512 is ran)
Salt? Check: chSalt parameter (note that the salt is always randomly generated)
Salt length? Check: chSalt.size() (this is always 16)
Hash function number? Check: nDerivationMethod parameter (always equals 0, which stands for "use SHA512 for the hash function")

Encrypted key (not obvious but is also a requirement to have a proper PBKDF2)? Check: The vchKey and vchIV members of the CCrypter class, which are directly calculated from the password.

The rest, length of encryption key, length of derivation method, additional arguments, these are all constants for Bitcoin wallet hashes and so they aren't even seen in this code snippet (ccrypter.h, ccrypter.h).