3 ;; Copyright (C) 2016 g10 Code GmbH
5 ;; This file is part of GnuPG.
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.
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.
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/>.
20 (load (with-path "defs.scm"))
21 (setup-legacy-environment)
23 (define (check-signing args input)
26 (call-popen `(,@GPG --output ,signed --yes
27 ,@args ,source) input)
28 (call-popen `(,@GPG --output ,sink --yes ,signed) ""))))
31 "Checking signing and verifying plain text messages"
33 ((if (equal? "plain-3" source)
34 ;; plain-3 does not end in a newline, and gpg will add one.
35 ;; Therefore, we merely check that the verification is ok.
37 ;; Otherwise, we do check that we recover the original file.
40 (check-signing '(--passphrase-fd "0" --clear-sign) usrpass1)))
41 (append plain-files '("plain-large")))
43 ;; The test vectors are lists of length three, containing
44 ;; - a string to be signed,
45 ;; - a flag indicating whether we verify that the exact message is
46 ;; reconstructed (whitespace at the end is normalized for plain text
48 ;; - and a list of arguments to add to gpg when encoding
52 (define :check-equality cadr)
53 (define :options caddr)
57 '(;; one with long lines
58 ("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxyx
60 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
63 ;; one with only one long line
64 ("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxyx
67 ;; and one with an empty body
70 ;; and one with one empty line at the end
74 there is a blank line after this
78 ;; I think this file will be constructed wrong (gpg 0.9.3) but it
79 ;; should verify okay anyway.
83 ;; check our special diff mode
84 ("--- mainproc.c Tue Jun 27 09:28:11 2000
85 +++ mainproc.c~ Thu Jun 8 22:50:25 2000
86 @@ -1190,16 +1190,13 @@
87 md_enable( c->mfx.md, n1->pkt->pkt.signature->digest_algo);
89 /* ask for file and hash it */
90 - if( c->sigs_only ) {
92 rc = hash_datafiles( c->mfx.md, NULL,
93 c->signed_data, c->sigfilename,
94 n1? (n1->pkt->pkt.onepass_sig->sig_class == 0x01):0 );
95 " #t (--not-dash-escaped))))
97 (let ((counter (make-counter)))
99 "Checking signing and verifying test vectors"
102 (with-output-to-file tmp (lambda () (display (:string vec))))
103 ((if (:check-equality vec) check-identity check-execution)
105 (check-signing `(--passphrase-fd "0" --clear-sign ,@(:options vec))
107 (lambda (vec) (counter))