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.

  • Does this help? Quote: "ESSIV derives the IV from key material via encryption of the sector numberwith a hashed version of the key material, the salt2. ESSIV does not specifya particular hash algorithmH, but the digest size of the hash must be a validkey size for the block cipher. For instance, sha256 is a valid choice for AES, assha256 produces a 256-bit digest."
    – Tom K.
    Jun 10, 2020 at 16:13
  • Not what I am looking for but thanks, saved to bookmarks. Tomorrow I will try AES-256 with ECB as bulk cipher once again.
    – wtdmn
    Jun 10, 2020 at 18:57
  • 1
    Ok, here: is.muni.cz/th/vesfr/final.pdf (page 30) I found that for ESSIV vector generation one should use the same exact block cipher as for finishing encryption. Now, since I am using CTR which turns block cipher into stream cipher, I presume I have to extend sector number to 16 bytes first to achieve 16 byte output. I will post answer when I find if it works. Good work, dr. Brož.
    – wtdmn
    Jun 13, 2020 at 11:50

1 Answer 1


Seems that in my case it was sufficient to use AES-256 ECB for ESSIV iv generation. I probably deceived myself by misinterpreting sentence:

Note that while the cipher algorithm is always as the same as the algorithm used for data encryption..

Although it makes sense, since IV usage in generation of primary IV is unnecesary in this case.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .