From: Alex Hornung Date: Sat, 21 Aug 2010 06:17:54 +0000 (+0100) Subject: dm_target_crypt - Fix compatibility with Linux X-Git-Tag: v2.9.0~466 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/7a89864aca790456f28133cb04924ae4b1364a46 dm_target_crypt - Fix compatibility with Linux * 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. --- diff --git a/sys/dev/disk/dm/dm_target_crypt.c b/sys/dev/disk/dm/dm_target_crypt.c index 7973eaad3f..5beccf131b 100644 --- a/sys/dev/disk/dm/dm_target_crypt.c +++ b/sys/dev/disk/dm/dm_target_crypt.c @@ -365,7 +365,7 @@ plain_ivgen(dm_target_crypt_config_t *priv, u_int8_t *iv, 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); } @@ -588,7 +588,7 @@ dm_target_crypt_init(dm_dev_t * dmv, void **target_config, char *params) /* 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;