Skip to contentSkip to conversation

cryptsetup: Add luks2 related PACKAGECONFIGs

PATCH In review Alejandro Enedino Hernandez Samaniego 2 participants 5 messages Apr 28, 2022 – Apr 29, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cryptsetup: Add luks2 related PACKAGECONFIGs

Cryptsetup allows for certain luks2 related defaults to be set for libcryptsetup, these include the default PBKDF algorithm, memory limit for PBKDF2, parallel threads and iteration time.

Add these options as PACKAGECONFIGs to cryptsetup while setting variables defined as the current cryptsetup defaults, making this change transparent for the user but allow these knobs to be customized.

---
 .../recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb    | 12 ++++++++++++
 1 file changed, 12 insertions(+)
meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb +12 -0
index 8f9f663a3..7baca98cb 100644
@@ -44,6 +44,14 @@ PACKAGECONFIG:append:class-target = " \
     udev \
 "
 
+
+# libcryptsetup default PBKDF algorithm, Argon2 memory cost (KB), parallel threads and iteration time (ms)
+LUKS2_PBKDF ?= "argon2i"
+LUKS2_MEMORYKB ?= "1048576"
+LUKS2_PARALLEL_THREADS ?= "4"
+LUKS2_ITERTIME ?= "2000"
+
+
 PACKAGECONFIG[keyring] = "--enable-keyring,--disable-keyring"
 PACKAGECONFIG[fips] = "--enable-fips,--disable-fips"
 PACKAGECONFIG[pwquality] = "--enable-pwquality,--disable-pwquality,libpwquality"
@@ -69,6 +77,10 @@ PACKAGECONFIG[nss] = "--with-crypto_backend=nss,,nss"
 PACKAGECONFIG[kernel] = "--with-crypto_backend=kernel"
 PACKAGECONFIG[nettle] = "--with-crypto_backend=nettle,,nettle"
 PACKAGECONFIG[luks2] = "--with-default-luks-format=LUKS2,--with-default-luks-format=LUKS1"
+PACKAGECONFIG[luks2-pbkdf] = "--with-luks2-pbkdf=${LUKS2_PBKDF}"
+PACKAGECONFIG[luks2-memorykb] = "--with-luks2-memory-kb=${LUKS2_MEMORYKB}"
+PACKAGECONFIG[luks2-parallel-threads] = "--with-luks2-parallel-threads=${LUKS2_PARALLEL_THREADS}"
+PACKAGECONFIG[luks2-itertime] = "--with-luks2-iter-time=${LUKS2_ITERTIME}"
 
 EXTRA_OECONF = "--enable-static"
 # Building without largefile is not supported by upstream
Signature · 1 line
2.25.1
#1 lore raw
Quoted 20 lines · Alejandro Hernandez Samaniego

Cryptsetup allows for certain luks2 related defaults to be set for libcryptsetup, these include the default PBKDF algorithm, memory limit for PBKDF2, parallel threads and iteration time.

Add these options as PACKAGECONFIGs to cryptsetup while setting variables defined as the current cryptsetup defaults, making this change transparent for the user but allow these knobs to be customized.

---
  .../recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb    | 12 ++++++++++++
  1 file changed, 12 insertions(+)
meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb +0 -0
index 8f9f663a3..7baca98cb 100644

meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb PACKAGECONFIG:append:class-target = " \ · line 53

Quoted 10 lines
meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb +7 -0
@@ -44,6 +44,14 @@ PACKAGECONFIG:append:class-target = " \
      udev \
  "
 
+
+# libcryptsetup default PBKDF algorithm, Argon2 memory cost (KB), parallel threads and iteration time (ms)
+LUKS2_PBKDF ?= "argon2i"
+LUKS2_MEMORYKB ?= "1048576"
+LUKS2_PARALLEL_THREADS ?= "4"
+LUKS2_ITERTIME ?= "2000"
+

is this something that can be selected at runtime too ?

Quoted 26 lines
meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb +5 -1
+
  PACKAGECONFIG[keyring] = "--enable-keyring,--disable-keyring"
  PACKAGECONFIG[fips] = "--enable-fips,--disable-fips"
  PACKAGECONFIG[pwquality] = "--enable-pwquality,--disable-pwquality,libpwquality"
@@ -69,6 +77,10 @@ PACKAGECONFIG[nss] = "--with-crypto_backend=nss,,nss"
  PACKAGECONFIG[kernel] = "--with-crypto_backend=kernel"
  PACKAGECONFIG[nettle] = "--with-crypto_backend=nettle,,nettle"
  PACKAGECONFIG[luks2] = "--with-default-luks-format=LUKS2,--with-default-luks-format=LUKS1"
