Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
initrd support for crypt key file with offset and size
--- encrypt_hook 2014-12-09 12:47:02.379911026 +0000
+++ encrypt_hook 2014-12-09 12:47:41.416087076 +0000
@@ -7,7 +7,7 @@
# Get keyfile if specified
ckeyfile="/crypto_keyfile.bin"
if [ -n "$cryptkey" ]; then
- IFS=: read ckdev ckarg1 ckarg2 <<EOF
+ IFS=: read ckdev ckarg1 ckarg2 ckarg3 ckarg4 <<EOF
$cryptkey
EOF
@@ -18,9 +18,13 @@
*[!0-9]*)
# Use a file on the device
# ckarg1 is not numeric: ckarg1=filesystem, ckarg2=path
+ # ckarg3=offset, ckarg4=length
mkdir /ckey
mount -r -t "$ckarg1" "$resolved" /ckey
- dd if="/ckey/$ckarg2" of="$ckeyfile" >/dev/null 2>&1
+ [ -n "$ckarg3$ckarg4" ] && ckoffset="bs=1"
+ [ -n "$ckarg3" ] && ckoffset="$ckoffset skip=$ckarg3"
+ [ -n "$ckarg4" ] && ckoffset="$ckoffset count=$ckarg4"
+ dd if="/ckey/$ckarg2" of="$ckeyfile" $ckoffset >/dev/null 2>&1
umount /ckey
;;
*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.