summaryrefslogtreecommitdiff
path: root/tests/gpgsm
diff options
context:
space:
mode:
Diffstat (limited to 'tests/gpgsm')
-rw-r--r--tests/gpgsm/32100C27173EF6E9C4E9A25D3D69F86D37A4F93918
-rw-r--r--tests/gpgsm/Makefile.am72
-rw-r--r--tests/gpgsm/Makefile.in756
-rw-r--r--tests/gpgsm/cert_dfn_pca01.derbin0 -> 1224 bytes
-rw-r--r--tests/gpgsm/cert_dfn_pca15.derbin0 -> 1560 bytes
-rw-r--r--tests/gpgsm/cert_g10code_test1.derbin0 -> 793 bytes
-rw-r--r--tests/gpgsm/cms-decrypt.c108
-rw-r--r--tests/gpgsm/cms-keylist.c125
-rw-r--r--tests/gpgsm/t-decrypt.c86
-rw-r--r--tests/gpgsm/t-encrypt.c78
-rw-r--r--tests/gpgsm/t-export.c86
-rw-r--r--tests/gpgsm/t-genkey.c128
-rw-r--r--tests/gpgsm/t-import.c175
-rw-r--r--tests/gpgsm/t-keylist.c389
-rw-r--r--tests/gpgsm/t-sign.c127
-rw-r--r--tests/gpgsm/t-support.h114
-rw-r--r--tests/gpgsm/t-verify.c182
17 files changed, 2444 insertions, 0 deletions
diff --git a/tests/gpgsm/32100C27173EF6E9C4E9A25D3D69F86D37A4F939 b/tests/gpgsm/32100C27173EF6E9C4E9A25D3D69F86D37A4F939
new file mode 100644
index 0000000..cf0535f
--- /dev/null
+++ b/tests/gpgsm/32100C27173EF6E9C4E9A25D3D69F86D37A4F939
@@ -0,0 +1,18 @@
+(private-key
+ (oid.1.2.840.113549.1.1.1
+ (n #00e0ce96f90b6c9e02f3922beada93fe50a875eac6bcc18bb9a9cf2e84965caa2d1ff95a7f542465c6c0c19d276e4526ce048868a7a914fd343cc3a87dd74291ffc565506d5bbb25cbac6a0e2dd1f8bcaab0d4a29c2f37c950f363484bf269f7891440464baf79827e03a36e70b814938eebdc63e964247be75dc58b014b7ea251#)
+ (e #010001#)
+ (d #046129F2489D71579BE0A75FE029BD6CDB574EBF57EA8A5B0FDA942CAB943B117D7BB95E5D28875E0F9FC5FCC06A72F6D502464DABDED78EF6B716177B83D5BDC543DC5D3FED932E59F5897E92E6F58A0F33424106A3B6FA2CBF877510E4AC21C3EE47851E97D12996222AC3566D4CCB0B83D164074ABF7DE655FC2446DA1781#)
+ (p #00e861b700e17e8afe6837e7512e35b6ca11d0ae47d8b85161c67baf64377213fe52d772f2035b3ca830af41d8a4120e1c1c70d12cc22f00d28d31dd48a8d424f1#)
+ (q #00f7a7ca5367c661f8e62df34f0d05c10c88e5492348dd7bddc942c9a8f369f935a07785d2db805215ed786e4285df1658eed3ce84f469b81b50d358407b4ad361#)
+ (u #304559a9ead56d2309d203811a641bb1a09626bc8eb36fffa23c968ec5bd891eebbafc73ae666e01ba7c8990bae06cc2bbe10b75e69fcacb353a6473079d8e9b#)
+ )
+)
+
+
+
+
+
+
+
+
diff --git a/tests/gpgsm/Makefile.am b/tests/gpgsm/Makefile.am
new file mode 100644
index 0000000..9086134
--- /dev/null
+++ b/tests/gpgsm/Makefile.am
@@ -0,0 +1,72 @@
+# Copyright (C) 2000 Werner Koch (dd9jn)
+# Copyright (C) 2001 g10 Code GmbH
+#
+# This file is part of GPGME.
+#
+# GPGME is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of the
+# License, or (at your option) any later version.
+#
+# GPGME 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 Lesser General
+# Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+
+## Process this file with automake to produce Makefile.in
+
+GPGSM = @GPGSM@
+
+TESTS_ENVIRONMENT = GNUPGHOME=$(abs_builddir) GPG_AGENT_INFO=
+
+noinst_HEADERS = t-support.h
+TESTS = t-import t-keylist t-encrypt t-verify t-decrypt t-sign t-export
+
+EXTRA_DIST = cert_dfn_pca01.der cert_dfn_pca15.der cert_g10code_test1.der \
+ $(key_id)
+
+INCLUDES = -I$(top_builddir)/src
+
+AM_CPPFLAGS = @GPG_ERROR_CFLAGS@
+LDADD = ../../src/libgpgme.la
+
+# We don't run t-genkey in the test suite, because it takes too long
+# and needs a working pinentry.
+noinst_PROGRAMS = $(TESTS) t-genkey cms-keylist cms-decrypt
+
+key_id = 32100C27173EF6E9C4E9A25D3D69F86D37A4F939
+
+CLEANFILES = pubring.kbx pubring.kbx~ gpgsm.conf trustlist.txt \
+ random_seed S.gpg-agent
+
+clean-local:
+ -gpg-connect-agent KILLAGENT /bye
+ -rm -fR private-keys-v1.d
+
+all-local: ./pubring.kbx ./gpgsm.conf ./private-keys-v1.d/$(key_id).key ./trustlist.txt
+
+export GNUPGHOME := $(abs_builddir)
+
+export GPG_AGENT_INFO :=
+
+./pubring.kbx: $(srcdir)/cert_g10code_test1.der
+ $(GPGSM) --import $(srcdir)/cert_g10code_test1.der
+
+./gpgsm.conf:
+ echo disable-crl-checks > ./gpgsm.conf
+ echo faked-system-time 1008241200 >> ./gpgsm.conf
+
+./private-keys-v1.d/$(key_id).key: $(srcdir)/$(key_id)
+ test -d ./private-keys-v1.d || mkdir ./private-keys-v1.d
+ cp $(srcdir)/$(key_id) private-keys-v1.d/$(key_id).key
+
+./trustlist.txt:
+ echo $(key_id) > ./trustlist.txt
+ echo >> ./trustlist.txt
+ echo "# CN=test cert 1,OU=Aegypten Project,O=g10 Code GmbH,L=Düsseldorf,C=DE" >> ./trustlist.txt
+ echo "3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E S" >> ./trustlist.txt
+
diff --git a/tests/gpgsm/Makefile.in b/tests/gpgsm/Makefile.in
new file mode 100644
index 0000000..8c9ba31
--- /dev/null
+++ b/tests/gpgsm/Makefile.in
@@ -0,0 +1,756 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Copyright (C) 2000 Werner Koch (dd9jn)
+# Copyright (C) 2001 g10 Code GmbH
+#
+# This file is part of GPGME.
+#
+# GPGME is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of the
+# License, or (at your option) any later version.
+#
+# GPGME 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 Lesser General
+# Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+TESTS = t-import$(EXEEXT) t-keylist$(EXEEXT) t-encrypt$(EXEEXT) \
+ t-verify$(EXEEXT) t-decrypt$(EXEEXT) t-sign$(EXEEXT) \
+ t-export$(EXEEXT)
+noinst_PROGRAMS = $(am__EXEEXT_1) t-genkey$(EXEEXT) \
+ cms-keylist$(EXEEXT) cms-decrypt$(EXEEXT)
+subdir = tests/gpgsm
+DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/glib-2.0.m4 \
+ $(top_srcdir)/m4/glibc21.m4 $(top_srcdir)/m4/gnupg-ttyname.m4 \
+ $(top_srcdir)/m4/gpg-error.m4 $(top_srcdir)/m4/libassuan.m4 \
+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__EXEEXT_1 = t-import$(EXEEXT) t-keylist$(EXEEXT) t-encrypt$(EXEEXT) \
+ t-verify$(EXEEXT) t-decrypt$(EXEEXT) t-sign$(EXEEXT) \
+ t-export$(EXEEXT)
+PROGRAMS = $(noinst_PROGRAMS)
+cms_decrypt_SOURCES = cms-decrypt.c
+cms_decrypt_OBJECTS = cms-decrypt.$(OBJEXT)
+cms_decrypt_LDADD = $(LDADD)
+cms_decrypt_DEPENDENCIES = ../../src/libgpgme.la
+cms_keylist_SOURCES = cms-keylist.c
+cms_keylist_OBJECTS = cms-keylist.$(OBJEXT)
+cms_keylist_LDADD = $(LDADD)
+cms_keylist_DEPENDENCIES = ../../src/libgpgme.la
+t_decrypt_SOURCES = t-decrypt.c
+t_decrypt_OBJECTS = t-decrypt.$(OBJEXT)
+t_decrypt_LDADD = $(LDADD)
+t_decrypt_DEPENDENCIES = ../../src/libgpgme.la
+t_encrypt_SOURCES = t-encrypt.c
+t_encrypt_OBJECTS = t-encrypt.$(OBJEXT)
+t_encrypt_LDADD = $(LDADD)
+t_encrypt_DEPENDENCIES = ../../src/libgpgme.la
+t_export_SOURCES = t-export.c
+t_export_OBJECTS = t-export.$(OBJEXT)
+t_export_LDADD = $(LDADD)
+t_export_DEPENDENCIES = ../../src/libgpgme.la
+t_genkey_SOURCES = t-genkey.c
+t_genkey_OBJECTS = t-genkey.$(OBJEXT)
+t_genkey_LDADD = $(LDADD)
+t_genkey_DEPENDENCIES = ../../src/libgpgme.la
+t_import_SOURCES = t-import.c
+t_import_OBJECTS = t-import.$(OBJEXT)
+t_import_LDADD = $(LDADD)
+t_import_DEPENDENCIES = ../../src/libgpgme.la
+t_keylist_SOURCES = t-keylist.c
+t_keylist_OBJECTS = t-keylist.$(OBJEXT)
+t_keylist_LDADD = $(LDADD)
+t_keylist_DEPENDENCIES = ../../src/libgpgme.la
+t_sign_SOURCES = t-sign.c
+t_sign_OBJECTS = t-sign.$(OBJEXT)
+t_sign_LDADD = $(LDADD)
+t_sign_DEPENDENCIES = ../../src/libgpgme.la
+t_verify_SOURCES = t-verify.c
+t_verify_OBJECTS = t-verify.$(OBJEXT)
+t_verify_LDADD = $(LDADD)
+t_verify_DEPENDENCIES = ../../src/libgpgme.la
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = cms-decrypt.c cms-keylist.c t-decrypt.c t-encrypt.c \
+ t-export.c t-genkey.c t-import.c t-keylist.c t-sign.c \
+ t-verify.c
+DIST_SOURCES = cms-decrypt.c cms-keylist.c t-decrypt.c t-encrypt.c \
+ t-export.c t-genkey.c t-import.c t-keylist.c t-sign.c \
+ t-verify.c
+HEADERS = $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BUILD_FILEVERSION = @BUILD_FILEVERSION@
+BUILD_NUMBER = @BUILD_NUMBER@
+BUILD_TIMESTAMP = @BUILD_TIMESTAMP@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+G13 = @G13@
+GITLOG_TO_CHANGELOG = @GITLOG_TO_CHANGELOG@
+GLIBC21 = @GLIBC21@
+GLIB_CFLAGS = @GLIB_CFLAGS@
+GLIB_GENMARSHAL = @GLIB_GENMARSHAL@
+GLIB_LIBS = @GLIB_LIBS@
+GLIB_MKENUMS = @GLIB_MKENUMS@
+GOBJECT_QUERY = @GOBJECT_QUERY@
+GPG = @GPG@
+GPGCONF = @GPGCONF@
+GPGME_CONFIG_API_VERSION = @GPGME_CONFIG_API_VERSION@
+GPGME_CONFIG_CFLAGS = @GPGME_CONFIG_CFLAGS@
+GPGME_CONFIG_HOST = @GPGME_CONFIG_HOST@
+GPGME_CONFIG_LIBS = @GPGME_CONFIG_LIBS@
+GPGSM = @GPGSM@
+GPG_ERROR_CFLAGS = @GPG_ERROR_CFLAGS@
+GPG_ERROR_CONFIG = @GPG_ERROR_CONFIG@
+GPG_ERROR_LIBS = @GPG_ERROR_LIBS@
+GPG_PATH = @GPG_PATH@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBASSUAN_CFLAGS = @LIBASSUAN_CFLAGS@
+LIBASSUAN_CONFIG = @LIBASSUAN_CONFIG@
+LIBASSUAN_LIBS = @LIBASSUAN_LIBS@
+LIBGPGME_LT_AGE = @LIBGPGME_LT_AGE@
+LIBGPGME_LT_CURRENT = @LIBGPGME_LT_CURRENT@
+LIBGPGME_LT_REVISION = @LIBGPGME_LT_REVISION@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+NEED__FILE_OFFSET_BITS = @NEED__FILE_OFFSET_BITS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+QT4_CORE_CFLAGS = @QT4_CORE_CFLAGS@
+QT4_CORE_LIBS = @QT4_CORE_LIBS@
+RANLIB = @RANLIB@
+RC = @RC@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+emacs_local_vars_begin = @emacs_local_vars_begin@
+emacs_local_vars_end = @emacs_local_vars_end@
+emacs_local_vars_read_only = @emacs_local_vars_read_only@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+TESTS_ENVIRONMENT = GNUPGHOME=$(abs_builddir) GPG_AGENT_INFO=
+noinst_HEADERS = t-support.h
+EXTRA_DIST = cert_dfn_pca01.der cert_dfn_pca15.der cert_g10code_test1.der \
+ $(key_id)
+
+INCLUDES = -I$(top_builddir)/src
+AM_CPPFLAGS = @GPG_ERROR_CFLAGS@
+LDADD = ../../src/libgpgme.la
+key_id = 32100C27173EF6E9C4E9A25D3D69F86D37A4F939
+CLEANFILES = pubring.kbx pubring.kbx~ gpgsm.conf trustlist.txt \
+ random_seed S.gpg-agent
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/gpgsm/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu tests/gpgsm/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstPROGRAMS:
+ @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
+cms-decrypt$(EXEEXT): $(cms_decrypt_OBJECTS) $(cms_decrypt_DEPENDENCIES)
+ @rm -f cms-decrypt$(EXEEXT)
+ $(LINK) $(cms_decrypt_OBJECTS) $(cms_decrypt_LDADD) $(LIBS)
+cms-keylist$(EXEEXT): $(cms_keylist_OBJECTS) $(cms_keylist_DEPENDENCIES)
+ @rm -f cms-keylist$(EXEEXT)
+ $(LINK) $(cms_keylist_OBJECTS) $(cms_keylist_LDADD) $(LIBS)
+t-decrypt$(EXEEXT): $(t_decrypt_OBJECTS) $(t_decrypt_DEPENDENCIES)
+ @rm -f t-decrypt$(EXEEXT)
+ $(LINK) $(t_decrypt_OBJECTS) $(t_decrypt_LDADD) $(LIBS)
+t-encrypt$(EXEEXT): $(t_encrypt_OBJECTS) $(t_encrypt_DEPENDENCIES)
+ @rm -f t-encrypt$(EXEEXT)
+ $(LINK) $(t_encrypt_OBJECTS) $(t_encrypt_LDADD) $(LIBS)
+t-export$(EXEEXT): $(t_export_OBJECTS) $(t_export_DEPENDENCIES)
+ @rm -f t-export$(EXEEXT)
+ $(LINK) $(t_export_OBJECTS) $(t_export_LDADD) $(LIBS)
+t-genkey$(EXEEXT): $(t_genkey_OBJECTS) $(t_genkey_DEPENDENCIES)
+ @rm -f t-genkey$(EXEEXT)
+ $(LINK) $(t_genkey_OBJECTS) $(t_genkey_LDADD) $(LIBS)
+t-import$(EXEEXT): $(t_import_OBJECTS) $(t_import_DEPENDENCIES)
+ @rm -f t-import$(EXEEXT)
+ $(LINK) $(t_import_OBJECTS) $(t_import_LDADD) $(LIBS)
+t-keylist$(EXEEXT): $(t_keylist_OBJECTS) $(t_keylist_DEPENDENCIES)
+ @rm -f t-keylist$(EXEEXT)
+ $(LINK) $(t_keylist_OBJECTS) $(t_keylist_LDADD) $(LIBS)
+t-sign$(EXEEXT): $(t_sign_OBJECTS) $(t_sign_DEPENDENCIES)
+ @rm -f t-sign$(EXEEXT)
+ $(LINK) $(t_sign_OBJECTS) $(t_sign_LDADD) $(LIBS)
+t-verify$(EXEEXT): $(t_verify_OBJECTS) $(t_verify_DEPENDENCIES)
+ @rm -f t-verify$(EXEEXT)
+ $(LINK) $(t_verify_OBJECTS) $(t_verify_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cms-decrypt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cms-keylist.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-decrypt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-encrypt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-export.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-genkey.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-import.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-keylist.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-sign.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t-verify.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+check-TESTS: $(TESTS)
+ @failed=0; all=0; xfail=0; xpass=0; skip=0; \
+ srcdir=$(srcdir); export srcdir; \
+ list=' $(TESTS) '; \
+ $(am__tty_colors); \
+ if test -n "$$list"; then \
+ for tst in $$list; do \
+ if test -f ./$$tst; then dir=./; \
+ elif test -f $$tst; then dir=; \
+ else dir="$(srcdir)/"; fi; \
+ if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xpass=`expr $$xpass + 1`; \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=XPASS; \
+ ;; \
+ *) \
+ col=$$grn; res=PASS; \
+ ;; \
+ esac; \
+ elif test $$? -ne 77; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xfail=`expr $$xfail + 1`; \
+ col=$$lgn; res=XFAIL; \
+ ;; \
+ *) \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=FAIL; \
+ ;; \
+ esac; \
+ else \
+ skip=`expr $$skip + 1`; \
+ col=$$blu; res=SKIP; \
+ fi; \
+ echo "$${col}$$res$${std}: $$tst"; \
+ done; \
+ if test "$$all" -eq 1; then \
+ tests="test"; \
+ All=""; \
+ else \
+ tests="tests"; \
+ All="All "; \
+ fi; \
+ if test "$$failed" -eq 0; then \
+ if test "$$xfail" -eq 0; then \
+ banner="$$All$$all $$tests passed"; \
+ else \
+ if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
+ banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
+ fi; \
+ else \
+ if test "$$xpass" -eq 0; then \
+ banner="$$failed of $$all $$tests failed"; \
+ else \
+ if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
+ banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
+ fi; \
+ fi; \
+ dashes="$$banner"; \
+ skipped=""; \
+ if test "$$skip" -ne 0; then \
+ if test "$$skip" -eq 1; then \
+ skipped="($$skip test was not run)"; \
+ else \
+ skipped="($$skip tests were not run)"; \
+ fi; \
+ test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$skipped"; \
+ fi; \
+ report=""; \
+ if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
+ report="Please report to $(PACKAGE_BUGREPORT)"; \
+ test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$report"; \
+ fi; \
+ dashes=`echo "$$dashes" | sed s/./=/g`; \
+ if test "$$failed" -eq 0; then \
+ echo "$$grn$$dashes"; \
+ else \
+ echo "$$red$$dashes"; \
+ fi; \
+ echo "$$banner"; \
+ test -z "$$skipped" || echo "$$skipped"; \
+ test -z "$$report" || echo "$$report"; \
+ echo "$$dashes$$std"; \
+ test "$$failed" -eq 0; \
+ else :; fi
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) check-TESTS
+check: check-am
+all-am: Makefile $(PROGRAMS) $(HEADERS) all-local
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-local clean-noinstPROGRAMS \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: check-am install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am all-local check check-TESTS check-am \
+ clean clean-generic clean-libtool clean-local \
+ clean-noinstPROGRAMS ctags distclean distclean-compile \
+ distclean-generic distclean-libtool distclean-tags distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am
+
+
+clean-local:
+ -gpg-connect-agent KILLAGENT /bye
+ -rm -fR private-keys-v1.d
+
+all-local: ./pubring.kbx ./gpgsm.conf ./private-keys-v1.d/$(key_id).key ./trustlist.txt
+
+export GNUPGHOME := $(abs_builddir)
+
+export GPG_AGENT_INFO :=
+
+./pubring.kbx: $(srcdir)/cert_g10code_test1.der
+ $(GPGSM) --import $(srcdir)/cert_g10code_test1.der
+
+./gpgsm.conf:
+ echo disable-crl-checks > ./gpgsm.conf
+ echo faked-system-time 1008241200 >> ./gpgsm.conf
+
+./private-keys-v1.d/$(key_id).key: $(srcdir)/$(key_id)
+ test -d ./private-keys-v1.d || mkdir ./private-keys-v1.d
+ cp $(srcdir)/$(key_id) private-keys-v1.d/$(key_id).key
+
+./trustlist.txt:
+ echo $(key_id) > ./trustlist.txt
+ echo >> ./trustlist.txt
+ echo "# CN=test cert 1,OU=Aegypten Project,O=g10 Code GmbH,L=Düsseldorf,C=DE" >> ./trustlist.txt
+ echo "3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E S" >> ./trustlist.txt
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/tests/gpgsm/cert_dfn_pca01.der b/tests/gpgsm/cert_dfn_pca01.der
new file mode 100644
index 0000000..4c8593c
--- /dev/null
+++ b/tests/gpgsm/cert_dfn_pca01.der
Binary files differ
diff --git a/tests/gpgsm/cert_dfn_pca15.der b/tests/gpgsm/cert_dfn_pca15.der
new file mode 100644
index 0000000..c28f137
--- /dev/null
+++ b/tests/gpgsm/cert_dfn_pca15.der
Binary files differ
diff --git a/tests/gpgsm/cert_g10code_test1.der b/tests/gpgsm/cert_g10code_test1.der
new file mode 100644
index 0000000..67c7db6
--- /dev/null
+++ b/tests/gpgsm/cert_g10code_test1.der
Binary files differ
diff --git a/tests/gpgsm/cms-decrypt.c b/tests/gpgsm/cms-decrypt.c
new file mode 100644
index 0000000..580832d
--- /dev/null
+++ b/tests/gpgsm/cms-decrypt.c
@@ -0,0 +1,108 @@
+/* cms-decrypt.c - Helper to debug the decrupt operation.
+ Copyright (C) 2008 g10 Code GmbH
+
+ This file is part of GPGME.
+
+ GPGME is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ GPGME 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+/* We need to include config.h so that we know whether we are building
+ with large file system (LFS) support. */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <gpgme.h>
+
+#define PGM "cms-decrypt"
+
+#include "t-support.h"
+
+static const char *
+nonnull (const char *s)
+{
+ return s? s :"[none]";
+}
+
+
+int
+main (int argc, char **argv)
+{
+ gpgme_error_t err;
+ gpgme_ctx_t ctx;
+ gpgme_data_t in, out;
+ gpgme_decrypt_result_t result;
+ gpgme_recipient_t recp;
+
+ if (argc)
+ { argc--; argv++; }
+
+ if (argc != 1)
+ {
+ fputs ("usage: " PGM " FILE\n", stderr);
+ exit (1);
+ }
+
+ init_gpgme (GPGME_PROTOCOL_CMS);
+
+ err = gpgme_new (&ctx);
+ fail_if_err (err);
+ gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS);
+
+
+ err = gpgme_data_new_from_file (&in, *argv, 1);
+ fail_if_err (err);
+
+ err = gpgme_data_new (&out);
+ fail_if_err (err);
+
+ err = gpgme_op_decrypt (ctx, in, out);
+ printf ("gpgme_op_decrypt: %s <%s> (%u)\n",
+ gpgme_strerror (err), gpgme_strsource (err), err);
+ result = gpgme_op_decrypt_result (ctx);
+ if (!result)
+ {
+ fputs (PGM ": error: decryption result missing\n", stderr);
+ exit (1);
+ }
+
+ printf ("unsupported_algorithm: %s\n",
+ nonnull (result->unsupported_algorithm));
+ printf ("wrong_key_usage: %u\n", result->wrong_key_usage);
+ printf ("file_name: %s\n", nonnull (result->file_name));
+ for (recp = result->recipients; recp; recp = recp->next)
+ {
+ printf ("recipient.status: %s <%s> (%u)\n",
+ gpgme_strerror (recp->status), gpgme_strsource (recp->status),
+ recp->status);
+ printf ("recipient.pkalgo: %d\n", recp->pubkey_algo);
+ printf ("recipient.keyid : %s\n", nonnull (recp->keyid));
+ }
+
+ if (!err)
+ {
+ puts ("plaintext:");
+ print_data (out);
+ gpgme_data_release (out);
+ }
+
+ gpgme_data_release (in);
+
+ gpgme_release (ctx);
+ return 0;
+}
diff --git a/tests/gpgsm/cms-keylist.c b/tests/gpgsm/cms-keylist.c
new file mode 100644
index 0000000..7ed3a4e
--- /dev/null
+++ b/tests/gpgsm/cms-keylist.c
@@ -0,0 +1,125 @@
+/* cms-keylist.c - Helper to show a key listing.
+ Copyright (C) 2008 g10 Code GmbH
+
+ This file is part of GPGME.
+
+ GPGME is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ GPGME 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+/* We need to include config.h so that we know whether we are building
+ with large file system (LFS) support. */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <gpgme.h>
+
+#define PGM "cms-keylist"
+
+#include "t-support.h"
+
+static const char *
+nonnull (const char *s)
+{
+ return s? s :"[none]";
+}
+
+
+int
+main (int argc, char **argv)
+{
+ gpgme_error_t err;
+ gpgme_ctx_t ctx;
+ gpgme_key_t key;
+ gpgme_keylist_result_t result;
+
+ if (argc)
+ { argc--; argv++; }
+
+ if (argc > 1)
+ {
+ fputs ("usage: " PGM " [USERID]\n", stderr);
+ exit (1);
+ }
+
+ init_gpgme (GPGME_PROTOCOL_CMS);
+
+ err = gpgme_new (&ctx);
+ fail_if_err (err);
+ gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS);
+
+ gpgme_set_keylist_mode (ctx, (gpgme_get_keylist_mode (ctx)
+ | GPGME_KEYLIST_MODE_VALIDATE));
+
+ err = gpgme_op_keylist_start (ctx, argc? argv[0]:NULL, 0);
+ fail_if_err (err);
+
+ while (!(err = gpgme_op_keylist_next (ctx, &key)))
+ {
+ gpgme_user_id_t uid;
+ int nuids;
+
+ for (nuids=0, uid=key->uids; uid; uid = uid->next)
+ nuids++;
+
+ printf ("serial : %s\n", nonnull (key->issuer_serial));
+ printf ("issuer : %s\n", nonnull (key->issuer_name));
+ printf ("chain-id: %s\n", nonnull (key->chain_id));
+ printf ("caps : %s%s%s%s\n",
+ key->can_encrypt? "e":"",
+ key->can_sign? "s":"",
+ key->can_certify? "c":"",
+ key->can_authenticate? "a":"");
+ printf ("flags :%s%s%s%s%s%s\n",
+ key->secret? " secret":"",
+ key->revoked? " revoked":"",
+ key->expired? " expired":"",
+ key->disabled? " disabled":"",
+ key->invalid? " invalid":"",
+ key->is_qualified? " qualifid":"");
+ for (nuids=0, uid=key->uids; uid; uid = uid->next, nuids++)
+ {
+ printf ("userid %d: %s\n", nuids, nonnull(uid->uid));
+ printf ("valid %d: %s\n", nuids,
+ uid->validity == GPGME_VALIDITY_UNKNOWN? "unknown":
+ uid->validity == GPGME_VALIDITY_UNDEFINED? "undefined":
+ uid->validity == GPGME_VALIDITY_NEVER? "never":
+ uid->validity == GPGME_VALIDITY_MARGINAL? "marginal":
+ uid->validity == GPGME_VALIDITY_FULL? "full":
+ uid->validity == GPGME_VALIDITY_ULTIMATE? "ultimate": "[?]");
+ }
+
+ putchar ('\n');
+
+ gpgme_key_unref (key);
+ }
+ if (gpgme_err_code (err) != GPG_ERR_EOF)
+ fail_if_err (err);
+ err = gpgme_op_keylist_end (ctx);
+ fail_if_err (err);
+
+ result = gpgme_op_keylist_result (ctx);
+ if (result->truncated)
+ {
+ fprintf (stderr, PGM ": key listing unexpectedly truncated\n");
+ exit (1);
+ }
+
+ gpgme_release (ctx);
+ return 0;
+}
diff --git a/tests/gpgsm/t-decrypt.c b/tests/gpgsm/t-decrypt.c
new file mode 100644
index 0000000..654c7e1
--- /dev/null
+++ b/tests/gpgsm/t-decrypt.c
@@ -0,0 +1,86 @@
+/* t-encrypt.c - Regression test.
+ Copyright (C) 2000 Werner Koch (dd9jn)
+ Copyright (C) 2001, 2003, 2004 g10 Code GmbH
+
+ This file is part of GPGME.
+
+ GPGME is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ GPGME 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+/* We need to include config.h so that we know whether we are building
+ with large file system (LFS) support. */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+#include <gpgme.h>
+#include "t-support.h"
+
+
+static const char test_text1[] = "Hallo Leute!\n";
+static const char test_cip1[] =
+"-----BEGIN CMS OBJECT-----\n"
+"MIAGCSqGSIb3DQEHA6CAMIACAQAxggEJMIIBBQIBADBwMGsxCzAJBgNVBAYTAkRF\n"
+"MRMwEQYDVQQHFApE/HNzZWxkb3JmMRYwFAYDVQQKEw1nMTAgQ29kZSBHbWJIMRkw\n"
+"FwYDVQQLExBBZWd5cHRlbiBQcm9qZWN0MRQwEgYDVQQDEwt0ZXN0IGNlcnQgMQIB\n"
+"ADALBgkqhkiG9w0BAQEEgYBOFcOfUtAav+XjKGM1RJtF+8JLkbnu46S3T3709Iok\n"
+"u+Z9dwpOyfHwxXOmjzkSKQSBBxxi6ar+sKjU/KfPIvaMpARwT+NfIVSCZRWIJ27z\n"
+"wbSrav/kcRRDDA0wXV7dHVmSLPUJNCpiFMNZbkYtI+ai15g0PVeDw+szYd9zdsjJ\n"
+"2zCABgkqhkiG9w0BBwEwFAYIKoZIhvcNAwcECA8gPQY2NtJToIAECAeoY3MIcz9h\n"
+"BAiiytWtOSmqnwAA\n"
+"-----END CMS OBJECT-----\n";
+
+
+int
+main (int argc, char *argv[])
+{
+ gpgme_ctx_t ctx;
+ gpgme_error_t err;
+ gpgme_data_t in, out;
+ gpgme_decrypt_result_t result;
+
+ init_gpgme (GPGME_PROTOCOL_CMS);
+
+ err = gpgme_new (&ctx);
+ fail_if_err (err);
+ gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS);
+
+ err = gpgme_data_new_from_mem (&in, test_cip1, strlen (test_cip1), 0);
+ fail_if_err (err);
+
+ err = gpgme_data_new (&out);
+ fail_if_err (err);
+
+ err = gpgme_op_decrypt (ctx, in, out);
+ fail_if_err (err);
+ result = gpgme_op_decrypt_result (ctx);
+ if (result->unsupported_algorithm)
+ {
+ fprintf (stderr, "%s:%i: unsupported algorithm: %s\n",
+ __FILE__, __LINE__, result->unsupported_algorithm);
+ exit (1);
+ }
+ print_data (out);
+
+ gpgme_data_release (in);
+ gpgme_data_release (out);
+ gpgme_release (ctx);
+ return 0;
+}
diff --git a/tests/gpgsm/t-encrypt.c b/tests/gpgsm/t-encrypt.c
new file mode 100644
index 0000000..45c772b
--- /dev/null
+++ b/tests/gpgsm/t-encrypt.c
@@ -0,0 +1,78 @@
+/* t-encrypt.c - Regression test.
+ Copyright (C) 2000 Werner Koch (dd9jn)
+ Copyright (C) 2001, 2002, 2003, 2004 g10 Code GmbH
+
+ This file is part of GPGME.
+
+ GPGME is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ GPGME 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+/* We need to include config.h so that we know whether we are building
+ with large file system (LFS) support. */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <gpgme.h>
+
+#include "t-support.h"
+
+int
+main (int argc, char **argv)
+{
+ gpgme_ctx_t ctx;
+ gpgme_error_t err;
+ gpgme_data_t in, out;
+ gpgme_key_t key[] = { NULL, NULL };
+ gpgme_encrypt_result_t result;
+
+ init_gpgme (GPGME_PROTOCOL_CMS);
+
+ err = gpgme_new (&ctx);
+ fail_if_err (err);
+ gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS);
+ gpgme_set_armor (ctx, 1);
+
+ err = gpgme_data_new_from_mem (&in, "Hallo Leute\n", 12, 0);
+ fail_if_err (err);
+
+ err = gpgme_data_new (&out);
+ fail_if_err (err);
+
+ err = gpgme_get_key (ctx, "3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E",
+ &key[0], 0);
+ fail_if_err (err);
+
+ err = gpgme_op_encrypt (ctx, key, 0, in, out);
+ fail_if_err (err);
+ result = gpgme_op_encrypt_result (ctx);
+ if (result->invalid_recipients)
+ {
+ fprintf (stderr, "Invalid recipient encountered: %s\n",
+ result->invalid_recipients->fpr);
+ exit (1);
+ }
+ print_data (out);
+
+ gpgme_key_unref (key[0]);
+ gpgme_data_release (in);
+ gpgme_data_release (out);
+ gpgme_release (ctx);
+ return 0;
+}
diff --git a/tests/gpgsm/t-export.c b/tests/gpgsm/t-export.c
new file mode 100644
index 0000000..d8856f2
--- /dev/null
+++ b/tests/gpgsm/t-export.c
@@ -0,0 +1,86 @@
+/* t-export.c - Regression test.
+ Copyright (C) 2000 Werner Koch (dd9jn)
+ Copyright (C) 2001, 2003, 2004 g10 Code GmbH
+
+ This file is part of GPGME.
+
+ GPGME is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ GPGME 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+/* We need to include config.h so that we know whether we are building
+ with large file system (LFS) support. */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include <gpgme.h>
+#include "t-support.h"
+
+
+int
+main (int argc, char *argv[])
+{
+ gpgme_ctx_t ctx;
+ gpgme_error_t err;
+ gpgme_data_t out;
+ const char *pattern1[] = { "DFN Top Level Certification Authority", NULL };
+ const char *pattern2[] = { "3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E",
+ "DFN Server Certification Authority",
+ NULL };
+
+ init_gpgme (GPGME_PROTOCOL_CMS);
+
+ err = gpgme_new (&ctx);
+ fail_if_err (err);
+ gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS);
+
+ gpgme_set_armor (ctx, 1);
+
+ /* Check exporting of one certificate. */
+ err = gpgme_data_new (&out);
+ fail_if_err (err);
+ err = gpgme_op_export_ext (ctx, pattern1, 0, out);
+ fail_if_err (err);
+
+ fflush (NULL);
+ fputs ("Begin Result:\n", stdout);
+ print_data (out);
+ fputs ("End Result.\n", stdout);
+
+ gpgme_data_release (out);
+
+ /* Check exporting of 2 certificates. */
+ err = gpgme_data_new (&out);
+ fail_if_err (err);
+ err = gpgme_op_export_ext (ctx, pattern2, 0, out);
+ fail_if_err (err);
+
+ fflush (NULL);
+ fputs ("Begin Result:\n", stdout);
+ print_data (out);
+ fputs ("End Result.\n", stdout);
+
+ gpgme_data_release (out);
+
+
+ gpgme_release (ctx);
+
+ return 0;
+}
diff --git a/tests/gpgsm/t-genkey.c b/tests/gpgsm/t-genkey.c
new file mode 100644
index 0000000..9de9d54
--- /dev/null
+++ b/tests/gpgsm/t-genkey.c
@@ -0,0 +1,128 @@
+/* t-genkey.c - Regression test.
+ Copyright (C) 2000 Werner Koch (dd9jn)
+ Copyright (C) 2001, 2003, 2004 g10 Code GmbH
+
+ This file is part of GPGME.
+
+ GPGME is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ GPGME 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+/* We need to include config.h so that we know whether we are building
+ with large file system (LFS) support. */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+#include <gpgme.h>
+#include "t-support.h"
+
+
+/* True if progress function printed something on the screen. */
+static int progress_called;
+
+static void
+progress (void *self, const char *what, int type, int current, int total)
+{
+ if (!strcmp (what, "primegen") && !current && !total
+ && (type == '.' || type == '+' || type == '!'
+ || type == '^' || type == '<' || type == '>'))
+ {
+ printf ("%c", type);
+ fflush (stdout);
+ progress_called = 1;
+ }
+ else
+ {
+ fprintf (stderr, "unknown progress `%s' %d %d %d\n", what, type,
+ current, total);
+ exit (1);
+ }
+}
+
+
+int
+main (int argc, char *argv[])
+{
+ gpgme_ctx_t ctx;
+ gpgme_error_t err;
+ const char *parms = "<GnupgKeyParms format=\"internal\">\n"
+ "Key-Type: RSA\n"
+ "Key-Length: 1024\n"
+ "Name-DN: C=de,O=g10 code,OU=Testlab,CN=Joe 2 Tester\n"
+ "Name-Email: joe@foo.bar\n"
+ "</GnupgKeyParms>\n";
+ gpgme_genkey_result_t result;
+ gpgme_data_t certreq;
+
+ init_gpgme (GPGME_PROTOCOL_CMS);
+
+ err = gpgme_data_new (&certreq);
+ fail_if_err (err);
+
+ err = gpgme_new (&ctx);
+ fail_if_err (err);
+
+ gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS);
+ gpgme_set_armor (ctx, 1);
+
+ gpgme_set_progress_cb (ctx, progress, NULL);
+
+ err = gpgme_op_genkey (ctx, parms, certreq, NULL);
+ fail_if_err (err);
+
+ result = gpgme_op_genkey_result (ctx);
+ if (!result)
+ {
+ fprintf (stderr, "%s:%d: gpgme_op_genkey_result returns NULL\n",
+ __FILE__, __LINE__);
+ exit (1);
+ }
+ if (progress_called)
+ printf ("\n");
+
+ printf ("Generated key: %s (%s)\n", result->fpr ? result->fpr : "none",
+ result->primary ? (result->sub ? "primary, sub" : "primary")
+ : (result->sub ? "sub" : "none"));
+
+ if (result->fpr)
+ {
+ fprintf (stderr, "%s:%d: generated key has (unexpectdly) a fingerprint\n",
+ __FILE__, __LINE__);
+ exit (1);
+ }
+ if (!result->primary)
+ {
+ fprintf (stderr, "%s:%d: primary key was not generated\n",
+ __FILE__, __LINE__);
+ exit (1);
+ }
+ if (result->sub)
+ {
+ fprintf (stderr, "%s:%d: sub key was (unexpectedly) generated\n",
+ __FILE__, __LINE__);
+ exit (1);
+ }
+ gpgme_release (ctx);
+
+ print_data (certreq);
+ gpgme_data_release (certreq);
+
+ return 0;
+}
diff --git a/tests/gpgsm/t-import.c b/tests/gpgsm/t-import.c
new file mode 100644
index 0000000..2d23779
--- /dev/null
+++ b/tests/gpgsm/t-import.c
@@ -0,0 +1,175 @@
+/* t-import.c - Regression test.
+ Copyright (C) 2000 Werner Koch (dd9jn)
+ Copyright (C) 2001, 2003, 2004 g10 Code GmbH
+
+ This file is part of GPGME.
+
+ GPGME is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ GPGME 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+/* We need to include config.h so that we know whether we are building
+ with large file system (LFS) support. */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+#include <gpgme.h>
+
+#include "t-support.h"
+
+
+void
+check_result (gpgme_import_result_t result, char *fpr, int total,
+ int total_stat)
+{
+ if (result->considered != total)
+ {
+ fprintf (stderr, "Unexpected number of considered keys %i\n",
+ result->considered);
+ exit (1);
+ }
+ if (result->no_user_id != 0)
+ {
+ fprintf (stderr, "Unexpected number of user ids %i\n",
+ result->no_user_id);
+ exit (1);
+ }
+ if (result->imported != 0 && result->imported != 1)
+ {
+ fprintf (stderr, "Unexpected number of imported keys %i\n",
+ result->imported);
+ exit (1);
+ }
+ if (result->imported_rsa != 0)
+ {
+ fprintf (stderr, "Unexpected number of imported RSA keys %i\n",
+ result->imported_rsa);
+ exit (1);
+ }
+ if ((result->imported == 0 && result->unchanged != total)
+ || (result->imported == 1 && result->unchanged != total - 1))
+ {
+ fprintf (stderr, "Unexpected number of unchanged keys %i\n",
+ result->unchanged);
+ exit (1);
+ }
+ if (result->new_user_ids != 0)
+ {
+ fprintf (stderr, "Unexpected number of new user IDs %i\n",
+ result->new_user_ids);
+ exit (1);
+ }
+ if (result->new_sub_keys != 0)
+ {
+ fprintf (stderr, "Unexpected number of new sub keys %i\n",
+ result->new_sub_keys);
+ exit (1);
+ }
+ if (result->new_signatures != 0)
+ {
+ fprintf (stderr, "Unexpected number of new signatures %i\n",
+ result->new_signatures);
+ exit (1);
+ }
+ if (result->new_revocations != 0)
+ {
+ fprintf (stderr, "Unexpected number of new revocations %i\n",
+ result->new_revocations);
+ exit (1);
+ }
+ if (result->secret_read != 0)
+ {
+ fprintf (stderr, "Unexpected number of secret keys read %i\n",
+ result->secret_read);
+ exit (1);
+ }
+ if (result->secret_imported != 0)
+ {
+ fprintf (stderr, "Unexpected number of secret keys imported %i\n",
+ result->secret_imported);
+ exit (1);
+ }
+ if (result->secret_unchanged != 0)
+ {
+ fprintf (stderr, "Unexpected number of secret keys unchanged %i\n",
+ result->secret_unchanged);
+ exit (1);
+ }
+ if (result->not_imported != 0)
+ {
+ fprintf (stderr, "Unexpected number of secret keys not imported %i\n",
+ result->not_imported);
+ exit (1);
+ }
+
+ {
+ int n;
+ gpgme_import_status_t r;
+
+ for (n=0, r=result->imports; r; r=r->next)
+ n++;
+
+ if (n != total_stat)
+ {
+ fprintf (stderr, "Unexpected number of status reports\n");
+ exit (1);
+ }
+ }
+}
+
+
+int
+main (int argc, char **argv)
+{
+ gpgme_ctx_t ctx;
+ gpgme_error_t err;
+ gpgme_data_t in;
+ gpgme_import_result_t result;
+ const char *cert_1 = make_filename ("cert_dfn_pca01.der");
+ const char *cert_2 = make_filename ("cert_dfn_pca15.der");
+
+ init_gpgme (GPGME_PROTOCOL_CMS);
+
+ err = gpgme_new (&ctx);
+ fail_if_err (err);
+
+ gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS);
+
+ err = gpgme_data_new_from_file (&in, cert_1, 1);
+ fail_if_err (err);
+
+ err = gpgme_op_import (ctx, in);
+ fail_if_err (err);
+ result = gpgme_op_import_result (ctx);
+ check_result (result, "DFA56FB5FC41E3A8921F77AD1622EEFD9152A5AD", 1, 1);
+ gpgme_data_release (in);
+
+ err = gpgme_data_new_from_file (&in, cert_2, 1);
+ fail_if_err (err);
+
+ err = gpgme_op_import (ctx, in);
+ fail_if_err (err);
+ result = gpgme_op_import_result (ctx);
+ check_result (result, "2C8F3C356AB761CB3674835B792CDA52937F9285", 1, 2);
+ gpgme_data_release (in);
+
+ gpgme_release (ctx);
+ return 0;
+}
diff --git a/tests/gpgsm/t-keylist.c b/tests/gpgsm/t-keylist.c
new file mode 100644
index 0000000..bebd9d6
--- /dev/null
+++ b/tests/gpgsm/t-keylist.c
@@ -0,0 +1,389 @@
+/* t-keylist.c - regression test
+ Copyright (C) 2000 Werner Koch (dd9jn)
+ Copyright (C) 2001, 2003, 2004 g10 Code GmbH
+
+ This file is part of GPGME.
+
+ GPGME is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ GPGME 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+/* We need to include config.h so that we know whether we are building
+ with large file system (LFS) support. */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <gpgme.h>
+
+#include "t-support.h"
+
+
+struct
+{
+ char *fpr;
+ int secret;
+ long timestamp;
+ long expires;
+ char *issuer_serial;
+ char *issuer_name;
+ char *chain_id;
+ char *uid;
+ char *email;
+ gpgme_validity_t validity;
+ unsigned int key_length;
+}
+keys[] =
+ {
+ { "3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E", 1, 1007372198, 1038908198, "00",
+ "CN=test cert 1,OU=Aegypten Project,O=g10 Code GmbH,L=D\xc3\xbcsseldorf,C=DE",
+ "3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E",
+ "CN=test cert 1,OU=Aegypten Project,O=g10 Code GmbH,L=D\xc3\xbcsseldorf,C=DE",
+ NULL, GPGME_VALIDITY_ULTIMATE, 1024
+ },
+ { "DFA56FB5FC41E3A8921F77AD1622EEFD9152A5AD", 0, 909684190, 1009821790, "01",
+ "1.2.840.113549.1.9.1=#63657274696679407063612E64666E2E6465,"
+ "CN=DFN Top Level Certification Authority,OU=DFN-PCA,"
+ "O=Deutsches Forschungsnetz,C=DE",
+ "DFA56FB5FC41E3A8921F77AD1622EEFD9152A5AD",
+ "1.2.840.113549.1.9.1=#63657274696679407063612E64666E2E6465,"
+ "CN=DFN Top Level Certification Authority,OU=DFN-PCA,"
+ "O=Deutsches Forschungsnetz,C=DE",
+ "<certify@pca.dfn.de>", GPGME_VALIDITY_NEVER, 2048
+ },
+ { "2C8F3C356AB761CB3674835B792CDA52937F9285", 0, 973183644, 1009735200, "15",
+ "1.2.840.113549.1.9.1=#63657274696679407063612E64666E2E6465,"
+ "CN=DFN Top Level Certification Authority,OU=DFN-PCA,"
+ "O=Deutsches Forschungsnetz,C=DE",
+ "DFA56FB5FC41E3A8921F77AD1622EEFD9152A5AD",
+ "1.2.840.113549.1.9.1=#63657274696679407063612E64666E2E6465,"
+ "CN=DFN Server Certification Authority,OU=DFN-PCA,"
+ "O=Deutsches Forschungsnetz,C=DE",
+ "<certify@pca.dfn.de>", GPGME_VALIDITY_UNKNOWN, 2048
+ },
+ { NULL }
+ };
+
+
+int
+main (int argc, char **argv)
+{
+ gpgme_error_t err;
+ gpgme_ctx_t ctx;
+ gpgme_key_t key;
+ gpgme_keylist_result_t result;
+ int i = 0;
+
+ init_gpgme (GPGME_PROTOCOL_CMS);
+
+ err = gpgme_new (&ctx);
+ fail_if_err (err);
+ gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS);
+
+ err = gpgme_op_keylist_start (ctx, NULL, 0);
+ fail_if_err (err);
+
+ while (!(err = gpgme_op_keylist_next (ctx, &key)))
+ {
+ if (!keys[i].fpr)
+ {
+ fprintf (stderr, "More keys returned than expected\n");
+ exit (1);
+ }
+
+ if (strcmp (key->subkeys->fpr, keys[i].fpr))
+ {
+ fprintf (stderr, "Warning: Skipping unknown key %s\n",
+ key->subkeys->fpr);
+ continue;
+ }
+ else
+ printf ("Checking key %s\n", key->subkeys->fpr);
+
+ /* Global key flags. */
+ if (key->revoked)
+ {
+ fprintf (stderr, "Key unexpectedly revoked\n");
+ exit (1);
+ }
+ if (key->expired)
+ {
+ fprintf (stderr, "Key unexpectedly expired\n");
+ exit (1);
+ }
+ if (key->disabled)
+ {
+ fprintf (stderr, "Key unexpectedly disabled\n");
+ exit (1);
+ }
+ if (key->invalid)
+ {
+ fprintf (stderr, "Key unexpectedly invalid\n");
+ exit (1);
+ }
+ if (key->can_encrypt != keys[i].secret)
+ {
+ fprintf (stderr, "Key unexpectedly%s usable for encryption\n",
+ key->can_encrypt ? "" : " not");
+ exit (1);
+ }
+ if (key->can_sign != keys[i].secret)
+ {
+ fprintf (stderr, "Key unexpectedly%s usable for signing\n",
+ key->can_sign ? "" : " not");
+ exit (1);
+ }
+ if (!key->can_certify)
+ {
+ fprintf (stderr, "Key unexpectedly unusable for certifications\n");
+ exit (1);
+ }
+ if (key->secret != keys[i].secret)
+ {
+ fprintf (stderr, "Key unexpectedly%s secret\n",
+ key->secret ? "" : " not");
+ exit (1);
+ }
+ if (key->protocol != GPGME_PROTOCOL_CMS)
+ {
+ fprintf (stderr, "Key has unexpected protocol: %s\n",
+ gpgme_get_protocol_name (key->protocol));
+ exit (1);
+ }
+ if (!key->issuer_serial)
+ {
+ fprintf (stderr, "Key unexpectedly misses issuer serial\n");
+ exit (1);
+ }
+ if (strcmp (key->issuer_serial, keys[i].issuer_serial))
+ {
+ fprintf (stderr, "Key has unexpected issuer serial: %s\n",
+ key->issuer_serial);
+ exit (1);
+ }
+ if (!key->issuer_name)
+ {
+ fprintf (stderr, "Key unexpectedly misses issuer name\n");
+ exit (1);
+ }
+ if (strcmp (key->issuer_name, keys[i].issuer_name))
+ {
+ fprintf (stderr, "Key has unexpected issuer name: %s\n",
+ key->issuer_name);
+ exit (1);
+ }
+ if (key->chain_id && !keys[i].chain_id)
+ {
+ fprintf (stderr, "Key unexpectedly carries chain ID: %s\n",
+ key->chain_id);
+ exit (1);
+ }
+ if (!key->chain_id && keys[i].chain_id)
+ {
+ fprintf (stderr, "Key unexpectedly carries no chain ID\n");
+ exit (1);
+ }
+ if (key->chain_id && strcmp (key->chain_id, keys[i].chain_id))
+ {
+ fprintf (stderr, "Key carries unexpected chain ID: %s\n",
+ key->chain_id);
+ exit (1);
+ }
+ if (key->owner_trust != GPGME_VALIDITY_UNKNOWN)
+ {
+ fprintf (stderr, "Key has unexpected owner trust: %i\n",
+ key->owner_trust);
+ exit (1);
+ }
+ if (!key->subkeys || key->subkeys->next)
+ {
+ fprintf (stderr, "Key has unexpected number of subkeys\n");
+ exit (1);
+ }
+
+ /* Primary key. */
+ if (key->subkeys->revoked)
+ {
+ fprintf (stderr, "Primary key unexpectedly revoked\n");
+ exit (1);
+ }
+ if (key->subkeys->expired)
+ {
+ fprintf (stderr, "Primary key unexpectedly expired\n");
+ exit (1);
+ }
+ if (key->subkeys->disabled)
+ {
+ fprintf (stderr, "Primary key unexpectedly disabled\n");
+ exit (1);
+ }
+ if (key->subkeys->invalid)
+ {
+ fprintf (stderr, "Primary key unexpectedly invalid\n");
+ exit (1);
+ }
+ if (key->subkeys->can_encrypt != keys[i].secret)
+ {
+ fprintf (stderr, "Key unexpectedly%s usable for encryption\n",
+ key->subkeys->can_encrypt ? "" : " not");
+ exit (1);
+ }
+ if (key->subkeys->can_sign != keys[i].secret)
+ {
+ fprintf (stderr, "Key unexpectedly%s usable for signing\n",
+ key->subkeys->can_sign ? "" : " not");
+ exit (1);
+ }
+ if (!key->subkeys->can_certify)
+ {
+ fprintf (stderr, "Primary key unexpectedly unusable for certifications\n");
+ exit (1);
+ }
+ if (key->subkeys->secret != keys[i].secret)
+ {
+ fprintf (stderr, "Primary Key unexpectedly%s secret\n",
+ key->secret ? "" : " not");
+ exit (1);
+ }
+ if (key->subkeys->pubkey_algo != GPGME_PK_RSA)
+ {
+ fprintf (stderr, "Primary key has unexpected public key algo: %s\n",
+ gpgme_pubkey_algo_name (key->subkeys->pubkey_algo));
+ exit (1);
+ }
+ if (key->subkeys->length != keys[i].key_length)
+ {
+ fprintf (stderr, "Primary key has unexpected length: %i\n",
+ key->subkeys->length);
+ exit (1);
+ }
+ if (strcmp (key->subkeys->keyid, &keys[i].fpr[40 - 16]))
+ {
+ fprintf (stderr, "Primary key has unexpected key ID: %s\n",
+ key->subkeys->keyid);
+ exit (1);
+ }
+ if (strcmp (key->subkeys->fpr, keys[i].fpr))
+ {
+ fprintf (stderr, "Primary key has unexpected fingerprint: %s\n",
+ key->subkeys->fpr);
+ exit (1);
+ }
+ if (key->subkeys->timestamp != keys[i].timestamp)
+ {
+ fprintf (stderr, "Primary key unexpected timestamp: %lu\n",
+ key->subkeys->timestamp);
+ exit (1);
+ }
+ if (key->subkeys->expires != keys[i].expires)
+ {
+ fprintf (stderr, "Primary key unexpectedly expires: %lu\n",
+ key->subkeys->expires);
+ exit (1);
+ }
+
+ /* Be tolerant against a missing email (ie, older gpgsm versions). */
+ if (!key->uids || (key->uids->next && !keys[i].email))
+ {
+ fprintf (stderr, "Key has unexpected number of user IDs\n");
+ exit (1);
+ }
+ if (key->uids->revoked)
+ {
+ fprintf (stderr, "User ID unexpectedly revoked\n");
+ exit (1);
+ }
+ if (key->uids->invalid)
+ {
+ fprintf (stderr, "User ID unexpectedly invalid\n");
+ exit (1);
+ }
+ if (key->uids->validity != keys[i].validity)
+ {
+ fprintf (stderr, "User ID unexpectedly validity: %i\n",
+ key->uids->validity);
+ exit (1);
+ }
+ if (key->uids->signatures)
+ {
+ fprintf (stderr, "User ID unexpectedly signed\n");
+ exit (1);
+ }
+ if (!key->uids->name || key->uids->name[0])
+ {
+ fprintf (stderr, "Unexpected name in user ID: %s\n",
+ key->uids->name);
+ exit (1);
+ }
+ if (!key->uids->comment || key->uids->comment[0])
+ {
+ fprintf (stderr, "Unexpected comment in user ID: %s\n",
+ key->uids->comment);
+ exit (1);
+ }
+ if (!key->uids->email || key->uids->email[0])
+ {
+ fprintf (stderr, "Unexpected email in user ID: %s\n",
+ key->uids->email);
+ exit (1);
+ }
+ if (!key->uids->uid || strcmp (key->uids->uid, keys[i].uid))
+ {
+ fprintf (stderr, "Unexpected uid in user ID: %s\n",
+ key->uids->uid);
+ exit (1);
+ }
+ if (key->uids->next && strcmp (key->uids->next->uid, keys[i].email))
+ {
+ fprintf (stderr, "Unexpected email in user ID: %s\n",
+ key->uids->next->uid);
+ exit (1);
+ }
+ if (key->uids->next && strcmp (key->uids->next->uid, keys[i].email))
+ {
+ fprintf (stderr, "Unexpected email in user ID: %s\n",
+ key->uids->next->uid);
+ exit (1);
+ }
+
+
+
+ gpgme_key_unref (key);
+ i++;
+ }
+ if (gpgme_err_code (err) != GPG_ERR_EOF)
+ fail_if_err (err);
+ err = gpgme_op_keylist_end (ctx);
+ fail_if_err (err);
+
+ result = gpgme_op_keylist_result (ctx);
+ if (result->truncated)
+ {
+ fprintf (stderr, "Key listing unexpectedly truncated\n");
+ exit (1);
+ }
+
+ if (keys[i].fpr)
+ {
+ fprintf (stderr, "Less keys returned than expected\n");
+ exit (1);
+ }
+
+ gpgme_release (ctx);
+ return 0;
+}
diff --git a/tests/gpgsm/t-sign.c b/tests/gpgsm/t-sign.c
new file mode 100644
index 0000000..dc2d841
--- /dev/null
+++ b/tests/gpgsm/t-sign.c
@@ -0,0 +1,127 @@
+/* t-sign.c - Regression test.
+ Copyright (C) 2000 Werner Koch (dd9jn)
+ Copyright (C) 2001, 2003, 2004 g10 Code GmbH
+
+ This file is part of GPGME.
+
+ GPGME is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ GPGME 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+/* We need to include config.h so that we know whether we are building
+ with large file system (LFS) support. */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <gpgme.h>
+#include "t-support.h"
+
+
+static void
+check_result (gpgme_sign_result_t result, gpgme_sig_mode_t type)
+{
+ if (result->invalid_signers)
+ {
+ fprintf (stderr, "Invalid signer found: %s\n",
+ result->invalid_signers->fpr);
+ exit (1);
+ }
+ if (!result->signatures || result->signatures->next)
+ {
+ fprintf (stderr, "Unexpected number of signatures created\n");
+ exit (1);
+ }
+ if (result->signatures->type != type)
+ {
+ fprintf (stderr, "Wrong type of signature created\n");
+ exit (1);
+ }
+ if (result->signatures->pubkey_algo != GPGME_PK_RSA)
+ {
+ fprintf (stderr, "Wrong pubkey algorithm reported: %i\n",
+ result->signatures->pubkey_algo);
+ exit (1);
+ }
+ if (result->signatures->hash_algo != GPGME_MD_SHA1)
+ {
+ fprintf (stderr, "Wrong hash algorithm reported: %i\n",
+ result->signatures->hash_algo);
+ exit (1);
+ }
+ if (result->signatures->sig_class != 0)
+ {
+ fprintf (stderr, "Wrong signature class reported: %u\n",
+ result->signatures->sig_class);
+ exit (1);
+ }
+ if (strcmp ("3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E",
+ result->signatures->fpr))
+ {
+ fprintf (stderr, "Wrong fingerprint reported: %s\n",
+ result->signatures->fpr);
+ exit (1);
+ }
+}
+
+
+int
+main (int argc, char *argv[])
+{
+ gpgme_ctx_t ctx;
+ gpgme_error_t err;
+ gpgme_data_t in, out;
+ gpgme_sign_result_t result;
+
+ init_gpgme (GPGME_PROTOCOL_CMS);
+
+ err = gpgme_new (&ctx);
+ fail_if_err (err);
+
+ gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS);
+ gpgme_set_textmode (ctx, 1);
+ gpgme_set_armor (ctx, 1);
+
+ err = gpgme_data_new_from_mem (&in, "Hallo Leute!\n", 13, 0);
+ fail_if_err (err);
+
+ /* First a normal signature. */
+ err = gpgme_data_new (&out);
+ fail_if_err (err);
+ err = gpgme_op_sign (ctx, in, out, GPGME_SIG_MODE_NORMAL);
+ fail_if_err (err);
+ result = gpgme_op_sign_result (ctx);
+ check_result (result, GPGME_SIG_MODE_NORMAL);
+ print_data (out);
+ gpgme_data_release (out);
+
+ /* Now a detached signature. */
+ gpgme_data_seek (in, 0, SEEK_SET);
+ err = gpgme_data_new (&out);
+ fail_if_err (err);
+ err = gpgme_op_sign (ctx, in, out, GPGME_SIG_MODE_DETACH);
+ fail_if_err (err);
+ result = gpgme_op_sign_result (ctx);
+ check_result (result, GPGME_SIG_MODE_DETACH);
+ print_data (out);
+ gpgme_data_release (out);
+
+ gpgme_data_release (in);
+ gpgme_release (ctx);
+ return 0;
+}
diff --git a/tests/gpgsm/t-support.h b/tests/gpgsm/t-support.h
new file mode 100644
index 0000000..cc1a7db
--- /dev/null
+++ b/tests/gpgsm/t-support.h
@@ -0,0 +1,114 @@
+/* t-support.h - Helper routines for regression tests.
+ Copyright (C) 2000 Werner Koch (dd9jn)
+ Copyright (C) 2001, 2002, 2003, 2004 g10 Code GmbH
+
+ This file is part of GPGME.
+
+ GPGME is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ GPGME 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+#include <unistd.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <locale.h>
+
+#include <gpgme.h>
+
+#define fail_if_err(err) \
+ do \
+ { \
+ if (err) \
+ { \
+ fprintf (stderr, "%s:%d: %s: %s (%d.%d)\n", \
+ __FILE__, __LINE__, gpgme_strsource (err), \
+ gpgme_strerror (err), \
+ gpgme_err_source (err), gpgme_err_code (err)); \
+ exit (1); \
+ } \
+ } \
+ while (0)
+
+
+void
+print_data (gpgme_data_t dh)
+{
+#define BUF_SIZE 512
+ char buf[BUF_SIZE + 1];
+ int ret;
+
+ ret = gpgme_data_seek (dh, 0, SEEK_SET);
+ if (ret)
+ fail_if_err (gpgme_error_from_errno (errno));
+ while ((ret = gpgme_data_read (dh, buf, BUF_SIZE)) > 0)
+ fwrite (buf, ret, 1, stdout);
+ if (ret < 0)
+ fail_if_err (gpgme_error_from_errno (errno));
+}
+
+
+gpgme_error_t
+passphrase_cb (void *opaque, const char *uid_hint, const char *passphrase_info,
+ int last_was_bad, int fd)
+{
+ int res;
+ char *pass = "abc\n";
+ int passlen = strlen (pass);
+ int off = 0;
+
+ do
+ {
+ res = write (fd, &pass[off], passlen - off);
+ if (res > 0)
+ off += res;
+ }
+ while (res > 0 && off != passlen);
+
+ return off == passlen ? 0 : gpgme_error_from_errno (errno);
+}
+
+
+char *
+make_filename (const char *fname)
+{
+ const char *srcdir = getenv ("srcdir");
+ char *buf;
+
+ if (!srcdir)
+ srcdir = ".";
+ buf = malloc (strlen(srcdir) + strlen(fname) + 2);
+ if (!buf)
+ exit (8);
+ strcpy (buf, srcdir);
+ strcat (buf, "/");
+ strcat (buf, fname);
+ return buf;
+}
+
+
+void
+init_gpgme (gpgme_protocol_t proto)
+{
+ gpgme_error_t err;
+
+ gpgme_check_version (NULL);
+#ifndef HAVE_W32_SYSTEM
+ setlocale (LC_ALL, "");
+ gpgme_set_locale (NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL));
+ gpgme_set_locale (NULL, LC_MESSAGES, setlocale (LC_MESSAGES, NULL));
+#endif
+
+ err = gpgme_engine_check_version (proto);
+ fail_if_err (err);
+}
diff --git a/tests/gpgsm/t-verify.c b/tests/gpgsm/t-verify.c
new file mode 100644
index 0000000..062c5a1
--- /dev/null
+++ b/tests/gpgsm/t-verify.c
@@ -0,0 +1,182 @@
+/* t-verify.c - Regression test.
+ Copyright (C) 2000 Werner Koch (dd9jn)
+ Copyright (C) 2001, 2002, 2003, 2004 g10 Code GmbH
+
+ This file is part of GPGME.
+
+ GPGME is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ GPGME 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
+
+/* We need to include config.h so that we know whether we are building
+ with large file system (LFS) support. */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <gpgme.h>
+
+#include "t-support.h"
+
+
+static int got_errors;
+
+static const char test_text1[] = "Hallo Leute!\n";
+static const char test_text1f[]= "Hallo Leute?\n";
+static const char test_sig1[] =
+"-----BEGIN CMS OBJECT-----\n"
+"MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAA\n"
+"MYIBOTCCATUCAQEwcDBrMQswCQYDVQQGEwJERTETMBEGA1UEBxQKRPxzc2VsZG9y\n"
+"ZjEWMBQGA1UEChMNZzEwIENvZGUgR21iSDEZMBcGA1UECxMQQWVneXB0ZW4gUHJv\n"
+"amVjdDEUMBIGA1UEAxMLdGVzdCBjZXJ0IDECAQAwBwYFKw4DAhqgJTAjBgkqhkiG\n"
+"9w0BCQQxFgQU7FC/ibH3lC9GE24RJJxa8zqP7wEwCwYJKoZIhvcNAQEBBIGAA3oC\n"
+"DUmKERmD1eoJYFw38y/qnncS/6ZPjWINDIphZeK8mzAANpvpIaRPf3sNBznb89QF\n"
+"mRgCXIWcjlHT0DTRLBf192Ve22IyKH00L52CqFsSN3a2sajqRUlXH8RY2D+Al71e\n"
+"MYdRclgjObCcoilA8fZ13VR4DiMJVFCxJL4qVWI=\n"
+"-----END CMS OBJECT-----\n";
+
+
+static void
+check_result (gpgme_verify_result_t result, int summary, char *fpr,
+ gpgme_error_t status, gpgme_validity_t validity)
+{
+ gpgme_signature_t sig;
+
+ sig = result->signatures;
+ if (!sig || sig->next)
+ {
+ fprintf (stderr, "%s:%i: Unexpected number of signatures\n",
+ __FILE__, __LINE__);
+ got_errors = 1;
+ }
+ if (sig->summary != summary)
+ {
+ fprintf (stderr, "%s:%i: Unexpected signature summary: "
+ "want=0x%x have=0x%x\n",
+ __FILE__, __LINE__, summary, sig->summary);
+ got_errors = 1;
+ }
+ if (strcmp (sig->fpr, fpr))
+ {
+ fprintf (stderr, "%s:%i: Unexpected fingerprint: %s\n",
+ __FILE__, __LINE__, sig->fpr);
+ got_errors = 1;
+ }
+ if (gpgme_err_code (sig->status) != status)
+ {
+ fprintf (stderr, "%s:%i: Unexpected signature status: %s\n",
+ __FILE__, __LINE__, gpgme_strerror (sig->status));
+ got_errors = 1;
+ }
+ if (sig->notations)
+ {
+ fprintf (stderr, "%s:%i: Unexpected notation data\n",
+ __FILE__, __LINE__);
+ got_errors = 1;
+ }
+ if (sig->wrong_key_usage)
+ {
+ fprintf (stderr, "%s:%i: Unexpectedly wrong key usage\n",
+ __FILE__, __LINE__);
+ got_errors = 1;
+ }
+ if (sig->validity != validity)
+ {
+ fprintf (stderr, "%s:%i: Unexpected validity: %i\n",
+ __FILE__, __LINE__, sig->validity);
+ got_errors = 1;
+ }
+ if (gpgme_err_code (sig->validity_reason) != GPG_ERR_NO_ERROR)
+ {
+ fprintf (stderr, "%s:%i: Unexpected validity reason: %s\n",
+ __FILE__, __LINE__, gpgme_strerror (sig->validity_reason));
+ got_errors = 1;
+ }
+}
+
+
+static void
+show_auditlog (gpgme_ctx_t ctx)
+{
+ gpgme_error_t err;
+ gpgme_data_t data;
+
+ err = gpgme_data_new (&data);
+ fail_if_err (err);
+ err = gpgme_op_getauditlog (ctx, data, GPGME_AUDITLOG_HTML);
+ if (err)
+ {
+ fprintf (stderr, "%s:%i: Can't get audit log: %s\n",
+ __FILE__, __LINE__, gpgme_strerror (err));
+ if (gpgme_err_code (err) != GPG_ERR_ASS_UNKNOWN_CMD)
+ got_errors = 1;
+ }
+ print_data (data);
+ gpgme_data_release (data);
+}
+
+
+
+int
+main (int argc, char **argv)
+{
+ gpgme_ctx_t ctx;
+ gpgme_error_t err;
+ gpgme_data_t sig, text;
+ gpgme_verify_result_t result;
+
+ init_gpgme (GPGME_PROTOCOL_CMS);
+
+ err = gpgme_new (&ctx);
+ fail_if_err (err);
+ gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS);
+
+ /* Checking a valid message. */
+ err = gpgme_data_new_from_mem (&text, test_text1, strlen (test_text1), 0);
+ fail_if_err (err);
+ err = gpgme_data_new_from_mem (&sig, test_sig1, strlen (test_sig1), 0);
+ fail_if_err (err);
+
+ err = gpgme_op_verify (ctx, sig, text, NULL);
+ fail_if_err (err);
+ result = gpgme_op_verify_result (ctx);
+ check_result (result, GPGME_SIGSUM_VALID | GPGME_SIGSUM_GREEN,
+ "3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E",
+ GPG_ERR_NO_ERROR, GPGME_VALIDITY_FULL);
+
+ show_auditlog (ctx);
+
+ /* Checking a manipulated message. */
+ gpgme_data_release (text);
+ err = gpgme_data_new_from_mem (&text, test_text1f, strlen (test_text1f), 0);
+ fail_if_err (err);
+ gpgme_data_seek (sig, 0, SEEK_SET);
+ err = gpgme_op_verify (ctx, sig, text, NULL);
+ fail_if_err (err);
+ result = gpgme_op_verify_result (ctx);
+ check_result (result, GPGME_SIGSUM_RED,
+ "3CF405464F66ED4A7DF45BBDD1E4282E33BDB76E",
+ GPG_ERR_BAD_SIGNATURE, GPGME_VALIDITY_UNKNOWN);
+
+ show_auditlog (ctx);
+
+ gpgme_data_release (text);
+ gpgme_data_release (sig);
+ gpgme_release (ctx);
+ return got_errors? 1 : 0;
+}