+PACKAGECONFIG[luks2-pbkdf] = "--with-luks2-pbkdf=${LUKS2_PBKDF}"
+PACKAGECONFIG[luks2-memorykb] = "--with-luks2-memory-kb=${LUKS2_MEMORYKB}"
+PACKAGECONFIG[luks2-parallel-threads] = "--with-luks2-parallel-threads=${LUKS2_PARALLEL_THREADS}"
+PACKAGECONFIG[luks2-itertime] = "--with-luks2-iter-time=${LUKS2_ITERTIME}"
 
  EXTRA_OECONF = "--enable-static"
  # Building without largefile is not supported by upstream
 
 
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#96850): https://lists.openembedded.org/g/openembedded-devel/message/96850
Mute This Topic: https://lists.openembedded.org/mt/90765285/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw
Quoted 31 lines · Khem Raj
Quoted 11 lines · Alejandro Hernandez Samaniego

Cryptsetup allows for certain luks2 related defaults to be set for libcryptsetup, these include the default PBKDF algorithm, memory limit for PBKDF2, parallel threads and iteration time.

Add these options as PACKAGECONFIGs to cryptsetup while setting variables defined as the current cryptsetup defaults, making this change transparent for the user but allow these knobs to be customized.

Signed-off-by Alejandro Enedino Hernandez Samaniego <

[email protected]>

Review

Quoted 5 lines
---
  .../recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb    | 12 ++++++++++++
  1 file changed, 12 insertions(+)
(quoted diff) +0 -0

b/meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb

meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb PACKAGECONFIG:append:class-target = " \ · line 48

Quoted 9 lines

index 8f9f663a3..7baca98cb 100644

meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb +2 -0
@@ -44,6 +44,14 @@ PACKAGECONFIG:append:class-target = " \
      udev \
  "
 
+
+# libcryptsetup default PBKDF algorithm, Argon2 memory cost (KB),

parallel threads and iteration time (ms)

Quoted 8 lines

meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb PACKAGECONFIG:append:class-target = " \ · line 53

Quoted 5 lines
meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb +5 -0
+LUKS2_PBKDF ?= "argon2i"
+LUKS2_MEMORYKB ?= "1048576"
+LUKS2_PARALLEL_THREADS ?= "4"
+LUKS2_ITERTIME ?= "2000"
+

is this something that can be selected at runtime too ?

Hi Khem,

Yes, if using cryptsetup directly these can be changed at runtime regardless of the default set here.

Being able to change these at build time becomes useful when relying on the libcryptsetup API.

Cheers,
Alejandro

Quoted 34 lines

meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb PACKAGECONFIG:append:class-target = " \

Quoted 4 lines
meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb +1 -0
+
  PACKAGECONFIG[keyring] = "--enable-keyring,--disable-keyring"
  PACKAGECONFIG[fips] = "--enable-fips,--disable-fips"
  PACKAGECONFIG[pwquality] =

"--enable-pwquality,--disable-pwquality,libpwquality"

meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb PACKAGECONFIG[nss] = "--with-crypto_backend=nss,,nss" · line 79

Quoted 4 lines
meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb +0 -0
@@ -69,6 +77,10 @@ PACKAGECONFIG[nss] = "--with-crypto_backend=nss,,nss"
  PACKAGECONFIG[kernel] = "--with-crypto_backend=kernel"
  PACKAGECONFIG[nettle] = "--with-crypto_backend=nettle,,nettle"
  PACKAGECONFIG[luks2] =

"--with-default-luks-format=LUKS2,--with-default-luks-format=LUKS1"

meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb PACKAGECONFIG[nss] = "--with-crypto_backend=nss,,nss" · line 81

Quoted 2 lines
meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb +2 -0
+PACKAGECONFIG[luks2-pbkdf] = "--with-luks2-pbkdf=${LUKS2_PBKDF}"
+PACKAGECONFIG[luks2-memorykb] =

"--with-luks2-memory-kb=${LUKS2_MEMORYKB}"

meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb PACKAGECONFIG[nss] = "--with-crypto_backend=nss,,nss" · line 82

Quoted 1 line
meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb +1 -0
+PACKAGECONFIG[luks2-parallel-threads] =

"--with-luks2-parallel-threads=${LUKS2_PARALLEL_THREADS}"

meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb PACKAGECONFIG[nss] = "--with-crypto_backend=nss,,nss" · line 83

Quoted 1 line
meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb +1 -0
+PACKAGECONFIG[luks2-itertime] =

"--with-luks2-iter-time=${LUKS2_ITERTIME}"

