tDisable escapes when piping secrets - tomb - the crypto undertaker HTML git clone git://parazyd.org/tomb.git DIR Log DIR Files DIR Refs DIR README DIR LICENSE --- DIR commit 489b3582cb3291e60c4002187466e24f07aa5f80 DIR parent 9180b214afb3050ebe505f1abba5c11e45fbe5dc HTML Author: Jaromil <jaromil@dyne.org> Date: Thu, 20 Nov 2014 09:59:11 +0100 Disable escapes when piping secrets Switched to use echo with -E flag to disable escapes in keys: escape strings were discarded cryptsetup tomb operations when they were present in the decoded key random passphrase. Issue #154 The solution adopted here includes wrapping all cryptsetup operations to unify the behaviour adopted. Worth noting that this problem possibly breaks all tombs and keys created using the unstable Tomb from git development in the past 2 months. Regression tests with previous stable releases are OK. Diffstat: M AUTHORS.md | 2 +- M tomb | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) --- DIR diff --git a/AUTHORS.md b/AUTHORS.md t@@ -13,7 +13,7 @@ German translation by x3nu. Testing, reviews and documentation are contributed by Dreamer, Shining the Translucent, Mancausoft, Asbesto Molesto, Nignux, Vlax, The Grugq, -Reiven, GDrooid and the Linux Action Show! +Reiven, GDrooid, Alphazo and the Linux Action Show! Cryptsetup was developed by Christophe Saout and Clemens Fruhwirth. DIR diff --git a/tomb b/tomb t@@ -976,6 +976,13 @@ ask_key_password() { return 0 } +# call cryptsetup with arguments using the currently known secret +# echo flags eliminate newline and disable escape (BSD_ECHO) +_cryptsetup() { + echo -n -E - "$TOMBSECRET" | cryptsetup --key-file - ${=@} + return $? +} + # change tomb key password change_passwd() { local tmpnewkey lukskey c tombpass tombpasstmp t@@ -1496,17 +1503,14 @@ lock_tomb_with_key() { _success "Locking ::1 tomb file:: with ::2 tomb key file::" $TOMBFILE $TOMBKEYFILE _message "Formatting Luks mapped device." - print -n - $TOMBSECRET | \ - cryptsetup --key-file - --batch-mode \ + _cryptsetup --batch-mode \ --cipher ${cipher} --key-size 256 --key-slot 0 \ luksFormat ${nstloop} [[ $? == 0 ]] || { _warning "cryptsetup luksFormat returned an error." _failure "Operation aborted." } - print -n - $TOMBSECRET | \ - cryptsetup --key-file - \ - --cipher ${cipher} luksOpen ${nstloop} tomb.tmp + _cryptsetup --cipher ${cipher} luksOpen ${nstloop} tomb.tmp [[ $? == 0 ]] || { _warning "cryptsetup luksOpen returned an error." _failure "Operation aborted." } t@@ -1694,8 +1698,7 @@ mount_tomb() { } [[ $? == 0 ]] || _failure "No valid password supplied." - print -n - $TOMBSECRET | \ - cryptsetup --key-file - luksOpen ${nstloop} ${mapper} + _cryptsetup luksOpen ${nstloop} ${mapper} [[ -r /dev/mapper/${mapper} ]] || { _failure "Failure mounting the encrypted file." } t@@ -2233,8 +2236,7 @@ resize_tomb() { mapdate=`date +%s` mapper="tomb.$TOMBNAME.$mapdate.$(basename $nstloop)" - print -n - $TOMBSECRET | \ - cryptsetup --key-file - luksOpen ${nstloop} ${mapper} + _cryptsetup luksOpen ${nstloop} ${mapper} [[ -r /dev/mapper/${mapper} ]] || { _failure "Failure mounting the encrypted file." }