Blame SOURCES/0013-luks-define-max-entropy-bits-for-pwmake.patch

412654
--- clevis-15.ori/src/clevis.1.adoc	2020-10-28 19:55:47.663228800 +0100
412654
+++ clevis-15/src/clevis.1.adoc	2023-01-11 17:18:29.967295005 +0100
412654
@@ -101,7 +101,7 @@
412654
 
412654
 This command performs four steps:
412654
 
412654
-1. Creates a new key with the same entropy as the LUKS master key.
412654
+1. Creates a new key with the same entropy as the LUKS master key -- maximum entropy bits is 256.
412654
 2. Encrypts the new key with Clevis.
412654
 3. Stores the Clevis JWE in the LUKS header.
412654
 4. Enables the new key for use with LUKS.
412654
--- clevis-15.ori/src/luks/clevis-luks-bind.1.adoc	2020-10-28 19:55:47.663228800 +0100
412654
+++ clevis-15/src/luks/clevis-luks-bind.1.adoc	2023-01-11 17:18:55.239351209 +0100
412654
@@ -20,7 +20,7 @@
412654
 
412654
 This command performs four steps:
412654
 
412654
-1. Creates a new key with the same entropy as the LUKS master key.
412654
+1. Creates a new key with the same entropy as the LUKS master key -- maximum entropy bits is 256.
412654
 2. Encrypts the new key with Clevis.
412654
 3. Stores the Clevis JWE in the LUKS header.
412654
 4. Enables the new key for use with LUKS.
412654
--- clevis-15.ori/src/luks/clevis-luks-common-functions	2023-01-11 17:15:44.984928070 +0100
412654
+++ clevis-15/src/luks/clevis-luks-common-functions	2023-01-11 17:20:53.238613637 +0100
412654
@@ -865,6 +865,7 @@
412654
     [ -z "${DEV}" ] && return 1
412654
 
412654
     local dump filter bits
412654
+    local MAX_ENTROPY_BITS=256
412654
     dump=$(cryptsetup luksDump "${DEV}")
412654
     if cryptsetup isLuks --type luks1 "${DEV}"; then
412654
         filter="$(echo "${dump}" | sed -rn 's|MK bits:[ \t]*([0-9]+)|\1|p')"
412654
@@ -876,6 +877,9 @@
412654
     fi
412654
 
412654
     bits="$(echo -n "${filter}" | sort -n | tail -n 1)"
412654
+    if [ "${bits}" -gt "${MAX_ENTROPY_BITS}" ]; then
412654
+        bits="${MAX_ENTROPY_BITS}"
412654
+    fi
412654
     pwmake "${bits}"
412654
 }
412654
412654
--- clevis-15.ori/src/luks/clevis-luks-bind.in	2023-01-11 17:15:44.815927694 +0100
412654
+++ clevis-15/src/luks/clevis-luks-bind.in	2023-01-12 16:20:30.266404993 +0100
412654
@@ -19,6 +19,8 @@
412654
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
412654
 #
412654
 
412654
+. clevis-luks-common-functions
412654
+
412654
 SUMMARY="Binds a LUKS device using the specified policy"
412654
 UUID=cb6e8904-81ff-40da-a84a-07ab9ab5715e
412654
 
412654
@@ -139,14 +141,11 @@
412654
 fi
412654
 
412654
 # Generate a key with the same entropy as the LUKS Master Key
412654
-key="$(pwmake "$(
412654
-cryptsetup luksDump "$DEV" \
412654
-    | if [ "$luks_type" == "luks1" ]; then
412654
-        sed -rn 's|MK bits:[ \t]*([0-9]+)|\1|p'
412654
-    else
412654
-        sed -rn 's|^\s+Key:\s+([0-9]+) bits\s*$|\1|p'
412654
-    fi | sort -n | tail -n 1
412654
-)")"
412654
+if ! key="$(clevis_luks_generate_key "${DEV}")" \
412654
+     || [ -z "${key}" ]; then
412654
+    echo "Unable to generate key for ${DEV}" >&2
412654
+    return 1
412654
+fi
412654
 
412654
 # Encrypt the new key
412654
 jwe="$(echo -n "$key" | clevis encrypt "$PIN" "$CFG" "${YES}")"