tests: Improve handling of Windows newlines.
[gnupg.git] / tests / openpgp / multisig.scm
1 #!/usr/bin/env gpgscm
2
3 ;; Copyright (C) 2016 g10 Code GmbH
4 ;;
5 ;; This file is part of GnuPG.
6 ;;
7 ;; GnuPG is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 3 of the License, or
10 ;; (at your option) any later version.
11 ;;
12 ;; GnuPG is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ;; GNU General Public License for more details.
16 ;;
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program; if not, see <http://www.gnu.org/licenses/>.
19
20 ;; Check that gpg verifies only signatures where there is no ambiguity
21 ;; in the order of packets.  Needs the Demo Keys Lima and Mike.
22 ;;
23 ;; Note: We do not support multiple signatures anymore thus this test is
24 ;; not really needed because verify could do the same.  We keep it anyway.
25
26 (load (with-path "defs.scm"))
27
28 (define sig-1ls1ls-valid "
29 -----BEGIN PGP ARMORED FILE-----
30
31 kA0DAAIRN8q1H7eRA/gBrCdiBXRleHQxOogq9EkgYW0gc29ycnksIEkgY2FuJ3Qg
32 ZG8gdGhhdAqIPwMFADqIKvQ3yrUft5ED+BEC2joAoJaSaXOZEtSZqQ780HIXG77e
33 8PB7AJ4wCprmaFTO0fBaTcXDuEOBdAWnOZANAwACETfKtR+3kQP4AawnYgV0ZXh0
34 MTqIKvRJIGFtIHNvcnJ5LCBJIGNhbid0IGRvIHRoYXQKiD8DBQA6iCr0N8q1H7eR
35 A/gRAto6AKCWkmlzmRLUmakO/NByFxu+3vDwewCeMAqa5mhUztHwWk3Fw7hDgXQF
36 pzk=
37 =8jSC
38 -----END PGP ARMORED FILE-----
39 ")
40 (define sig-ls-valid "
41 -----BEGIN PGP ARMORED FILE-----
42
43 rCdiBXRleHQxOogrS0kgYW0gc29ycnksIEkgY2FuJ3QgZG8gdGhhdAqIPwMFADqI
44 K0s3yrUft5ED+BECLQMAn2jZUNOpB4OuurSQkc2TRfg6ek02AJ9+oJS0frQ+yUsT
45 QDUFTH2PvZRxjw==
46 =J+lb
47 -----END PGP ARMORED FILE-----
48 ")
49 (define sig-sl-valid "
50 -----BEGIN PGP ARMORED FILE-----
51
52 iD8DBQA6iCtLN8q1H7eRA/gRAi0DAJ9o2VDTqQeDrrq0kJHNk0X4OnpNNgCffqCU
53 tH60PslLE0A1BUx9j72UcY+sJ2IFdGV4dDE6iCtLSSBhbSBzb3JyeSwgSSBjYW4n
54 dCBkbyB0aGF0Cg==
55 =N9MP
56 -----END PGP ARMORED FILE-----
57 ")
58 (define sig-11lss-valid-but-is-not "
59 -----BEGIN PGP ARMORED FILE-----
60
61 kA0DAAIRN8q1H7eRA/gAkA0DAAIRN8q1H7eRA/gBrCdiBXRleHQxOogyXUkgYW0g
62 c29ycnksIEkgY2FuJ3QgZG8gdGhhdAqIPwMFADqIMl03yrUft5ED+BECwQAAnRXT
63 mXjVd385oD38W80XuheWKTGcAJ9pZ6/flaKDfw+SLido7xaUHuhp5Yg/AwUAOogy
64 XTfKtR+3kQP4EQLBAACgnN0IP+NztE0aAc/DZ17yHWR9diwAniN0P01WmbgZJoZB
65 Q341WRXKS/at
66 =Ekrs
67 -----END PGP ARMORED FILE-----
68 ")
69 (define sig-11lss11lss-valid-but-is-not "
70 -----BEGIN PGP ARMORED FILE-----
71
72 kA0DAAIRN8q1H7eRA/gAkA0DAAIRN8q1H7eRA/gBrCdiBXRleHQxOogyXUkgYW0g
73 c29ycnksIEkgY2FuJ3QgZG8gdGhhdAqIPwMFADqIMl03yrUft5ED+BECwQAAnRXT
74 mXjVd385oD38W80XuheWKTGcAJ9pZ6/flaKDfw+SLido7xaUHuhp5Yg/AwUAOogy
75 XTfKtR+3kQP4EQLBAACgnN0IP+NztE0aAc/DZ17yHWR9diwAniN0P01WmbgZJoZB
76 Q341WRXKS/atkA0DAAIRN8q1H7eRA/gAkA0DAAIRN8q1H7eRA/gBrCdiBXRleHQx
77 OogyXUkgYW0gc29ycnksIEkgY2FuJ3QgZG8gdGhhdAqIPwMFADqIMl03yrUft5ED
78 +BECwQAAnRXTmXjVd385oD38W80XuheWKTGcAJ9pZ6/flaKDfw+SLido7xaUHuhp
79 5Yg/AwUAOogyXTfKtR+3kQP4EQLBAACgnN0IP+NztE0aAc/DZ17yHWR9diwAniN0
80 P01WmbgZJoZBQ341WRXKS/at
81 =P1Mu
82 -----END PGP ARMORED FILE-----
83 ")
84 (define sig-ssl-valid-but-is-not "
85 -----BEGIN PGP ARMORED FILE-----
86
87 iD8DBQA6iCtLN8q1H7eRA/gRAi0DAJ9o2VDTqQeDrrq0kJHNk0X4OnpNNgCffqCU
88 tH60PslLE0A1BUx9j72UcY+IPwMFADqIK0s3yrUft5ED+BECLQMAn2jZUNOpB4Ou
89 urSQkc2TRfg6ek02AJ9+oJS0frQ+yUsTQDUFTH2PvZRxj6wnYgV0ZXh0MTqIK0tJ
90 IGFtIHNvcnJ5LCBJIGNhbid0IGRvIHRoYXQK
91 =Zven
92 -----END PGP ARMORED FILE-----
93 ")
94 (define sig-1lsls-invalid "
95 -----BEGIN PGP ARMORED FILE-----
96
97 kA0DAAIRN8q1H7eRA/gBrCdiBXRleHQxOogq9EkgYW0gc29ycnksIEkgY2FuJ3Qg
98 ZG8gdGhhdAqIPwMFADqIKvQ3yrUft5ED+BEC2joAoJaSaXOZEtSZqQ780HIXG77e
99 8PB7AJ4wCprmaFTO0fBaTcXDuEOBdAWnOawnYgV0ZXh0MTqIK0tJIGFtIHNvcnJ5
100 LCBJIGNhbid0IGRvIHRoYXQKiD8DBQA6iCtLN8q1H7eRA/gRAi0DAJ9o2VDTqQeD
101 rrq0kJHNk0X4OnpNNgCffqCUtH60PslLE0A1BUx9j72UcY8=
102 =nkeu
103 -----END PGP ARMORED FILE-----
104 ")
105 (define sig-lsls-invalid "
106 -----BEGIN PGP ARMORED FILE-----
107
108 rCdiBXRleHQxOogrS0kgYW0gc29ycnksIEkgY2FuJ3QgZG8gdGhhdAqIPwMFADqI
109 K0s3yrUft5ED+BECLQMAn2jZUNOpB4OuurSQkc2TRfg6ek02AJ9+oJS0frQ+yUsT
110 QDUFTH2PvZRxj6wnYgV0ZXh0MTqIK0tJIGFtIHNvcnJ5LCBJIGNhbid0IGRvIHRo
111 YXQKiD8DBQA6iCtLN8q1H7eRA/gRAi0DAJ9o2VDTqQeDrrq0kJHNk0X4OnpNNgCf
112 fqCUtH60PslLE0A1BUx9j72UcY8=
113 =BlZH
114 -----END PGP ARMORED FILE-----
115 ")
116 (define sig-lss-invalid "
117 -----BEGIN PGP ARMORED FILE-----
118
119 rCdiBXRleHQxOogrS0kgYW0gc29ycnksIEkgY2FuJ3QgZG8gdGhhdAqIPwMFADqI
120 K0s3yrUft5ED+BECLQMAn2jZUNOpB4OuurSQkc2TRfg6ek02AJ9+oJS0frQ+yUsT
121 QDUFTH2PvZRxj4g/AwUAOogrSzfKtR+3kQP4EQItAwCfaNlQ06kHg666tJCRzZNF
122 +Dp6TTYAn36glLR+tD7JSxNANQVMfY+9lHGP
123 =jmt6
124 -----END PGP ARMORED FILE-----
125 ")
126 (define sig-slsl-invalid "
127 -----BEGIN PGP ARMORED FILE-----
128
129 iD8DBQA6iCtLN8q1H7eRA/gRAi0DAJ9o2VDTqQeDrrq0kJHNk0X4OnpNNgCffqCU
130 tH60PslLE0A1BUx9j72UcY+sJ2IFdGV4dDE6iCtLSSBhbSBzb3JyeSwgSSBjYW4n
131 dCBkbyB0aGF0Cog/AwUAOogrSzfKtR+3kQP4EQItAwCfaNlQ06kHg666tJCRzZNF
132 +Dp6TTYAn36glLR+tD7JSxNANQVMfY+9lHGPrCdiBXRleHQxOogrS0kgYW0gc29y
133 cnksIEkgY2FuJ3QgZG8gdGhhdAo=
134 =phBF
135 -----END PGP ARMORED FILE-----
136 ")
137
138 (for-each-p
139  "Checking that a valid signature is verified as such"
140  (lambda (armored-file)
141    (tr:do
142     (tr:pipe-do
143      (pipe:echo (eval armored-file (current-environment)))
144      (pipe:spawn `(,@GPG --dearmor)))
145     (tr:spawn "" `(,@GPG --verify **in**))))
146  '(sig-sl-valid))
147
148 ;; ???
149 ;;
150 ;; #for i in "$sig-11lss-valid-but-is-not" "$sig-11lss11lss-valid-but-is-not" \
151 ;; #         "$sig-ssl-valid-but-is-not"; do
152 ;; #    echo "$i" | $GPG --dearmor >x
153 ;; #    $GPG --verify <x 2>/dev/null || error "valid is invalid"
154 ;; #done
155
156 (for-each-p
157  "Checking that an invalid signature is verified as such"
158  (lambda (armored-file)
159    (lettmp (file)
160      (pipe:do
161       (pipe:echo (eval armored-file (current-environment)))
162       (pipe:spawn `(,@GPG --dearmor))
163       (pipe:write-to file (logior O_WRONLY O_CREAT O_BINARY) #o600))
164
165      (if (= 0 (call `(,@GPG --verify ,file)))
166          (error "Bad signature verified ok"))))
167  '(sig-1ls1ls-valid sig-ls-valid sig-1lsls-invalid
168                     sig-lsls-invalid sig-lss-invalid sig-slsl-invalid))