Imported Upstream version 2.4
[platform/upstream/nettle.git] / examples / rsa-verify-test
1 #! /bin/sh
2
3 if [ -z "$srcdir" ] ; then
4   srcdir=`pwd`
5 fi
6
7 data="$srcdir/nettle-benchmark.c"
8
9 if [ -x rsa-verify ] ; then
10   ./rsa-sign testkey < "$data" > testsignature \
11     && ./rsa-verify testkey.pub testsignature < "$data" \
12     || exit 1;
13   
14   # Try modifying the data
15   sed s/128/129/ < "$data" >testdata
16
17   if ./rsa-verify testkey.pub testsignature < testdata 2>/dev/null; then
18     exit 1
19   fi
20   
21   # Try modifying the signature
22   sed s/1/2/ <testsignature > testsignature2
23   if ./rsa-verify testkey.pub testsignature2 < "$data" 2>/dev/null; then
24     exit 1;
25   fi
26   exit 0
27 else
28   exit 77
29 fi