From 5c81f5fa70f82f44e4d7c59f5b7f7a3429ff3bdc Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 6 Feb 2014 00:17:33 +0100 Subject: [PATCH] gluon-autoupdater: add SHA512 support --- package/gluon-autoupdater/files/usr/sbin/autoupdater | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/package/gluon-autoupdater/files/usr/sbin/autoupdater b/package/gluon-autoupdater/files/usr/sbin/autoupdater index 88e64346..40c52750 100755 --- a/package/gluon-autoupdater/files/usr/sbin/autoupdater +++ b/package/gluon-autoupdater/files/usr/sbin/autoupdater @@ -102,7 +102,7 @@ analyse_manifest() { fi fw_version=$(echo "${my_firmware}"|cut -d' ' -f2) - fw_md5=$(echo "${my_firmware}"|cut -d' ' -f3) + fw_checksum=$(echo "${my_firmware}"|cut -d' ' -f3) fw_file=$(echo "${my_firmware}"|cut -d' ' -f4) return 0 @@ -141,8 +141,9 @@ autoupdate() { local fw_image=$(mktemp) fetch_firmware $MIRROR $fw_image || { rm -f $fw_image; return 1; } - image_md5=$(md5sum "$fw_image"|cut -b-32) - if test "$image_md5" != "$fw_md5"; then + image_sha512=$(sha512sum "$fw_image" | awk '{print $1}') + image_md5=$(md5sum "$fw_image" | awk '{print $1}') + if [ "$image_sha512" != "$fw_checksum" -a "$image_md5" != "$fw_checksum" ]; then echo "Invalid image checksum" >&2 rm -f $fw_image return 1 @@ -174,7 +175,7 @@ for mirror in $MIRRORS; do autoupdate $mirror && exit 0 unset fw_version - unset fw_md5 + unset fw_checksum unset fw_file done