[pkg-cryptsetup-devel] Bug#932437: LUKS formatting of a 16 MB (sic!) device is possible, open not

Milan Broz gmazyland at gmail.com
Fri Jul 19 12:18:45 BST 2019


On 19/07/2019 12:40, Marc Haber wrote:
> I would like to luksFormat a really tiny device (which will only hold a
> single file) with LUKS or LUKS2. I have been doing this multiple times
> in the past, and was surprised that it doesn't work any more with
> current cryptsetup.

Default header size is much bigger because it reserves space for more
keyslots and optionally online reencryption. But it can be changed.

You can now create even smaller device with LUKS2, if you are
ok with a very small metadata size and only one keyslot (size of keyslot depends on
a key size, example is for XTS 512bit key).

I am able to create just 1MB LUKS header this way:

  cryptsetup luksFormat --type luks2 --luks2-metadata-size=16k --luks2-keyslots-size=256k img

or even smaller (here <300 kB), if you ignore default 1MB alignment

  cryptsetup luksFormat --type luks2 --luks2-metadata-size=16k --luks2-keyslots-size=256k --align-payload=1 img

> cryptsetup should be more clear about minimum space requirement, and it
> should use them consistently. Having a minimum size is ok, if I know of
> it, and being able to format but not open a device because it's too
> small is a bug.

For detached header you must be able to format header only (no data area).

But for the normal device, it is a bug, it should not format device and then complain
that it is too small :)

Also I think we should print default header size in --help output...

Anyway, this is upstream bug, so if you want to fill an issue for us, tracker
is here https://gitlab.com/cryptsetup/cryptsetup/issues

Thanks,
Milan



More information about the pkg-cryptsetup-devel mailing list