From d990ce6bcb7fbc55a756b89d6f730f62306c10f7 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Wed, 3 Jun 2020 23:48:33 +0200 Subject: [PATCH] cryptroot: Retry mounting drives, if key does not work (you may add it). --- .../scripts/local-top/cryptroot | 34 +++++++++---------- rand/rand | 3 ++ 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/decrypt-root-with-usb/ubuntu-20.04/usr/share/initramfs-tools/scripts/local-top/cryptroot b/decrypt-root-with-usb/ubuntu-20.04/usr/share/initramfs-tools/scripts/local-top/cryptroot index 5d7151f..288aa1a 100644 --- a/decrypt-root-with-usb/ubuntu-20.04/usr/share/initramfs-tools/scripts/local-top/cryptroot +++ b/decrypt-root-with-usb/ubuntu-20.04/usr/share/initramfs-tools/scripts/local-top/cryptroot @@ -123,23 +123,6 @@ setup_mapping() { fi fi - if [ -z "${CRYPTTAB_OPTION_keyscript+x}" ]; then - # Wait for USB to settle - /bin/sleep 3 - - # Test all devices - mkdir /mnt - echo -n "Searching for cryptkey.txt on available disks... " - local partition - for partition in `cat /proc/partitions |awk '{print $4}'|tail -n +3`; do - if mount /dev/$partition /mnt 2>/dev/null; then - cat /mnt/cryptkey.txt >> /tmp/cryptkeys.txt 2>/dev/null - umount /dev/$partition - fi - done - echo "done." - fi - get_crypt_type # set CRYPTTAB_TYPE to the type of crypt device local count=0 maxtries="${CRYPTTAB_OPTION_tries:-3}" fstype vg rv while [ $maxtries -le 0 ] || [ $count -lt $maxtries ]; do @@ -147,6 +130,23 @@ setup_mapping() { # unlock via keyfile unlock_mapping "$CRYPTTAB_KEY" else + if [ -z "${CRYPTTAB_OPTION_keyscript+x}" ]; then + # Wait for USB to settle + /bin/sleep 3 + + # Test all devices + mkdir /mnt + echo -n "Searching for cryptkey.txt on available disks... " + local partition + for partition in `cat /proc/partitions |awk '{print $4}'|tail -n +3`; do + if mount /dev/$partition /mnt 2>/dev/null; then + cat /mnt/cryptkey.txt >> /tmp/cryptkeys.txt 2>/dev/null + umount /dev/$partition + fi + done + echo "done." + fi + if [ -s /tmp/cryptkeys.txt ]; then local keyfound keyfound=0 diff --git a/rand/rand b/rand/rand index 869e8cc..71d4fc1 100755 --- a/rand/rand +++ b/rand/rand @@ -115,7 +115,10 @@ randdata() { key=$(echo "$seed" | openssl sha256 -hex | cut -d' ' -f2) iv=$(echo "$seed" | openssl sha512 -hex | cut -d' ' -f2) fi + # single core = 743MiB/s < /dev/zero openssl enc -aes-128-ctr -K $key -iv $iv 2>/dev/null + # single core = 184MiB/s + # openssl rand 2000000000 } export -f randdata