summaryrefslogtreecommitdiff
path: root/tests/futility/test_show_usbpd1.sh
blob: 08b535b5f8608efd49d1e69a3ff606ed4b8f4dae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash -eux
# Copyright 2015 The ChromiumOS Authors
# 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="${SCRIPT_DIR}/futility/data"
TESTS="dingdong hoho minimuffin zinger"
TESTKEYS=${SRCDIR}/tests/testkeys

SIGS="1024 2048 4096 8192"
HASHES="SHA1 SHA256 SHA512"

set -o pipefail

for s in $SIGS; do

    echo -n "$s " 1>&3

    for test in $TESTS; do

        infile="${DATADIR}/${test}.unsigned"

        for h in $HASHES; do

            pemfile="${TESTKEYS}/key_rsa${s}.pem"
            outfile="${TMP}.${test}_${s}_${h}.new"

            # sign it
            "${FUTILITY}" sign --type usbpd1 --pem "${pemfile}" "${infile}" \
                          "${outfile}"

            # make sure it identifies correctly
            "${FUTILITY}" verify "${outfile}"

        done
    done
done

# cleanup
rm -rf "${TMP}"*
exit 0