Quoted 9 lines
meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb +0 -1
  EXTRA_OECONF = "--enable-static"
  # Building without largefile is not supported by upstream
 
 
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group. View/Reply Online (#96850):

https://lists.openembedded.org/g/openembedded-devel/message/96850

Quoted 3 lines

Mute This Topic: https://lists.openembedded.org/mt/90765285/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [

[email protected]]

Quoted 2 lines

-=-=-=-=-=-=-=-=-=-=-=-

#3 lore raw
Quoted 43 lines · Alejandro Enedino Hernandez Samaniego
Quoted 27 lines · Khem Raj
Quoted 23 lines · Alejandro Hernandez Samaniego

Cryptsetup allows for certain luks2 related defaults to be set for libcryptsetup, these include the default PBKDF algorithm, memory limit for PBKDF2, parallel threads and iteration time.

Add these options as PACKAGECONFIGs to cryptsetup while setting variables defined as the current cryptsetup defaults, making this change transparent for the user but allow these knobs to be customized.

---
  .../recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb    | 12 ++++++++++++
  1 file changed, 12 insertions(+)
meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb +0 -0
index 8f9f663a3..7baca98cb 100644
@@ -44,6 +44,14 @@ PACKAGECONFIG:append:class-target = " \
      udev \
  "
 
Quoted 9 lines

meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb PACKAGECONFIG:append:class-target = " \ · line 53

Quoted 7 lines
meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb +7 -0
+
+# libcryptsetup default PBKDF algorithm, Argon2 memory cost (KB), parallel threads and iteration time (ms)
+LUKS2_PBKDF ?= "argon2i"
+LUKS2_MEMORYKB ?= "1048576"
+LUKS2_PARALLEL_THREADS ?= "4"
+LUKS2_ITERTIME ?= "2000"
+

is this something that can be selected at runtime too ?

Quoted 4 lines

Hi Khem,

Yes, if using cryptsetup directly these can be changed at runtime regardless of the default set here.

in current settings, it will need to set two knobs and it seems a bit off from what packageconfigs are for.
so perhaps we can enable the default configure options unconditionally with default values and make the values a weak assigment.

Quoted 34 lines

Being able to change these at build time becomes useful when relying on the libcryptsetup API.

Cheers,
Alejandro

Quoted 27 lines
Quoted 27 lines
meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb +5 -1
+
  PACKAGECONFIG[keyring] = "--enable-keyring,--disable-keyring"
  PACKAGECONFIG[fips] = "--enable-fips,--disable-fips"
  PACKAGECONFIG[pwquality] = "--enable-pwquality,--disable-pwquality,libpwquality"
@@ -69,6 +77,10 @@ PACKAGECONFIG[nss] = "--with-crypto_backend=nss,,nss"
  PACKAGECONFIG[kernel] = "--with-crypto_backend=kernel"
  PACKAGECONFIG[nettle] = "--with-crypto_backend=nettle,,nettle"
  PACKAGECONFIG[luks2] = "--with-default-luks-format=LUKS2,--with-default-luks-format=LUKS1"
+PACKAGECONFIG[luks2-pbkdf] = "--with-luks2-pbkdf=${LUKS2_PBKDF}"
+PACKAGECONFIG[luks2-memorykb] = "--with-luks2-memory-kb=${LUKS2_MEMORYKB}"
+PACKAGECONFIG[luks2-parallel-threads] = "--with-luks2-parallel-threads=${LUKS2_PARALLEL_THREADS}"
+PACKAGECONFIG[luks2-itertime] = "--with-luks2-iter-time=${LUKS2_ITERTIME}"
 
  EXTRA_OECONF = "--enable-static"
  # Building without largefile is not supported by upstream
 
 
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#96850): https://lists.openembedded.org/g/openembedded-devel/message/96850
Mute This Topic: https://lists.openembedded.org/mt/90765285/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#4 lore raw
Quoted 51 lines · Khem Raj
Quoted 13 lines · Alejandro Enedino Hernandez Samaniego
Quoted 9 lines · Khem Raj
Quoted 5 lines · Alejandro Hernandez Samaniego

Cryptsetup allows for certain luks2 related defaults to be set for libcryptsetup, these include the default PBKDF algorithm, memory limit for PBKDF2, parallel threads and iteration time.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Add these options as PACKAGECONFIGs to cryptsetup while setting variables defined as the current cryptsetup defaults, making this change transparent for the user but allow these knobs to be customized.

Signed-off-by Alejandro Enedino Hernandez Samaniego <

[email protected]>

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
---
  .../recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb    | 12

++++++++++++

Quoted 3 lines
Quoted 3 lines

Review

Quoted 3 lines
  1 file changed, 12 insertions(+)
(quoted diff) +0 -0

b/meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb

