tests: Add test suite for gpgsm.

* configure.ac (AC_CONFIG_FILES): Add new file.
* tests/Makefile.am (SUBDIRS): Add new directory.
* tests/gpgsm/32100C27173EF6E9C4E9A25D3D69F86D37A4F939: New file.
* tests/gpgsm/Makefile.am: Likewise.
* tests/gpgsm/cert_dfn_pca01.der: Likewise.
* tests/gpgsm/cert_dfn_pca15.der: Likewise.
* tests/gpgsm/cert_g10code_test1.der: Likewise.
* tests/gpgsm/decrypt.scm: Likewise.
* tests/gpgsm/encrypt.scm: Likewise.
* tests/gpgsm/export.scm: Likewise.
* tests/gpgsm/gpgsm-defs.scm: Likewise.
* tests/gpgsm/import.scm: Likewise.
* tests/gpgsm/plain-1.cms.asc: Likewise.
* tests/gpgsm/plain-2.cms.asc: Likewise.
* tests/gpgsm/plain-3.cms.asc: Likewise.
* tests/gpgsm/plain-large.cms.asc: Likewise.
* tests/gpgsm/run-tests.scm: Likewise.
* tests/gpgsm/setup.scm: Likewise.
* tests/gpgsm/shell.scm: Likewise.
* tests/gpgsm/sign.scm: Likewise.
* tests/gpgsm/verify.scm: Likewise.
--
The certificates and keys are taken from GPGME's test suite.

Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
Justus Winter 2016-12-20 14:05:10 +01:00
parent c067a012c7
commit 36c1413928
21 changed files with 4838 additions and 1 deletions

View File

@ -1894,6 +1894,7 @@ tests/Makefile
tests/gpgscm/Makefile
tests/openpgp/Makefile
tests/migrations/Makefile
tests/gpgsm/Makefile
tests/gpgme/Makefile
tests/pkits/Makefile
g10/gpg.w32-manifest

View File

@ -18,7 +18,7 @@
## Process this file with automake to produce Makefile.in
SUBDIRS = gpgscm openpgp migrations gpgme pkits .
SUBDIRS = gpgscm openpgp migrations gpgsm gpgme pkits .
GPGSM = ../sm/gpgsm

View File

