From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-eopbgr770080.outbound.protection.outlook.com [40.107.77.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.server123.net (Postfix) with ESMTPS for ; Mon, 21 Oct 2019 18:13:11 +0200 (CEST) From: Hualing Yu Date: Mon, 21 Oct 2019 16:13:08 +0000 Message-ID: References: <4eea62ab-e121-d069-9be2-048b09cf301e@gmail.com> In-Reply-To: <4eea62ab-e121-d069-9be2-048b09cf301e@gmail.com> Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_CH2P132MB0187F6574C7736A42B09AFFA87690CH2P132MB0187NAMP_" MIME-Version: 1.0 Subject: Re: [dm-crypt] 10 M Luks2 header size? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Milan Broz , "dm-crypt@saout.de" --_000_CH2P132MB0187F6574C7736A42B09AFFA87690CH2P132MB0187NAMP_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Milan, Thank you very much for the detailed explanation! This is tremendous help = to us! I had already brought this up in our group meeting. We will re-arrange out= partitions to ensure all have enough space for default configurations. Th= ank you very much on that! May I ask further - (sorry more questions, I just want to do it right and m= ake the best out from your original design.) 1. I'm using linux kernel keyring as token for passphrase. Do I need = to enlarge JSON? (BTW, Why JSON area is stored twice, for backup only that= area?) 2. Do we still need to use luksHeaderBackup and luksHeaderRes= tore are for entire 16 M header backup? This means each luks part= ition needs 32 M for its header! Now here is our story : We have storage redundancy on our board, that is, f= or each component (for example linux rootfs) we have two partitions to save= two copies of the component. I think with that, we may not need luks head= er backup. When we detect anything wrong with current active partition, in= clude luks header, we can switch to use the standby partition for rootfs fo= r example, and then repair, or simply wipe everything and redo luks format = and copy the data into it. Should this work? Can you suggest some ways, or check points, for our back= ground task to periodically checking to ensure all luks's are good, in case= you have something on top of your head? 8-) Thank you so much! Hualing -----Original Message----- From: Milan Broz [mailto:gmazyland@gmail.com] Sent: Sunday, October 20, 2019 6:08 AM To: Hualing Yu ; dm-crypt@saout.de Subject: Re: [dm-crypt] 10 M Luks2 header size? Hi, this information should be later in FAQ, so I try to explain it here. Anyway, stay with defaults, if you can. On 19/10/2019 21:59, Hualing Yu wrote: > > May I ask a couple of additional questions about this so that we know how= to trade off. > > > 1. What the reencryption can do for us? Could you explain very > briefly as I'm not sure if we need it? In principle it can perform changes that requires full-device rewrite (chan= ge of the volume key). See man cryptsetup-reencrypt - just for LUKS2 it is more reliable and mainl= y online (you can use device while it is in reencryption process). See slides from Ondra https://nam02.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fokozi= na.fedorapeople.org%2Fonline-disk-reencryption-with-luks2-compact.pdf&d= ata=3D02%7C01%7Chualing.yu%40jci.com%7Ca096abcf38e8483e599808d7554555fc%7Ca= 1f1e2147ded45b681a19e8ae3459641%7C0%7C1%7C637071628596824108&sdata=3DZn= 13uT%2B7wsLKex3r6u3LWAC7xFobCn4PLs10ywQYxeU%3D&reserved=3D0 There should be also some online demos Reencryption demo: https://nam02.safelinks.protection.outlook.com/?url=3D= https%3A%2F%2Fasciinema.org%2Fa%2F268573&data=3D02%7C01%7Chualing.yu%40= jci.com%7Ca096abcf38e8483e599808d7554555fc%7Ca1f1e2147ded45b681a19e8ae34596= 41%7C0%7C1%7C637071628596824108&sdata=3D6DkH8Bwz699zeGzk25vf8gh4%2FKuIm= VaMeGEu34qHkCA%3D&reserved=3D0 Encryption demo: https://nam02.safelinks.protection.outlook.com/?url=3Dht= tps%3A%2F%2Fasciinema.org%2Fa%2F268574&data=3D02%7C01%7Chualing.yu%40jc= i.com%7Ca096abcf38e8483e599808d7554555fc%7Ca1f1e2147ded45b681a19e8ae3459641= %7C0%7C1%7C637071628596824108&sdata=3D8nuvhvj5fBB%2FeH0pu0%2F0qRNd7l47d= VMQwzDrNFoeeMA%3D&reserved=3D0 For this we require some reserved area for storing temporary encryption dat= a. > 2. We need only one or at most two keyslots but we do want them > to be scattered as much as needed just as if for the default case, > what we can do? Use -luks2-keyslots-size=3D1 M (or whatever size that > will give two key enough space to scatter)? There are two areas (see LUKS2 docs) - JSON area for metadata and binary ar= ea. JSON has small binary header, than JSON data (it is 16k currently, stored t= wice). For the binary area, it depends what you need, exact size depends on the st= ored key size (here the binary keyslot data are stored, exactly the same as= in LUKS1). I would expect you are using current default for disk encryption, AES256-XT= S. Then you need to store 512bit (2x256bit) key in each binary keyslot. With the LUKS AF filter and 4k alignment it should be 256KiB of binary data= per keyslot. So for 1M and 512bit key it allows 4 LUKS keyslots here. > 3. What the size of metadata size for default configuration? > What's the downside of using 16 K? The whole LUKS2 default header takes 16MiB. For JSON area it is 16k, stored twice (we will increase it later, this is f= or compatibility reasons), for binary area - it is "16M - 2x16k" (16M minus= JSON areas). There is only several possible sizes of JSON area you can use (see LUKS2 do= cs), binary area is basically arbitrary with maximum 128M, it must be align= ed to 4k sectors. JSON areas allows to store user token metadata, so if you do not need it, n= o need to enlarge it. Thanks, Milan --_000_CH2P132MB0187F6574C7736A42B09AFFA87690CH2P132MB0187NAMP_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi Milan,

 

Thank you very much for the detailed explanation!=   This is tremendous help to us!

 

I had already brought this up in our group meetin= g.  We will re-arrange out partitions to ensure all have enough space = for default configurations.  Thank you very much on that!

 

May I ask further – (sorry more questions, = I just want to do it right and make the best out from your original design.= )

1.      I’m using linux kernel keyring as token for p= assphrase.  Do I need to enlarge JSON?  (BTW, Why JSON area is st= ored twice, for backup only that area?)

2. &nbs= p;    Do we still need to use luksHeaderBackup <= device> and luksHeaderRestore <device> are for entire 16 M header backup?&n= bsp; This means each luks partition needs 32 M for its header!

 

Now here is our sto= ry : We have storage redundancy on our board, that is, for each component (= for example linux rootfs) we have two partitions to save two copies of the = component.  I think with that, we may not need luks header backup.  When we detect anything wrong with curr= ent active partition, include luks header, we can switch to use the standby= partition for rootfs for example, and then repair, or simply wipe everythi= ng and redo luks format and copy the data into it.

Should this work?&n= bsp; Can you suggest some ways, or check points, for our background task to= periodically checking to ensure all luks’s are good, in case you hav= e something on top of your head?  8-)

 