Quoted 9 lines
Quoted 9 lines

meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb PACKAGECONFIG:append:class-target = " \ · line 48

Quoted 9 lines

index 8f9f663a3..7baca98cb 100644

meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb +2 -0
@@ -44,6 +44,14 @@ PACKAGECONFIG:append:class-target = " \
      udev \
  "
 
+
+# libcryptsetup default PBKDF algorithm, Argon2 memory cost (KB),

parallel threads and iteration time (ms)

Quoted 12 lines
Quoted 7 lines

meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb PACKAGECONFIG:append:class-target = " \ · line 53

Quoted 5 lines
meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb +5 -0
+LUKS2_PBKDF ?= "argon2i"
+LUKS2_MEMORYKB ?= "1048576"
+LUKS2_PARALLEL_THREADS ?= "4"
+LUKS2_ITERTIME ?= "2000"
+

is this something that can be selected at runtime too ?

Hi Khem,

Quoted 9 lines
Quoted 1 line

Yes, if using cryptsetup directly these can be changed at runtime

regardless of the default set here.

Quoted 1 line

in current settings, it will need to set two knobs and it seems a bit off from what packageconfigs are for.
so perhaps we can enable the default configure options unconditionally with default values and make the values a weak assigment.

I'd be fine with that too, the only thing worth mentioning is that some of these are only valid as a combination, for example:

Luks2-memorykb is only valid when luks2-pbkdf="argon2<foo>", if luks2-pbkdf="pbkdf2" the luks header doesn't contain a memory field, also all these are only valid when the type=luks2

I believe we can just set them all as you say, as long as they don't conflict with one another and cause an error during do_configure.

I can check if these are okay to set and discarded if not compatible and we can go with that, performing checks for compatibility with anonymous python is another solution but seems a bit of an overkill.

Quoted 45 lines
Quoted 1 line

Being able to change these at build time becomes useful when relying on

the libcryptsetup API.

Quoted 11 lines

Cheers,
Alejandro

Quoted 5 lines
Quoted 5 lines
meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb +1 -0
+
  PACKAGECONFIG[keyring] = "--enable-keyring,--disable-keyring"
  PACKAGECONFIG[fips] = "--enable-fips,--disable-fips"
  PACKAGECONFIG[pwquality] =

"--enable-pwquality,--disable-pwquality,libpwquality"

Quoted 1 line
Quoted 1 line

meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb PACKAGECONFIG[nss] =

Quoted 1 line
meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb +0 -0
@@ -69,6 +77,10 @@ PACKAGECONFIG[nss] =

"--with-crypto_backend=nss,,nss"

Quoted 3 lines
Quoted 3 lines

meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb PACKAGECONFIG[nss] = "--with-crypto_backend=nss,,nss"

Quoted 3 lines
meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb +0 -0
  PACKAGECONFIG[kernel] = "--with-crypto_backend=kernel"
  PACKAGECONFIG[nettle] = "--with-crypto_backend=nettle,,nettle"
  PACKAGECONFIG[luks2] =

"--with-default-luks-format=LUKS2,--with-default-luks-format=LUKS1"

Quoted 2 lines
Quoted 2 lines

meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb PACKAGECONFIG[nss] = · line 81

Quoted 2 lines
meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb +2 -0
+PACKAGECONFIG[luks2-pbkdf] = "--with-luks2-pbkdf=${LUKS2_PBKDF}"
+PACKAGECONFIG[luks2-memorykb] =

"--with-luks2-memory-kb=${LUKS2_MEMORYKB}"

Quoted 1 line
Quoted 1 line

meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb PACKAGECONFIG[nss] = · line 82

Quoted 1 line
meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb +1 -0
+PACKAGECONFIG[luks2-parallel-threads] =

"--with-luks2-parallel-threads=${LUKS2_PARALLEL_THREADS}"

Quoted 1 line
Quoted 1 line

meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb PACKAGECONFIG[nss] = · line 83

Quoted 1 line
meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb +1 -0
+PACKAGECONFIG[luks2-itertime] =

"--with-luks2-iter-time=${LUKS2_ITERTIME}"

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
meta-oe/recipes-crypto/cryptsetup/cryptsetup_2.4.3.bb +0 -1
  EXTRA_OECONF = "--enable-static"
  # Building without largefile is not supported by upstream
 
 
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group. View/Reply Online (#96850):

https://lists.openembedded.org/g/openembedded-devel/message/96850

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Mute This Topic: https://lists.openembedded.org/mt/90765285/1997914
Group Owner: [email protected] Unsubscribe:

https://lists.openembedded.org/g/openembedded-devel/unsub [ [email protected]]

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

-=-=-=-=-=-=-=-=-=-=-=-