tests: Make test more robust.
[gnupg.git] / tests / sm-verify
1 # sm-verify 
2 #
3 # Verify a few distributed signatures.
4 # Requirements: 
5 #
6
7 srcdir = getenv srcdir
8
9 # Check an opaque signature
10 sig = openfile $srcdir/text-1.osig.pem
11 out = createfile msg.unsig
12 pipeserver $GPGSM
13 send INPUT FD=$sig
14 expect-ok
15 send OUTPUT FD=$out
16 expect-ok
17 badsig  = count-status BADSIG
18 goodsig = count-status GOODSIG
19 trusted = count-status TRUST_FULLY
20 send VERIFY
21 expect-ok
22 echo badsig=$badsig goodsig=$goodsig trusted=$trusted
23 fail-if $badsig
24 fail-if !$goodsig
25 fail-if !$trusted
26 send BYE
27 expect-ok
28
29 sig =
30 out =
31 cmpfiles $srcdir/text-1.txt msg.unsig
32 fail-if !$?
33
34 # Check a detached signature.
35 sig = openfile $srcdir/text-1.dsig.pem
36 plain = openfile $srcdir/text-1.txt
37 pipeserver $GPGSM
38 send INPUT FD=$sig
39 expect-ok
40 send MESSAGE FD=$plain
41 expect-ok
42 badsig  = count-status BADSIG
43 goodsig = count-status GOODSIG
44 trusted = count-status TRUST_FULLY
45 send VERIFY
46 expect-ok
47 echo badsig=$badsig goodsig=$goodsig trusted=$trusted
48 fail-if $badsig
49 fail-if !$goodsig
50 fail-if !$trusted
51 send BYE
52 expect-ok
53
54 # Check a tampered opaque message
55 sig = openfile $srcdir/text-1.osig-bad.pem
56 out = createfile msg.unsig
57
58 pipeserver $GPGSM
59 send INPUT FD=$sig
60 expect-ok
61 send OUTPUT FD=$out
62 expect-ok
63 badsig  = count-status BADSIG
64 goodsig = count-status GOODSIG
65 trusted = count-status TRUST_FULLY
66 send VERIFY
67 expect-ok
68 echo badsig=$badsig goodsig=$goodsig trusted=$trusted
69 fail-if $goodsig
70 fail-if !$badsig
71 fail-if $trusted
72 send BYE
73 expect-ok
74
75 # Check another opaque signature but without asking for the output.
76 sig = openfile $srcdir/text-2.osig.pem
77
78 pipeserver $GPGSM
79 send INPUT FD=$sig
80 expect-ok
81 badsig  = count-status BADSIG
82 goodsig = count-status GOODSIG
83 trusted = count-status TRUST_FULLY
84 send VERIFY
85 expect-ok
86 echo badsig=$badsig goodsig=$goodsig trusted=$trusted
87 fail-if $badsig
88 fail-if !$goodsig
89 fail-if !$trusted
90 send BYE
91 expect-ok
92
93 # We als have tampered version.
94 sig = openfile $srcdir/text-2.osig-bad.pem
95
96 pipeserver $GPGSM
97 send INPUT FD=$sig
98 expect-ok
99 badsig  = count-status BADSIG
100 goodsig = count-status GOODSIG
101 trusted = count-status TRUST_FULLY
102 send VERIFY
103 expect-ok
104 echo badsig=$badsig goodsig=$goodsig trusted=$trusted
105 fail-if $goodsig
106 fail-if !$badsig
107 fail-if $trusted
108 send BYE
109 expect-ok
110
111
112 quit
113
114