From 92b6b8caf13fa0c8d9194210d759eb4bd695c495 Mon Sep 17 00:00:00 2001 From: slush0 Date: Thu, 19 Jun 2014 02:08:31 +0200 Subject: [PATCH] Tools for deterministic builds and firmware comparing --- docker-build.sh | 24 ++++++++++++++++++++++++ firmware-fingerprint.sh | 11 +++++++++++ 2 files changed, 35 insertions(+) create mode 100755 docker-build.sh create mode 100755 firmware-fingerprint.sh diff --git a/docker-build.sh b/docker-build.sh new file mode 100755 index 000000000..4cb95deee --- /dev/null +++ b/docker-build.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +dirname $0 + +# Build trezor firmware +docker build . | tee docker.log + +# Parse image name +IMAGE=`grep "Successfully built" docker.log | tail -n1 | cut -d' ' -f3` +echo "IMAGE NAME: $IMAGE" + +docker run -t $IMAGE true + +# Parse container name +CONTAINER=`docker ps -a | grep true | head -n1 | cut -d' ' -f1` +echo "CONTAINER NAME: $CONTAINER" + +docker cp $CONTAINER:/trezor-mcu/firmware/trezor.bin . + +echo "-------------------------" +echo "" +echo "SHA256 hash:" + +sha256sum trezor.bin diff --git a/firmware-fingerprint.sh b/firmware-fingerprint.sh new file mode 100755 index 000000000..498ba9c9b --- /dev/null +++ b/firmware-fingerprint.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +MAGIC=`head -c +4 $1` + +if [ "x$MAGIC" != "xTRZR" ]; then + echo "Missing magic characters 'TRZR', invalid firmware" + exit 1 +fi + +echo "Firmware fingerprint:" +tail -c +257 $1 | sha256sum