From 13625df75ce06441df9c8e19d104c4fabf69bafe Mon Sep 17 00:00:00 2001 From: Chris Lamb Date: Sun, 23 Mar 2008 04:20:31 +0000 Subject: lh_binary_encryption: Rework and fix broken AES encryption routines --- helpers/lh_binary_encryption | 76 +++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 36 deletions(-) diff --git a/helpers/lh_binary_encryption b/helpers/lh_binary_encryption index e4157a4..35bdc24 100755 --- a/helpers/lh_binary_encryption +++ b/helpers/lh_binary_encryption @@ -92,54 +92,58 @@ Restore_cache cache/packages_binary # Installing depends Install_package -case "${LH_CHROOT_BUILD}" in - enabled) - # Moving image - mv binary/${INITFS}/filesystem.${LH_CHROOT_FILESYSTEM} chroot +Echo_message "Encrypting binary/${INITFS}/filesystem.${LH_CHROOT_FILESYSTEM} with ${LH_ENCRYPTION}..." -echo "Encrypting binary/${INITFS}/filesystem.${ROOTFS} with ${LH_ENCRYPTION}..." +if [ "${LH_CHROOT_BUILD}" = "enabled" ] +then + # Moving image + mv binary/${INITFS}/filesystem.${LH_CHROOT_FILESYSTEM} chroot +fi -cat >> chroot/encrypt.sh << EOF while true do - cat filesystem.${ROOTFS} | aespipe -e ${LH_ENCRYPTION} -T > filesystem.${ROOTFS}.tmp && mv filesystem.${ROOTFS}.tmp filesystem.${ROOTFS} && break - - echo -n "Something went wrong... Retry? [YES/no] " + echo + echo " **************************************" + echo " ** Configuring encrypted filesystem **" + echo " **************************************" + echo " (Passwords must be at least 20 characters long)" + echo + + case "${LH_CHROOT_BUILD}" in + enabled) + if Chroot aespipe -e ${LH_ENCRYPTION} -T \ + < chroot/filesystem.${LH_CHROOT_FILESYSTEM} \ + > chroot/filesystem.${LH_CHROOT_FILESYSTEM}.tmp + then + mv chroot/filesystem.${LH_CHROOT_FILESYSTEM}.tmp binary/${INITFS}/filesystem.${LH_CHROOT_FILESYSTEM} + break + fi + ;; + disabled) + if aespipe -e ${LH_ENCRYPTION} -T \ + < binary/${INITFS}/filesystem.${LH_CHROOT_FILESYSTEM} \ + > binary/${INITFS}/filesystem.${LH_CHROOT_FILESYSTEM}.tmp + then + mv binary/${INITFS}/filesystem.${LH_CHROOT_FILESYSTEM}.tmp binary/${INITFS}/filesystem.${LH_CHROOT_FILESYSTEM} + break + fi + ;; + esac + printf "\nThere was an error configuring encryption ... Retry? [Y/n] " read ANSWER - if [ "no" = "${ANSWER}" ] + if [ "$(echo "${ANSWER}" | cut -b1 | tr A-Z a-z)" = "n" ] then unset ANSWER break fi done -EOF - - Chroot "sh encrypt.sh" - - # Move image - mv chroot/filesystem.${LH_CHROOT_FILESYSTEM} binary/${INITFS} - rm -f chroot/encrypt.sh - ;; - - disabled) - while true - do - cat binary/${INITFS}/filesystem.${ROOTFS} | aespipe -e ${LH_ENCRYPTION} -T > binary/${INITFS}/filesystem.${ROOTFS}.tmp && mv binary/${INITFS}/filesystem.${ROOTFS}.tmp binary/${INITFS}/filesystem.${ROOTFS} && break - - echo -n "Something went wrong... Retry? [YES/no] " - - read ANSWER - - if [ "no" = "${ANSWER}" ] - then - unset ANSWER - break - fi - done - ;; -esac + +# Cleanup temporary filesystems +rm -f chroot/filesystem.${LH_CHROOT_FILESYSTEM} +rm -f chroot/filesystem.${LH_CHROOT_FILESYSTEM}.tmp +rm -f binary/${INITFS}/filesystem.${LH_CHROOT_FILESYSTEM}.tmp # Saving cache Save_cache cache/packages_binary -- cgit v1.0