If you want to guarantee that ciphertext is NEVER duplicated, you
_have_ to store the IV somewhere. You can not rely on a block offset
to be unique for a given system. For instance, I imagine that someone
will come up with a simple modification to RedHat where all
filesystems are encrypted to protect the machine in case it is stolen
[should be pretty easy to so using initrd by the way, hint hint]. If
the machine has multiple disks, each disk will have duplicated
ciphertext whether they use absolute or relative block numbers as IV.
So when you use relative offsets, you get duplicated ciphertext when
you have several encrypted filesystems. When you use absolute
offsets, you get duplicated ciphertext when you have several encrypted
filesystems starting from the beginning of each disk. To me it seems
that using relative offsets is a security/useability tradeoff that a
lot of users will want.
If you think this is a serious problem it should be dealt with
properly. Three reasonable ways of doing it are:
1) Store random IVs in the loopback filesystem.
You then have to waste some space, but you'll get your added security
in all cases, and users will be able to move the files since the IVs
are stored internally. I can imagine a loopback file having a layout
like this:
<512 bytes IVs><512*(512/num_iv_bytes) ciphertext>
<512 bytes IVs><512*(512/num_iv_bytes) ciphertext>
...
So to store block x you calculate:
blocknum = x + (x >> 9) + 1
ivblocknum = (x & ~511)
ivoffset = (x & 511) * num_iv_bytes
You fetch the IVs from /dev/urandom, and the buffer cache will take
care of keeping the IVs handy.
2) Give a random initial IV during losetup and use offsets relative to
this value
This just changes the calculation of IVs from
IV = absolute_block_offset
to
IV = initial_iv ^ relative_block_offset
3) Reserve 64 bytes at the start/end of each loopback filesystem to store
the data for (2).
astor
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/