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 "gpgsm-defs.scm"))
21 (setup-gpgsm-environment)
24 ;; Two simple tests to check that verify fails for bad input data
27 "Checking bogus signature."
30 (call-with-binary-output-file
33 (display (make-string 64 (integer->char (string->number char)))
35 (assert (not (zero? (call `(,@gpgsm --verify ,x data-500)))))))
38 (define test-text1 "Hallo Leute!\n")
39 (define test-text1f "Hallo Leute?\n")
41 -----BEGIN CMS OBJECT-----
42 MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAA
43 MYIBOTCCATUCAQEwcDBrMQswCQYDVQQGEwJERTETMBEGA1UEBxQKRPxzc2VsZG9y
44 ZjEWMBQGA1UEChMNZzEwIENvZGUgR21iSDEZMBcGA1UECxMQQWVneXB0ZW4gUHJv
45 amVjdDEUMBIGA1UEAxMLdGVzdCBjZXJ0IDECAQAwBwYFKw4DAhqgJTAjBgkqhkiG
46 9w0BCQQxFgQU7FC/ibH3lC9GE24RJJxa8zqP7wEwCwYJKoZIhvcNAQEBBIGAA3oC
47 DUmKERmD1eoJYFw38y/qnncS/6ZPjWINDIphZeK8mzAANpvpIaRPf3sNBznb89QF
48 mRgCXIWcjlHT0DTRLBf192Ve22IyKH00L52CqFsSN3a2sajqRUlXH8RY2D+Al71e
49 MYdRclgjObCcoilA8fZ13VR4DiMJVFCxJL4qVWI=
50 -----END CMS OBJECT-----")
55 (info "Checking that a valid signature is verified as such.")
57 (with-output-to-file sig (lambda () (display test-sig1)))
58 (with-output-to-file body (lambda () (display test-text1)))
59 (call-check `(,@gpgsm --verify ,sig ,body)))
61 (info "Checking that an invalid signature is verified as such.")
63 (with-output-to-file sig (lambda () (display test-sig1)))
64 (with-output-to-file body (lambda () (display test-text1f)))
65 (assert (not (zero? (call `(,@gpgsm --verify ,sig ,body))))))