lh_binary_encryption: Rework and fix broken AES encryption routines
Signed-off-by: Chris Lamb <chris@chris-lamb.co.uk>
This commit is contained in:
parent
31dca28f67
commit
ea375828e9
|
@ -92,55 +92,59 @@ Restore_cache cache/packages_binary
|
|||
# Installing depends
|
||||
Install_package
|
||||
|
||||
case "${LH_CHROOT_BUILD}" in
|
||||
enabled)
|
||||
Echo_message "Encrypting binary/${INITFS}/filesystem.${LH_CHROOT_FILESYSTEM} with ${LH_ENCRYPTION}..."
|
||||
|
||||
if [ "${LH_CHROOT_BUILD}" = "enabled" ]
|
||||
then
|
||||
# Moving image
|
||||
mv binary/${INITFS}/filesystem.${LH_CHROOT_FILESYSTEM} chroot
|
||||
fi
|
||||
|
||||
echo "Encrypting binary/${INITFS}/filesystem.${ROOTFS} with ${LH_ENCRYPTION}..."
|
||||
|
||||
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
|
||||
echo " **************************************"
|
||||
echo " ** Configuring encrypted filesystem **"
|
||||
echo " **************************************"
|
||||
echo " (Passwords must be at least 20 characters long)"
|
||||
echo
|
||||
|
||||
echo -n "Something went wrong... Retry? [YES/no] "
|
||||
|
||||
read ANSWER
|
||||
|
||||
if [ "no" = "${ANSWER}" ]
|
||||
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
|
||||
unset ANSWER
|
||||
mv chroot/filesystem.${LH_CHROOT_FILESYSTEM}.tmp binary/${INITFS}/filesystem.${LH_CHROOT_FILESYSTEM}
|
||||
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}" ]
|
||||
if aespipe -e ${LH_ENCRYPTION} -T \
|
||||
< binary/${INITFS}/filesystem.${LH_CHROOT_FILESYSTEM} \
|
||||
> binary/${INITFS}/filesystem.${LH_CHROOT_FILESYSTEM}.tmp
|
||||
then
|
||||
unset ANSWER
|
||||
mv binary/${INITFS}/filesystem.${LH_CHROOT_FILESYSTEM}.tmp binary/${INITFS}/filesystem.${LH_CHROOT_FILESYSTEM}
|
||||
break
|
||||
fi
|
||||
done
|
||||
;;
|
||||
esac
|
||||
|
||||
printf "\nThere was an error configuring encryption ... Retry? [Y/n] "
|
||||
read ANSWER
|
||||
|
||||
if [ "$(echo "${ANSWER}" | cut -b1 | tr A-Z a-z)" = "n" ]
|
||||
then
|
||||
unset ANSWER
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# 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
|
||||
|
||||
|
|
Loading…
Reference in New Issue