summaryrefslogtreecommitdiff
path: root/tests/futility/test_sign_usbpd1.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/futility/test_sign_usbpd1.sh')
-rwxr-xr-xtests/futility/test_sign_usbpd1.sh56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/futility/test_sign_usbpd1.sh b/tests/futility/test_sign_usbpd1.sh
new file mode 100755
index 00000000..dc3b6420
--- /dev/null
+++ b/tests/futility/test_sign_usbpd1.sh
@@ -0,0 +1,56 @@
+#!/bin/bash -eux
+# Copyright 2015 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+me=${0##*/}
+TMP="$me.tmp"
+
+# Work in scratch directory
+cd "$OUTDIR"
+
+# The signed input images are signed with dev keys. We resign the unsigned
+# images with the same keypair, to make sure that we're producing identical
+# binaries.
+
+DATADIR="${SCRIPTDIR}/data"
+TESTS="dingdong hoho minimuffin zinger"
+
+set -o pipefail
+
+count=0
+for test in $TESTS; do
+
+ : $(( count++ ))
+ echo -n "$count " 1>&3
+
+ pemfile=${DATADIR}/${test}.pem
+ infile=${DATADIR}/${test}.unsigned
+ goodfile=${DATADIR}/${test}.signed
+ outfile=${TMP}.${test}.new
+
+ # Signing the whole thing with futility should produce identical results
+ ${FUTILITY} sign --type usbpd1 --pem ${pemfile} ${infile} ${outfile}
+ cmp ${goodfile} ${outfile}
+
+ # Now try signing just the RW part
+ size=$(stat -c '%s' ${infile})
+ half=$(( size / 2 ))
+
+ newin=${TMP}.${test}.rw_in
+ dd if=${infile} bs=${half} count=1 skip=1 of=${newin}
+ newgood=${TMP}.${test}.rw_ok
+ dd if=${goodfile} bs=${half} count=1 skip=1 of=${newgood}
+ newout=${TMP}.${test}.rw_out
+
+ # Sign the RW part alone
+ ${FUTILITY} sign --type usbpd1 --pem ${pemfile} \
+ --ro_size 0 \
+ ${newin} ${newout}
+ cmp ${newgood} ${newout}
+
+done
+
+# cleanup
+rm -rf ${TMP}*
+exit 0