* The sector number that Linux' dm-crypt passes to its iv generators
is offset another -block_offset sectors, so that the actual sector
number is the one on the dm device, not the underlying device.
* Also fix the plain iv generator, which is supposed to be a "32-bit
little-endian version of the sector number"
* Now our dm_target_crypt can read Linux' crypt disks. This was tested
with an image using aes-cbc-essiv:sha256 and aes-cbc-plain.
size_t iv_len, off_t sector, void *opaque)
{
bzero(iv, iv_len);
- *((off_t *)iv) = htole64(sector + priv->iv_offset);
+ *((uint32_t *)iv) = htole32((uint32_t)(sector + priv->iv_offset));
dmtc_crypto_dispatch(opaque);
}
/* Save length of param string */
priv->params_len = len;
priv->block_offset = block_offset;
- priv->iv_offset = iv_offset;
+ priv->iv_offset = iv_offset - block_offset;
*target_config = priv;