@ -0,0 +1,10 @@
(private-key
(oid.1.2.840.113549.1.1.1
(n #00e0ce96f90b6c9e02f3922beada93fe50a875eac6bcc18bb9a9cf2e84965caa2d1ff95a7f542465c6c0c19d276e4526ce048868a7a914fd343cc3a87dd74291ffc565506d5bbb25cbac6a0e2dd1f8bcaab0d4a29c2f37c950f363484bf269f7891440464baf79827e03a36e70b814938eebdc63e964247be75dc58b014b7ea251#)
(e #010001#)
(d #046129F2489D71579BE0A75FE029BD6CDB574EBF57EA8A5B0FDA942CAB943B117D7BB95E5D28875E0F9FC5FCC06A72F6D502464DABDED78EF6B716177B83D5BDC543DC5D3FED932E59F5897E92E6F58A0F33424106A3B6FA2CBF877510E4AC21C3EE47851E97D12996222AC3566D4CCB0B83D164074ABF7DE655FC2446DA1781#)
(p #00e861b700e17e8afe6837e7512e35b6ca11d0ae47d8b85161c67baf64377213fe52d772f2035b3ca830af41d8a4120e1c1c70d12cc22f00d28d31dd48a8d424f1#)
(q #00f7a7ca5367c661f8e62df34f0d05c10c88e5492348dd7bddc942c9a8f369f935a07785d2db805215ed786e4285df1658eed3ce84f469b81b50d358407b4ad361#)
(u #304559a9ead56d2309d203811a641bb1a09626bc8eb36fffa23c968ec5bd891eebbafc73ae666e01ba7c8990bae06cc2bbe10b75e69fcacb353a6473079d8e9b#)
)
)

78
tests/gpgsm/Makefile.am Normal file
View File

@ -0,0 +1,78 @@
# Makefile.am - For tests/gpgme
# Copyright (C) 2016 g10 Code GmbH
#
# This file is part of GnuPG.
#
# GnuPG is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# GnuPG is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <https://www.gnu.org/licenses/>.
# Process this file with automake to create Makefile.in
# Programs required before we can run these tests.
required_pgms = ../../g10/gpg$(EXEEXT) ../../agent/gpg-agent$(EXEEXT) \
../../tools/gpg-connect-agent$(EXEEXT) \
../gpgscm/gpgscm$(EXEEXT)
AM_CPPFLAGS = -I$(top_srcdir)/common
include $(top_srcdir)/am/cmacros.am
AM_CFLAGS =
TMP ?= /tmp
TESTS_ENVIRONMENT = LC_ALL=C \
EXEEXT=$(EXEEXT) \
PATH=../gpgscm:$(PATH) \
TMP=$(TMP) \
srcdir=$(abs_srcdir) \
objdir=$(abs_top_builddir) \
GPGSCM_PATH=$(abs_top_srcdir)/tests/gpgscm:$(abs_top_srcdir)/tests/openpgp:$(abs_top_srcdir)/tests/gpgsm
XTESTS = \
import.scm \
encrypt.scm \
verify.scm \
decrypt.scm \
sign.scm \
export.scm
# XXX: Currently, one cannot override automake's 'check' target. As a
# workaround, we avoid defining 'TESTS', thus automake will not emit
# the 'check' target. For extra robustness, we merely define a
# dependency on 'xcheck', so this hack should also work even if
# automake would emit the 'check' target, as adding dependencies to
# targets is okay.
check: xcheck
.PHONY: xcheck
xcheck:
$(TESTS_ENVIRONMENT) $(abs_top_builddir)/tests/gpgscm/gpgscm \
$(abs_srcdir)/run-tests.scm $(TESTFLAGS) $(XTESTS)
KEYS = 32100C27173EF6E9C4E9A25D3D69F86D37A4F939
CERTS = cert_g10code_test1.der \
cert_dfn_pca01.der \
cert_dfn_pca15.der
TEST_FILES = plain-1.cms.asc \
plain-2.cms.asc \
plain-3.cms.asc \
plain-large.cms.asc
EXTRA_DIST = $(XTESTS) $(KEYS) $(CERTS) $(TEST_FILES) \
gpgsm-defs.scm run-tests.scm setup.scm
CLEANFILES = *.log
# We need to depend on a couple of programs so that the tests don't
# start before all programs are built.
all-local: $(required_pgms)

Binary file not shown.

Binary file not shown.

Binary file not shown.

30
tests/gpgsm/decrypt.scm Normal file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env gpgscm
;; Copyright (C) 2016 g10 Code GmbH
;;
;; This file is part of GnuPG.
;;
;; GnuPG is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3 of the License, or
;; (at your option) any later version.
;;
;; GnuPG is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "gpgsm-defs.scm"))
(setup-gpgsm-environment)
(for-each-p
"Checking decryption of supplied files."
(lambda (name)
(tr:do
(tr:open (in-srcdir (string-append name ".cms.asc")))
(tr:gpgsm "" '(--decrypt))
(tr:assert-identity name)))
plain-files)

39
tests/gpgsm/encrypt.scm Normal file
View File

@ -0,0 +1,39 @@
#!/usr/bin/env gpgscm
;; Copyright (C) 2016 g10 Code GmbH
;;
;; This file is part of GnuPG.
;;
;; GnuPG is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3 of the License, or
;; (at your option) any later version.
;;
;; GnuPG is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "gpgsm-defs.scm"))
(setup-gpgsm-environment)
(for-each-p
"Checking encryption"
(lambda (source)
(for-each-p
"with arguments..."
(lambda (args)
(tr:do
(tr:open source)
(tr:gpgsm "" `(--encrypt --recipient ,certs::test-1::uid::CN
,@args))
(tr:gpgsm "" `(--decrypt ,@(if (member '--base64 args)
'(--assume-base64) '())))
(tr:assert-identity source)))
`(()
(--armor --cipher-algo ,(cadr (force all-cipher-algos)))
(--base64 --digest-algo ,(car (force all-hash-algos))))))
all-files)

32
tests/gpgsm/export.scm Normal file
View File

@ -0,0 +1,32 @@
#!/usr/bin/env gpgscm
;; Copyright (C) 2016 g10 Code GmbH
;;
;; This file is part of GnuPG.
;;
;; GnuPG is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3 of the License, or
;; (at your option) any later version.
;;
;; GnuPG is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "gpgsm-defs.scm"))
(setup-gpgsm-environment)
(for-each-p'
"Checking certificate export."
(lambda (cert)
(lettmp (exported)
(call-check `(,@gpgsm --output ,exported --export ,cert::uid::CN))
(with-ephemeral-home-directory
(call-check `(,@gpgsm --import ,exported))
(assert (sm-have-public-key? cert)))))
(lambda (cert) cert::uid::CN)
all-certs)

103
tests/gpgsm/gpgsm-defs.scm Normal file
View File

@ -0,0 +1,103 @@
;; Common definitions for the GPGSM test scripts.
;;
;; Copyright (C) 2016 g10 Code GmbH
;;
;; This file is part of GnuPG.
;;
;; GnuPG is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3 of the License, or
;; (at your option) any later version.
;;
;; GnuPG is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "defs.scm"))
;; This is the list of certificates that we install in the test
;; environment.
(define certs
(package
(define (new fpr issuer-fpr uid)
(package))
(define (new-uid CN OU O L C)
(package))
(define test-1 (new "3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E"
"3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E"
(new-uid "test cert 1"
"Aegypten Project"
"g10 Code GmbH"
"Düsseldorf"
"DE")))))
(define all-certs (list certs::test-1))
(define gpgsm `(,(tool 'gpgsm) --yes)) ;; more/less options
(define (tr:gpgsm input args)
(tr:spawn input `(,@gpgsm --output **out** ,@args **in**)))
(define (pipe:gpgsm args)
(pipe:spawn `(,@gpgsm --output - ,@args -)))
(define (gpgsm-with-colons args)
(let ((s (call-popen `(,@gpgsm --with-colons ,@args) "")))
(map (lambda (line) (string-split line #\:))
(string-split-newlines s))))
(define (sm-have-public-key? key)
(catch #f
(pair? (filter (lambda (l) (and (equal? 'fpr (:type l))
(equal? key::fpr (:fpr l))))
(gpgsm-with-colons `(--list-keys ,key::fpr))))))
(define (sm-have-secret-key? key)
(catch #f
(pair? (filter (lambda (l) (and (equal? 'fpr (:type l))
(equal? key::fpr (:fpr l))))
(gpgsm-with-colons `(--list-secret-keys ,key::fpr))))))
(define (create-file name . lines)
(letfd ((fd (open name (logior O_WRONLY O_CREAT O_BINARY) #o600)))
(let ((port (fdopen fd "wb")))
(for-each (lambda (line) (display line port) (newline port))
lines))))
(define (create-gpgsmhome)
(create-file "gpgsm.conf"
"disable-crl-checks"
"faked-system-time 1008241200")
(create-file "gpg-agent.conf"
(string-append "pinentry-program " (tool 'pinentry)))
(create-file
"trustlist.txt"
"32100C27173EF6E9C4E9A25D3D69F86D37A4F939"
"# CN=test cert 1,OU=Aegypten Project,O=g10 Code GmbH,L=Düsseldorf,C=DE"
"3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E S")
(log "Storing private keys")
(mkdir "private-keys-v1.d" "-rwx")
(for-each
(lambda (name)
(file-copy (in-srcdir name)
(path-join "private-keys-v1.d"
(string-append name ".key"))))
'("32100C27173EF6E9C4E9A25D3D69F86D37A4F939"))
(log "Importing public demo and test keys")
(call-check `(,@gpgsm --import ,(in-srcdir "cert_g10code_test1.der")))
(create-sample-files)
(stop-agent))
;; Initialize the test environment, install appropriate configuration
;; and start the agent, with the keys from the legacy test suite.
(define (setup-gpgsm-environment)
(if (member "--unpack-tarball" *args*)
(call-check `(,(tool 'gpgtar) --extract --directory=. ,(cadr *args*)))
(create-gpgsm-gpghome))
(start-agent))

53
tests/gpgsm/import.scm Normal file
View File

@ -0,0 +1,53 @@
#!/usr/bin/env gpgscm
;; Copyright (C) 2016 g10 Code GmbH
;;
;; This file is part of GnuPG.
;;
;; GnuPG is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3 of the License, or
;; (at your option) any later version.
;;
;; GnuPG is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "gpgsm-defs.scm"))
(setup-gpgsm-environment)
(define certs-for-import
(list (list "cert_dfn_pca01.der"
(certs::new
"DFA56FB5FC41E3A8921F77AD1622EEFD9152A5AD"
"DFA56FB5FC41E3A8921F77AD1622EEFD9152A5AD"
(certs::new-uid "DFN Top Level Certification Authority"
"DFN-PCA"
"Deutsches Forschungsnetz"
""
"DE")))
(list "cert_dfn_pca15.der"
(certs::new
"2C8F3C356AB761CB3674835B792CDA52937F9285"
"DFA56FB5FC41E3A8921F77AD1622EEFD9152A5AD"
(certs::new-uid "DFN Server Certification Authority"
"DFN-PCA"
"Deutsches Forschungsnetz"
""
"DE")))))
(define :name car)
(define :cert cadr)
(for-each-p'
"Checking certificate import."
(lambda (test)
(assert (not (sm-have-public-key? (:cert test))))
(call-check `(,@gpgsm --import ,(in-srcdir (:name test))))
(assert (sm-have-public-key? (:cert test))))
(lambda (test) (:name test))
certs-for-import)

View File

@ -0,0 +1,33 @@
-----BEGIN ENCRYPTED MESSAGE-----
MIAGCSqGSIb3DQEHA6CAMIACAQAxggELMIIBBwIBADBwMGsxCzAJBgNVBAYTAkRF
MRMwEQYDVQQHFApE/HNzZWxkb3JmMRYwFAYDVQQKEw1nMTAgQ29kZSBHbWJIMRkw
FwYDVQQLExBBZWd5cHRlbiBQcm9qZWN0MRQwEgYDVQQDEwt0ZXN0IGNlcnQgMQIB
ADANBgkqhkiG9w0BAQEFAASBgL5yhIZiK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5ardDNYBEnUvzmTahzu6JTZILlMGIwY/HgXeovBO8rKMxjLCZuHYWH1
uVi5IcJeK5jqkwUdAi5E/WUNisgJBBBXo2FMcmlPIZJw3pGkJGQXAAAAAAAAAAAA
AA==
-----END ENCRYPTED MESSAGE-----

View File

@ -0,0 +1,11 @@
-----BEGIN ENCRYPTED MESSAGE-----
MIAGCSqGSIb3DQEHA6CAMIACAQAxggELMIIBBwIBADBwMGsxCzAJBgNVBAYTAkRF
MRMwEQYDVQQHFApE/HNzZWxkb3JmMRYwFAYDVQQKEw1nMTAgQ29kZSBHbWJIMRkw
FwYDVQQLExBBZWd5cHRlbiBQcm9qZWN0MRQwEgYDVQQDEwt0ZXN0IGNlcnQgMQIB
ADANBgkqhkiG9w0BAQEFAASBgB8adQNvg/lKghatZ/Wy+tMUrarqYmTHB3SDKoDh
B+riZDDxj/j/xR6utjmukvrAz6gz3BzKxU+AjAmXLpNesN1kv+oDS2DmAluFzg5e
j/Ppo+Dudq2uJjZOsMry6xniMIwOhHsLhkLs2cuEb0eB6XAVfMzJvdTawuLaMeLN
fGmVMIAGCSqGSIb3DQEHATAdBglghkgBZQMEAQIEECIzN1lVNsKXkPAEySzCpUWg
gAQgzfoRhxREyicy4Vf6dfDJ+X4kaB4tGwsKGKYVV1uITjEEEFpk2DxEsIIxH66o
pfqG9W4AAAAAAAAAAAAA
-----END ENCRYPTED MESSAGE-----

File diff suppressed because it is too large Load Diff

32
tests/gpgsm/run-tests.scm Normal file
View File

@ -0,0 +1,32 @@
;; Test-suite runner.
;;
;; Copyright (C) 2016 g10 Code GmbH
;;
;; This file is part of GnuPG.
;;
;; GnuPG is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3 of the License, or
;; (at your option) any later version.
;;
;; GnuPG is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(if (string=? "" (getenv "srcdir"))
(begin
(echo "Environment variable 'srcdir' not set. Please point it to"
"tests/openpgp.")
(exit 2)))
(let* ((tests (filter (lambda (arg) (not (string-prefix? arg "--"))) *args*))
(runner (if (and (member "--parallel" *args*)
(> (length tests) 1))
run-tests-parallel
run-tests-sequential)))
(runner (test::scm "setup.scm" "setup.scm")
(map (lambda (t) (test::scm t t)) tests)))

29
tests/gpgsm/setup.scm Normal file
View File

@ -0,0 +1,29 @@
#!/usr/bin/env gpgscm
;; Copyright (C) 2016 g10 Code GmbH
;;
;; This file is part of GnuPG.
;;
;; GnuPG is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3 of the License, or
;; (at your option) any later version.
;;
;; GnuPG is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "gpgsm-defs.scm"))
(define tarball (flag "--create-tarball" *args*))
(unless (and tarball (not (null? tarball)))
(error "Usage: setup.scm --create-tarball <file> ..."))
(with-ephemeral-home-directory
(create-gpgsmhome)
(stop-agent)
(call-check `(,(tool 'gpgtar) --create --output ,(car tarball) ".")))

30
tests/gpgsm/shell.scm Normal file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env gpgscm
;; Copyright (C) 2016 g10 Code GmbH
;;
;; This file is part of GnuPG.
;;
;; GnuPG is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3 of the License, or
;; (at your option) any later version.
;;
;; GnuPG is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "gpgsm-defs.scm"))
(setup-gpgsm-environment)
;; This is not a test, but can be used to inspect the test
;; environment. Simply execute
;;
;; make -Ctests/gpgsm check XTESTS=shell.scm
;;
;; to run it.
(interactive-shell)

35
tests/gpgsm/sign.scm Normal file
View File

@ -0,0 +1,35 @@
#!/usr/bin/env gpgscm
;; Copyright (C) 2016 g10 Code GmbH
;;
;; This file is part of GnuPG.
;;
;; GnuPG is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3 of the License, or
;; (at your option) any later version.
;;
;; GnuPG is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "gpgsm-defs.scm"))
(setup-gpgsm-environment)
(for-each-p
"Checking signing."
(lambda (source)
(for-each-p
"with digest..."
(lambda (digest)
(tr:do
(tr:open source)
(tr:gpgsm "" `(--sign --digest-algo ,digest))
(tr:gpgsm "" '(--verify))
(tr:assert-identity source)))
(force all-hash-algos)))
all-files)

65
tests/gpgsm/verify.scm Normal file
View File

@ -0,0 +1,65 @@
#!/usr/bin/env gpgscm
;; Copyright (C) 2016 g10 Code GmbH
;;
;; This file is part of GnuPG.
;;
;; GnuPG is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3 of the License, or
;; (at your option) any later version.
;;
;; GnuPG is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, see <http://www.gnu.org/licenses/>.
(load (with-path "gpgsm-defs.scm"))
(setup-gpgsm-environment)
;;
;; Two simple tests to check that verify fails for bad input data
;;
(for-each-p
"Checking bogus signature."
(lambda (char)
(lettmp (x)
(call-with-binary-output-file
x
(lambda (port)
(display (make-string 64 (integer->char (string->number char)))
port)))
(assert (not (zero? (call `(,@gpgsm --verify ,x data-500)))))))
'("#x2d" "#xca"))
(define test-text1 "Hallo Leute!\n")
(define test-text1f "Hallo Leute?\n")
(define test-sig1 "
-----BEGIN CMS OBJECT-----
MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAA
MYIBOTCCATUCAQEwcDBrMQswCQYDVQQGEwJERTETMBEGA1UEBxQKRPxzc2VsZG9y
ZjEWMBQGA1UEChMNZzEwIENvZGUgR21iSDEZMBcGA1UECxMQQWVneXB0ZW4gUHJv
amVjdDEUMBIGA1UEAxMLdGVzdCBjZXJ0IDECAQAwBwYFKw4DAhqgJTAjBgkqhkiG
9w0BCQQxFgQU7FC/ibH3lC9GE24RJJxa8zqP7wEwCwYJKoZIhvcNAQEBBIGAA3oC
DUmKERmD1eoJYFw38y/qnncS/6ZPjWINDIphZeK8mzAANpvpIaRPf3sNBznb89QF
mRgCXIWcjlHT0DTRLBf192Ve22IyKH00L52CqFsSN3a2sajqRUlXH8RY2D+Al71e
MYdRclgjObCcoilA8fZ13VR4DiMJVFCxJL4qVWI=
-----END CMS OBJECT-----")
;;
;; Now run the tests.
;;
(info "Checking that a valid signature is verified as such.")
(lettmp (sig body)
(with-output-to-file sig (lambda () (display test-sig1)))
(with-output-to-file body (lambda () (display test-text1)))
(call-check `(,@gpgsm --verify ,sig ,body)))
(info "Checking that an invalid signature is verified as such.")
(lettmp (sig body)
(with-output-to-file sig (lambda () (display test-sig1)))
(with-output-to-file body (lambda () (display test-text1f)))
(assert (not (zero? (call `(,@gpgsm --verify ,sig ,body))))))