Skip to content

Commit 3bb852b

Browse files
sergio-correiasarroutbi
authored andcommitted
luks: define max entropy bits for pwmake
So that we don't get a warning about using a value outside the allowed entropy range, when generating a new passphrase. Update existing documentation that mentions entropy to list the limitation of 256 bits.
1 parent 22f6a40 commit 3bb852b

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

src/clevis.1.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ This is accomplished with a simple command:
101101

102102
This command performs four steps:
103103

104-
1. Creates a new key with the same entropy as the LUKS master key.
104+
1. Creates a new key with the same entropy as the LUKS master key -- maximum entropy bits is 256.
105105
2. Encrypts the new key with Clevis.
106106
3. Stores the Clevis JWE in the LUKS header.
107107
4. Enables the new key for use with LUKS.

src/luks/clevis-luks-bind.1.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ policy. This is accomplished with a simple command:
2020

2121
This command performs four steps:
2222

23-
1. Creates a new key with the same entropy as the LUKS master key.
23+
1. Creates a new key with the same entropy as the LUKS master key -- maximum entropy bits is 256.
2424
2. Encrypts the new key with Clevis.
2525
3. Stores the Clevis JWE in the LUKS header.
2626
4. Enables the new key for use with LUKS.

src/luks/clevis-luks-common-functions.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,7 @@ clevis_luks_generate_key() {
841841
[ -z "${DEV}" ] && return 1
842842

843843
local dump filter bits
844+
local MAX_ENTROPY_BITS=256 # Maximum allowed by pwmake.
844845
dump=$(cryptsetup luksDump "${DEV}")
845846
if cryptsetup isLuks --type luks1 "${DEV}"; then
846847
filter="$(echo "${dump}" | sed -rn 's|MK bits:[ \t]*([0-9]+)|\1|p')"
@@ -852,6 +853,9 @@ clevis_luks_generate_key() {
852853
fi
853854

854855
bits="$(echo -n "${filter}" | sort -n | tail -n 1)"
856+
if [ "${bits}" -gt "${MAX_ENTROPY_BITS}" ]; then
857+
bits="${MAX_ENTROPY_BITS}"
858+
fi
855859
pwmake "${bits}"
856860
}
857861

0 commit comments

Comments
 (0)