public inbox for dm-crypt@saout.de
 help / color / mirror / Atom feed
From: Milan Broz <gmazyland@gmail.com>
To: Fourhundred Thecat <400thecat@gmx.ch>, dm-crypt@saout.de
Subject: Re: [dm-crypt] detached LUKS header size
Date: Mon, 25 Nov 2019 14:55:11 +0100	[thread overview]
Message-ID: <4c3b11fc-783c-e58f-681d-7acee12376d7@gmail.com> (raw)
In-Reply-To: <39693781-1472-1aeb-5005-5141c02c6746@gmx.ch>

Hi,

On 25/11/2019 05:34, Fourhundred Thecat wrote:
> On 23/11/2019 09.48, Milan Broz wrote:
>>
>> AF is mandatory and must be there, but you can allocate only absolute
>> minimum
>> for the LUKS2 whole header (for example only area for 1 keyslot), if you
>> do not need other features.
> 
> Hi Milan,
> 
> if I decide to use luks1 format for my detached header, what size do I
> need to allocate for the header file ?

For LUKS1 you cannot modify header size, there is always 8 keyslots pre-allocated
and its size depends on stored key size (usually 128/256/512 bits).

Then there is alignment, so the real data offset is aligned by default to
the 1MB boundary.

With this padding, header size is for 128bit key 2MB, for 256/512 key 4MB.

(See table 5.2. in LUKS2 standard describing conversion from LUKS1
here https://gitlab.com/cryptsetup/LUKS2-docs/blob/master/luks2_doc_wip.pdf )

> 
>  From the FAQ on gitlab, it would seem luks1 needs 2MB header file
> (Payload offset * 512), but when I use the "luksHeaderBackup" command on
> an existing standard luks1 partition:
> 
>   cryptsetup luksHeaderBackup /dev/sde1 --header-backup-file sde1.header
> 
> it actually creates a file of size 1,052,672 bytes

So your header contains keyslots for 256bit keys.

The luksBackup should store the header without alignment, so it is the exact
used size (in this case 2056 512-byte sectors).

> Is this the complete luks header ?

Yes, it is full header without padding (for 256bit keys only!).

> If I want to minimize the size of LUKS header, without changing any
> default settings, can I use a  1,052,672 bytes file for my luks1 header?

Yes. For reference: for 128bit it is 528384 bytes, for 256bit 1052672 bytes,
for 512bit (2x256bits in XTS mode) it is 2068480 bytes.

Milan

  reply	other threads:[~2019-11-25 13:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-23  5:43 [dm-crypt] detached LUKS header size Fourhundred Thecat
2019-11-23  8:21 ` Arno Wagner
2019-11-24  6:34   ` Fourhundred Thecat
2019-11-24  8:16     ` Arno Wagner
2019-11-24  8:39       ` Milan Broz
2019-11-23  8:48 ` Milan Broz
2019-11-25  4:34   ` Fourhundred Thecat
2019-11-25 13:55     ` Milan Broz [this message]
2019-11-25 15:17       ` Fourhundred Thecat
2019-11-25 15:27         ` Milan Broz
2019-11-24 11:46 ` Michael Kjörling

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4c3b11fc-783c-e58f-681d-7acee12376d7@gmail.com \
    --to=gmazyland@gmail.com \
    --cc=400thecat@gmx.ch \
    --cc=dm-crypt@saout.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox