summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtests/futility/run_test_scripts.sh1
-rwxr-xr-xtests/futility/test_show_rwsig.sh46
2 files changed, 47 insertions, 0 deletions
diff --git a/tests/futility/run_test_scripts.sh b/tests/futility/run_test_scripts.sh
index fe19f15b..b817c430 100755
--- a/tests/futility/run_test_scripts.sh
+++ b/tests/futility/run_test_scripts.sh
@@ -48,6 +48,7 @@ ${SCRIPTDIR}/test_load_fmap.sh
${SCRIPTDIR}/test_main.sh
${SCRIPTDIR}/test_show_contents.sh
${SCRIPTDIR}/test_show_kernel.sh
+${SCRIPTDIR}/test_show_rwsig.sh
${SCRIPTDIR}/test_show_vs_verify.sh
${SCRIPTDIR}/test_show_usbpd1.sh
${SCRIPTDIR}/test_sign_firmware.sh
diff --git a/tests/futility/test_show_rwsig.sh b/tests/futility/test_show_rwsig.sh
new file mode 100755
index 00000000..7ff25571
--- /dev/null
+++ b/tests/futility/test_show_rwsig.sh
@@ -0,0 +1,46 @@
+#!/bin/bash -eux
+# Copyright 2017 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"
+
+DATADIR="${SCRIPTDIR}/data"
+TESTKEYS=${SRCDIR}/tests/testkeys
+
+# Do not test 8192 as the signature length is > 1024 bytes
+SIGS="1024 2048 4096"
+HASHES="SHA1 SHA256 SHA512"
+
+set -o pipefail
+
+for s in $SIGS; do
+ echo -n "$s " 1>&3
+
+ for h in $HASHES; do
+ pemfile=${TESTKEYS}/key_rsa${s}.pem
+ outfile=${TMP}.${s}_${h}.new
+ infile=${DATADIR}/random_noise.bin
+ outkeys=${TMP}.${s}_${h}
+ outsig=${TMP}.${s}_${h}.signature
+
+ ${FUTILITY} create --desc "Test key" --hash_alg ${h} \
+ ${pemfile} ${outkeys}
+
+ ${FUTILITY} sign --type rwsig --prikey ${outkeys}.vbprik2 \
+ ${infile} ${outsig}
+ dd if=/dev/zero bs=$((4096 + 1024)) count=1 of=${outfile}
+ dd if=${infile} of=${outfile} conv=notrunc
+ dd if=${outsig} of=${outfile} bs=4096 seek=1 conv=notrunc
+
+ ${FUTILITY} show --type rwsig --pubkey ${outkeys}.vbpubk2 ${outfile}
+ done
+done
+
+# cleanup
+rm -rf ${TMP}*
+exit 0