Thank you so much!&= nbsp;

 

 

Hualing<= /span>

 

 

-----Original Message-----
From: Milan Broz [mailto:gmazyland@gmail.com]
Sent: Sunday, October 20, 2019 6:08 AM
To: Hualing Yu <hualing.yu@jci.com>; dm-crypt@saout.de
Subject: Re: [dm-crypt] 10 M Luks2 header size?

 

Hi,

 

this information should be later in FAQ, so I try= to explain it here.

 

Anyway, stay with defaults, if you can.

 

On 19/10/2019 21:59, Hualing Yu wrote:=

>

> May I ask a couple of additional questions a= bout this so that we know how to trade off.

>  

>

> 1.      What the re= encryption can do for us?  Could you explain very

> briefly as I’m not sure if we need it?=

 

In principle it can perform changes that requires= full-device rewrite (change of the volume key).

See man cryptsetup-reencrypt - just for LUKS2 it = is more reliable and mainly online (you can use device while it is in reenc= ryption process).

 

See slides from Ondra

  https://nam02.safelin= ks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fokozina.fedorapeople.org%2Fo= nline-disk-reencryption-with-luks2-compact.pdf&amp;data=3D02%7C01%7Chua= ling.yu%40jci.com%7Ca096abcf38e8483e599808d7554555fc%7Ca1f1e2147ded45b681a1= 9e8ae3459641%7C0%7C1%7C637071628596824108&amp;sdata=3DZn13uT%2B7wsLKex3= r6u3LWAC7xFobCn4PLs10ywQYxeU%3D&amp;reserved=3D0<= /p>

 

