I am playing around with disk encryption. https://gitlab.com/cryptsetup/cryptsetup/-/wikis/DMCrypt#iv-generators says:
essiv: "encrypted sector|salt initial vector", the sector number is encrypted with the bulk cipher using a salt as key.
The salt is derived from the bulk cipher's key via hashing.
Note that while the cipher algorithm is always as the same as the algorithm used for data encryption, its key size depends on used hash algorithm.
In other words, while data encryption can use AES-128, the ESSIV calculation with SHA256 will use AES-256.
ESSIV takes hash algorithm as an option, so the format is essiv:hash, e.g. essiv:sha256.
Available since: 1.1.0 (kernel 2.6.10)
The way I see it, I hash original KEY (32B), use this hash as key for bulk cipher (?) and encrypt sector number (8B) with it: result is used as IV for AES-256.
Now, do you have any idea which bulk cipher is it about? And what about its IV? I can't find anything about it in code: https://elixir.bootlin.com/linux/v3.10/source/drivers/md/dm-crypt.c#L256. Thanks.
EDIT: since ESSIV takes sector number 8B long it also has to be padded, possibly with zeros or PKCS7.