#! /bin/sh

set -e

./bin/sigsum-key generate -o test.key

echo foo > test.msg
rm -f test.msg.sig

./bin/sigsum-key sign -n sigsum-test -k test.key -o test.msg.sig < test.msg
./bin/sigsum-key verify -n sigsum-test -k test.key.pub -s test.msg.sig < test.msg

# Check that modified message makes verification fail.
if (cat test.msg && echo) \
    | ./bin/sigsum-key verify -n sigsum-test -k test.key.pub -s test.msg.sig 2>/dev/null ; then
    false
else
    true
fi