There should be also some online demos=

  Reencryption demo: https://nam02.safelin= ks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fasciinema.org%2Fa%2F268573&a= mp;amp;data=3D02%7C01%7Chualing.yu%40jci.com%7Ca096abcf38e8483e599808d75545= 55fc%7Ca1f1e2147ded45b681a19e8ae3459641%7C0%7C1%7C637071628596824108&am= p;sdata=3D6DkH8Bwz699zeGzk25vf8gh4%2FKuImVaMeGEu34qHkCA%3D&amp;reserved= =3D0

  Encryption demo: https://nam02.safelin= ks.protection.outlook.com/?url=3Dhttps%3A%2F%2Fasciinema.org%2Fa%2F268574&a= mp;amp;data=3D02%7C01%7Chualing.yu%40jci.com%7Ca096abcf38e8483e599808d75545= 55fc%7Ca1f1e2147ded45b681a19e8ae3459641%7C0%7C1%7C637071628596824108&am= p;sdata=3D8nuvhvj5fBB%2FeH0pu0%2F0qRNd7l47dVMQwzDrNFoeeMA%3D&amp;reserv= ed=3D0

 

For this we require some reserved area for storin= g temporary encryption data.

 

> 2.      We need onl= y one or at most two keyslots but we do want them

> to be scattered as much as needed just as if= for the default case,

> what we can do? Use  –luks2-keysl= ots-size=3D1 M (or whatever size that

> will give two key enough space to scatter)?<= o:p>

 

There are two areas (see LUKS2 docs) - JSON area = for metadata and binary area.

 

JSON has small binary header, than JSON data (it = is 16k currently, stored twice).

 

For the binary area, it depends what you need, ex= act size depends on the stored key size (here the binary keyslot data are s= tored, exactly the same as in LUKS1).

 

I would expect you are using current default for = disk encryption, AES256-XTS.

 

Then you need to store 512bit (2x256bit) key in e= ach binary keyslot.

 

With the LUKS AF filter and 4k alignment it shoul= d be 256KiB of binary data per keyslot.

 

So for 1M and 512bit key it allows 4 LUKS keyslot= s here.

 

> 3.      What the si= ze of metadata size for default configuration?

> What’s the downside of using 16 K?

The whole LUKS2 default header takes 16MiB.<= /o:p>

 

For JSON area it is 16k, stored twice (we will in= crease it later, this is for compatibility reasons), for binary area - it i= s "16M - 2x16k" (16M minus JSON areas).

 

There is only several possible sizes of JSON area= you can use (see LUKS2 docs), binary area is basically arbitrary with maxi= mum 128M, it must be aligned to 4k sectors.

 

JSON areas allows to store user token metadata, s= o if you do not need it, no need to enlarge it.

 

Thanks,

Milan

--_000_CH2P132MB0187F6574C7736A42B09AFFA87690CH2P132MB0187NAMP_--