If you create a new LUKS device, you can specify the option
For example like this:
sudo cryptsetup luksFormat --cipher aes-cbc-essiv:sha256 --key-size 256 --iter-time 2100 --hash sha512 /dev/loop0
From the manpage of cryptsetup:
For create action specifies hash to use for password hashing.
For luksFormat action specifies hash used in LUKS key setup scheme and volume key digest.
Because of the first sentence I naively assumed that the hash is used in a similar way as in a standard linux system, where a hash value is created by a specified algorithm (for example
sha512). To make it harder for an attacker which has the hash and wants to try a dictionary attack, the has is salted and the algorithm is iterated n-times to make computation time longer. In this case the has value is stored in
/etc/shadow. If a user logs in, the hash is computed and compared to the value in the
/etc/shadows file. If they are equal, the user is accepted to login. In a similar way an attacker which owns the file
/etc/shadow (from where he also knows the salt value) can compute hashes from words in a dictionary and compare it to the value in the
/etc/shadow file until some string matches.
If the hash in LUKS were used in a similar way, I assumed it must be stored somewhere (for example in the partition header) and if the attacker had access to the partition header (or the file where it is stored) for some reasons, he could proceed in a similar way as above to find out the password. This lead me to the question about how to get the hash: How can I extract the hash value of a LUKS device?
Thinking about how the LUKS system may work, I guess that it is not used in this way. Instead I think, that the password is just used to encrypt the key (and no hash is stored anywhere), which is stored encrypted in the header. But in the LUKS man-page I didn't find any hint, which encryption algorithm is used for key encryption and how to change it. (The options
--cipher aes-cbc-essiv:sha256 --key-size 256 refer to the actual algorithm which is used to encrypt the partition but not the key). This indicates for me that this understanding my be also incorrect.
So, how does this all really works and what is the role of the hash described above? Would be great if someone could clarify my misconceptions above (perhaps with some references).