Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
003c3f24fd | ||
|
c4531c92e3 | ||
|
3e01537c7c | ||
|
549c845f9d | ||
|
06e064d1d4 | ||
|
6e9d5a5800 | ||
|
22b7061c38 | ||
|
7d00d1958c | ||
|
37b563a6aa | ||
|
b18f6a5124 |
46
.gitignore
vendored
46
.gitignore
vendored
@ -1,55 +1,13 @@
|
|||||||
# GnuPG exclusions
|
|
||||||
/aclocal.m4
|
/aclocal.m4
|
||||||
/autom4te.cache
|
/autom4te.cache
|
||||||
|
/config.h.in
|
||||||
/configure
|
/configure
|
||||||
|
/config.h
|
||||||
/config.log
|
/config.log
|
||||||
/config.status
|
/config.status
|
||||||
/conf/config.h.in
|
|
||||||
/conf/config.h
|
|
||||||
/libtool
|
/libtool
|
||||||
/VERSION
|
|
||||||
Makefile.in
|
Makefile.in
|
||||||
Makefile
|
Makefile
|
||||||
stamp-h1
|
stamp-h1
|
||||||
*.o
|
*.o
|
||||||
*.lo
|
*.lo
|
||||||
|
|
||||||
# Hidden files
|
|
||||||
*~
|
|
||||||
|
|
||||||
# Byte compiled Python
|
|
||||||
*.py[cod]
|
|
||||||
__pycache__
|
|
||||||
|
|
||||||
# C extensions
|
|
||||||
*.so
|
|
||||||
|
|
||||||
# Packages
|
|
||||||
*.egg
|
|
||||||
*.egg-info
|
|
||||||
build
|
|
||||||
eggs
|
|
||||||
parts
|
|
||||||
develop-eggs
|
|
||||||
.installed.cfg
|
|
||||||
|
|
||||||
# Installer logs
|
|
||||||
pip-log.txt
|
|
||||||
|
|
||||||
# Unit test / coverage reports
|
|
||||||
.coverage
|
|
||||||
.tox
|
|
||||||
nosetests.xml
|
|
||||||
|
|
||||||
# Translations
|
|
||||||
*.mo
|
|
||||||
|
|
||||||
# Mr Developer
|
|
||||||
.mr.developer.cfg
|
|
||||||
.project
|
|
||||||
.pydevproject
|
|
||||||
|
|
||||||
# Assorted Apple crap
|
|
||||||
default.profraw
|
|
||||||
.DS_Store
|
|
||||||
._.DS_Store
|
|
||||||
|
53
AUTHORS
53
AUTHORS
@ -1,49 +1,21 @@
|
|||||||
Package: gpgme
|
Package: gpgme
|
||||||
Homepage: https://gnupg.org/software/gpgme/
|
Homepage: http://www.gnupg.org/related_software/gpgme/
|
||||||
Download: https://gnupg.org/ftp/gcrypt/gpgme/
|
Download: ftp://ftp.gnupg.org/gcrypt/gpgme/
|
||||||
Repository: git://git.gnupg.org/gpgme.git
|
Repository: git://git.gnupg.org/gpgme.git
|
||||||
Maintainer: Werner Koch <wk@gnupg.org>
|
Maintainer: Werner Koch <wk@gnupg.org>
|
||||||
Bug reports: https://bugs.gnupg.org
|
Bug reports: https://bugs.gnupg.org (use category "gpgme")
|
||||||
Security related bug reports: security@gnupg.org
|
Security related bug reports: security@gnupg.org
|
||||||
License (software): LGPL-2.1-or-later
|
License (software): LGPLv2.1+
|
||||||
License (manual+tools): GPL-3.0-or-later
|
License (manual+tools): GPLv3+
|
||||||
|
|
||||||
|
|
||||||
GPGME is free software. See the files COPYING.LESSER and COPYING for
|
|
||||||
copying conditions, , and LICENSES for notices about contributions
|
|
||||||
that require these additional notices to be distributed. License
|
|
||||||
copyright years may be listed using range notation, e.g., 2000-2013,
|
|
||||||
indicating that every year in the range, inclusive, is a copyrightable
|
|
||||||
year that would otherwise be listed individually.
|
|
||||||
|
|
||||||
|
|
||||||
List of Copyright holders
|
|
||||||
=========================
|
|
||||||
|
|
||||||
Copyright (C) 1991-2013 Free Software Foundation, Inc.
|
|
||||||
Copyright (C) 2000-2001 Werner Koch
|
|
||||||
Copyright (C) 2001-2023 g10 Code GmbH
|
|
||||||
Copyright (C) 2002 Klarälvdalens Datakonsult AB
|
|
||||||
Copyright (C) 2004-2008 Igor Belyi
|
|
||||||
Copyright (C) 2002 John Goerzen
|
|
||||||
Copyright (c) 2009 Dave Gamble
|
|
||||||
Copyright (C) 2014, 2015 Martin Albrecht
|
|
||||||
Copyright (C) 2015, 2018 Ben McGinnes
|
|
||||||
Copyright (C) 2015, 2016, 2018
|
|
||||||
Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Copyright (C) 2016 Intevation GmbH
|
|
||||||
|
|
||||||
|
|
||||||
Authors info
|
|
||||||
============
|
|
||||||
|
|
||||||
FSF <gnu@gnu.org>
|
FSF <gnu@gnu.org>
|
||||||
- Code taken from GnuPG 1.0: src/w32-util.c.
|
- Code taken from GnuPG 1.0: src/w32-util.c.
|
||||||
- Other from FSF projects: src/setenv.c, src/vasprintf.c,
|
- Other from FSF projects: src/setenv.c, src/vasprintf.c,
|
||||||
src/stpcpy.c, src/w32-ce.c.
|
src/stpcpy.c, src/w32-ce.c.
|
||||||
|
|
||||||
g10 Code GmbH <code@g10code.com>
|
g10 Code GmbH <code@g10code.com>
|
||||||
- All stuff since mid March 2001.
|
- All stuff since mid march 2001.
|
||||||
|
|
||||||
Werner Koch <wk@gnupg.org>
|
Werner Koch <wk@gnupg.org>
|
||||||
- Design and most stuff.
|
- Design and most stuff.
|
||||||
@ -58,20 +30,7 @@ Authors with a DCO
|
|||||||
Daniel Kahn Gillmor <dkg@fifthhorseman.net>
|
Daniel Kahn Gillmor <dkg@fifthhorseman.net>
|
||||||
2014-09-24:878ul9w4j8.fsf@alice.fifthhorseman.net:
|
2014-09-24:878ul9w4j8.fsf@alice.fifthhorseman.net:
|
||||||
|
|
||||||
Colin Watson <cjwatson@debian.org>
|
|
||||||
2017-09-16:20170916031428.uypfrdojquvjteor@riva.ucam.org:
|
|
||||||
|
|
||||||
Tobias Mueller <muelli@cryptobitch.de>
|
|
||||||
2016-11-23:1479937342.11180.3.camel@cryptobitch.de:
|
|
||||||
|
|
||||||
Ben McGinnes <ben@adversary.org>
|
|
||||||
2017-12-16:20171216002102.l6aejk5xdp6xhtfi@adversary.org:
|
|
||||||
|
|
||||||
Jacob Adams <tookmund@gmail.com>
|
|
||||||
2018-06-03:ad5141df-b6cc-6c2a-59df-b2f18f7160fd@gmail.com:
|
|
||||||
|
|
||||||
Guillaume LE VAILLANT <glv@posteo.net>
|
|
||||||
2018-10-11:20181011113825.76f9752a@yamatai:
|
|
||||||
|
|
||||||
|
|
||||||
Copyright 2001, 2002, 2012, 2013 g10 Code GmbH
|
Copyright 2001, 2002, 2012, 2013 g10 Code GmbH
|
||||||
|
38
LICENSES
38
LICENSES
@ -1,38 +0,0 @@
|
|||||||
Additional license notices for GPGME. -*- org -*-
|
|
||||||
|
|
||||||
This file contains the copying permission notices for various files in
|
|
||||||
the GPGME distribution which are not covered by the GNU Lesser
|
|
||||||
General Public License (LGPL) or the GNU General Public License (GPL).
|
|
||||||
|
|
||||||
These notices all require that a copy of the notice be included
|
|
||||||
in the accompanying documentation and be distributed with binary
|
|
||||||
distributions of the code, so be sure to include this file along
|
|
||||||
with any binary distributions derived from the GNU C Library.
|
|
||||||
|
|
||||||
* MIT License
|
|
||||||
|
|
||||||
For files:
|
|
||||||
- cJSON.c, cJSON.h
|
|
||||||
|
|
||||||
#+begin_quote
|
|
||||||
Copyright (c) 2009 Dave Gamble
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
a opy of this software and associated documentation files (the
|
|
||||||
"Software"), to eal in the Software without restriction, including
|
|
||||||
without limitation the ights to use, copy, modify, merge, publish,
|
|
||||||
distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be
|
|
||||||
included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
OF CONTRACT, TORT OR OTHERWISE, ARISING ROM, OUT OF OR IN CONNECTION
|
|
||||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
#+end_quote
|
|
102
Makefile.am
102
Makefile.am
@ -15,32 +15,17 @@
|
|||||||
# Public License for more details.
|
# Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
# License along with this program; if not, see <https://gnu.org/licenses/>.
|
# License along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
||||||
|
|
||||||
## Process this file with automake to produce Makefile.in
|
## Process this file with automake to produce Makefile.in
|
||||||
|
|
||||||
# Location of the released tarball archives. This is prefixed by
|
|
||||||
# the variable RELEASE_ARCHIVE in ~/.gnupg-autogen.rc. For example:
|
|
||||||
# RELEASE_ARCHIVE=user@host:archive/tarballs
|
|
||||||
RELEASE_ARCHIVE_SUFFIX = gpgme
|
|
||||||
# The variable RELEASE_SIGNKEY in ~/.gnupg-autogen.rc is used
|
|
||||||
# to specify the key for signing. For example:
|
|
||||||
# RELEASE_SIGNKEY=D8692123C4065DEA5E0F3AB5249B39D24F25E3B6
|
|
||||||
|
|
||||||
|
|
||||||
# Autoconf flags
|
|
||||||
ACLOCAL_AMFLAGS = -I m4
|
ACLOCAL_AMFLAGS = -I m4
|
||||||
|
|
||||||
DISTCHECK_CONFIGURE_FLAGS =
|
DISTCHECK_CONFIGURE_FLAGS =
|
||||||
|
|
||||||
EXTRA_DIST = autogen.sh autogen.rc gpgme.spec.in \
|
EXTRA_DIST = autogen.sh autogen.rc gpgme.spec.in \
|
||||||
ChangeLog-2011 m4/ChangeLog-2011 \
|
ChangeLog-2011 m4/ChangeLog-2011 contrib/ChangeLog-2011
|
||||||
build-aux/libtool-patch.sed \
|
|
||||||
conf/whatisthis VERSION LICENSES
|
|
||||||
|
|
||||||
# This artificial line is to put a dependency to conf/config.h for 'all'
|
|
||||||
BUILT_SOURCES = conf/config.h
|
|
||||||
|
|
||||||
if RUN_GPG_TESTS
|
if RUN_GPG_TESTS
|
||||||
tests = tests
|
tests = tests
|
||||||
@ -50,29 +35,17 @@ endif
|
|||||||
|
|
||||||
SUBDIRS = src ${tests} doc lang
|
SUBDIRS = src ${tests} doc lang
|
||||||
|
|
||||||
# Fix the version of the spec file.
|
# Fix the version of the spec file and create a file named VERSION
|
||||||
|
# to be used for patch's Prereq: feature.
|
||||||
dist-hook: gen-ChangeLog
|
dist-hook: gen-ChangeLog
|
||||||
@set -e; \
|
@set -e; \
|
||||||
sed -e 's/@pkg_version@/$(PACKAGE_VERSION)/g' \
|
sed -e 's/@pkg_version@/$(VERSION)/g' \
|
||||||
$(top_srcdir)/gpgme.spec.in > $(distdir)/gpgme.spec
|
$(top_srcdir)/gpgme.spec.in > $(distdir)/gpgme.spec
|
||||||
|
echo "$(VERSION)" > $(distdir)/VERSION
|
||||||
|
|
||||||
distcheck-hook:
|
|
||||||
set -e; ( \
|
|
||||||
pref="#+macro: gpgme_" ;\
|
|
||||||
reldate="$$(date -u +%Y-%m-%d)" ;\
|
|
||||||
echo "$${pref}ver $(PACKAGE_VERSION)" ;\
|
|
||||||
echo "$${pref}date $${reldate}" ;\
|
|
||||||
list='$(DIST_ARCHIVES)'; for i in $$list; do \
|
|
||||||
case "$$i" in *.tar.bz2) \
|
|
||||||
echo "$${pref}size $$(wc -c <$$i|awk '{print int($$1/1024)}')k" ;\
|
|
||||||
echo "$${pref}sha1 $$(sha1sum <$$i|cut -d' ' -f1)" ;\
|
|
||||||
echo "$${pref}sha2 $$(sha256sum <$$i|cut -d' ' -f1)" ;;\
|
|
||||||
esac;\
|
|
||||||
done ) | tee $(distdir).swdb
|
|
||||||
|
|
||||||
.PHONY: gen-ChangeLog release sign-release
|
|
||||||
|
|
||||||
gen_start_date = 2011-12-01T00:00:00
|
gen_start_date = 2011-12-01T00:00:00
|
||||||
|
.PHONY: gen-ChangeLog
|
||||||
gen-ChangeLog:
|
gen-ChangeLog:
|
||||||
if test -d $(top_srcdir)/.git; then \
|
if test -d $(top_srcdir)/.git; then \
|
||||||
(cd $(top_srcdir) && \
|
(cd $(top_srcdir) && \
|
||||||
@ -83,62 +56,3 @@ gen-ChangeLog:
|
|||||||
rm -f $(distdir)/ChangeLog; \
|
rm -f $(distdir)/ChangeLog; \
|
||||||
mv $(distdir)/cl-t $(distdir)/ChangeLog; \
|
mv $(distdir)/cl-t $(distdir)/ChangeLog; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Macro to help the release target.
|
|
||||||
RELEASE_NAME = $(PACKAGE_TARNAME)-$(PACKAGE_VERSION)
|
|
||||||
|
|
||||||
release:
|
|
||||||
+(set -e;\
|
|
||||||
if [ "$(abs_top_builddir)" = "$(abs_top_srcdir)" ]; then \
|
|
||||||
echo "error: build directory must not be the source directory" >&2;\
|
|
||||||
exit 2;\
|
|
||||||
fi ;\
|
|
||||||
echo "/* Build started at $$(date -uIseconds) */" ;\
|
|
||||||
cd $(top_srcdir); \
|
|
||||||
./autogen.sh --force; \
|
|
||||||
cd $(abs_top_builddir); \
|
|
||||||
rm -rf dist; mkdir dist ; cd dist ; \
|
|
||||||
$(abs_top_srcdir)/configure --enable-maintainer-mode; \
|
|
||||||
$(MAKE) distcheck; \
|
|
||||||
echo "/* Build finished at $$(date -uIseconds) */" ;\
|
|
||||||
echo "/*" ;\
|
|
||||||
echo " * Please run the final step interactively:" ;\
|
|
||||||
echo " * make sign-release" ;\
|
|
||||||
echo " */" ;\
|
|
||||||
) 2>&1 | tee "$(RELEASE_NAME).buildlog"
|
|
||||||
|
|
||||||
sign-release:
|
|
||||||
+(set -e; \
|
|
||||||
test $$(pwd | sed 's,.*/,,') = dist || cd dist; \
|
|
||||||
x=$$(grep '^RELEASE_ARCHIVE=' $$HOME/.gnupg-autogen.rc|cut -d= -f2);\
|
|
||||||
if [ -z "$$x" ]; then \
|
|
||||||
echo "error: RELEASE_ARCHIVE missing in ~/.gnupg-autogen.rc">&2; \
|
|
||||||
exit 2;\
|
|
||||||
fi;\
|
|
||||||
myarchive="$$x/$(RELEASE_ARCHIVE_SUFFIX)";\
|
|
||||||
x=$$(grep '^RELEASE_SIGNKEY=' $$HOME/.gnupg-autogen.rc|cut -d= -f2);\
|
|
||||||
if [ -z "$$x" ]; then \
|
|
||||||
echo "error: RELEASE_SIGNKEY missing in ~/.gnupg-autogen.rc">&2; \
|
|
||||||
exit 2;\
|
|
||||||
fi;\
|
|
||||||
mysignkey="$$x";\
|
|
||||||
files1="$(RELEASE_NAME).tar.bz2" ;\
|
|
||||||
files2="$(RELEASE_NAME).tar.bz2.sig \
|
|
||||||
$(RELEASE_NAME).swdb \
|
|
||||||
$(RELEASE_NAME).buildlog" ;\
|
|
||||||
echo "/* Signing the source tarball ..." ;\
|
|
||||||
gpg -sbu $$mysignkey $(RELEASE_NAME).tar.bz2 ;\
|
|
||||||
cat $(RELEASE_NAME).swdb >swdb.snippet;\
|
|
||||||
echo >>swdb.snippet ;\
|
|
||||||
sha1sum $${files1} >>swdb.snippet ;\
|
|
||||||
cat "../$(RELEASE_NAME).buildlog" swdb.snippet \
|
|
||||||
| gzip >$(RELEASE_NAME).buildlog ;\
|
|
||||||
echo "Copying to local archive ..." ;\
|
|
||||||
scp -p $${files1} $${files2} $$myarchive/ || true;\
|
|
||||||
echo "Uploading documentation ..." ;\
|
|
||||||
$(MAKE) -C doc online; \
|
|
||||||
echo '/*' ;\
|
|
||||||
echo ' * All done; for checksums see dist/swdb.snippet' ;\
|
|
||||||
echo ' */' ;\
|
|
||||||
)
|
|
||||||
|
61
README
61
README
@ -1,7 +1,7 @@
|
|||||||
GPGME - GnuPG Made Easy
|
GPGME - GnuPG Made Easy
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
Copyright 2001-2023 g10 Code GmbH
|
Copyright 2004, 2006, 2010, 2012, 2013, 2014, 2015 g10 Code GmbH
|
||||||
|
|
||||||
This file is free software; as a special exception the author gives
|
This file is free software; as a special exception the author gives
|
||||||
unlimited permission to copy and/or distribute it, with or without
|
unlimited permission to copy and/or distribute it, with or without
|
||||||
@ -22,12 +22,12 @@ to public key crypto engines like GnuPG or GpgSM easier for
|
|||||||
applications. GPGME provides a high-level crypto API for encryption,
|
applications. GPGME provides a high-level crypto API for encryption,
|
||||||
decryption, signing, signature verification and key management.
|
decryption, signing, signature verification and key management.
|
||||||
|
|
||||||
GPGME comes with language bindings for Common Lisp, C++, QT, Python2,
|
GPGME uses GnuPG and GpgSM as its backends to support OpenPGP and the
|
||||||
and Python 3.
|
|
||||||
|
|
||||||
GPGME uses GnuPG as its backend to support OpenPGP and the
|
|
||||||
Cryptographic Message Syntax (CMS).
|
Cryptographic Message Syntax (CMS).
|
||||||
|
|
||||||
|
GPGME runs best on GNU/Linux or *BSD systems. Other Unices may
|
||||||
|
require small portability fixes, please send us your patches.
|
||||||
|
|
||||||
See the files COPYING, COPYING.LESSER, and each file for copyright and
|
See the files COPYING, COPYING.LESSER, and each file for copyright and
|
||||||
warranty information. The file AUTHORS has a list of authors and
|
warranty information. The file AUTHORS has a list of authors and
|
||||||
useful web and mail addresses.
|
useful web and mail addresses.
|
||||||
@ -41,14 +41,16 @@ See the file INSTALL for generic installation instructions.
|
|||||||
Check that you have unmodified sources. See below on how to do this.
|
Check that you have unmodified sources. See below on how to do this.
|
||||||
Don't skip it - this is an important step!
|
Don't skip it - this is an important step!
|
||||||
|
|
||||||
To build GPGME, you need to install libgpg-error (>= 1.36) and
|
To build GPGME, you need to install libgpg-error (>= 1.11) and
|
||||||
Libassuan (>= 2.4.2).
|
Libassuan (>= 2.0.2).
|
||||||
|
|
||||||
For support of the OpenPGP and the CMS protocols, you should use at
|
For support of the OpenPGP protocol (default), you should use the
|
||||||
least GnuPG version 2.2.41 or 2.4.3, available at:
|
latest version of GnuPG (>= 1.4) , available at:
|
||||||
https://gnupg.org/ftp/gcrypt/gnupg/.
|
ftp://ftp.gnupg.org/gcrypt/gnupg/. For support of the CMS
|
||||||
|
(Cryptographic Message Syntax) protocol and lot of other features, you
|
||||||
|
need a GnuPG version >= 2.0.
|
||||||
|
|
||||||
For building the Git version of GPGME please see the file README.GIT
|
For building the GIT version of GPGME please see the file README.GIT
|
||||||
for more information.
|
for more information.
|
||||||
|
|
||||||
|
|
||||||
@ -62,33 +64,24 @@ following ways:
|
|||||||
a) If you have a trusted Version of GnuPG installed, you can simply check
|
a) If you have a trusted Version of GnuPG installed, you can simply check
|
||||||
the supplied signature:
|
the supplied signature:
|
||||||
|
|
||||||
$ gpg --verify gpgme-x.y.z.tar.gz.sig gpgme-x.y.z.tar.gz
|
$ gpg --verify gpgme-x.y.z.tar.gz.sig
|
||||||
|
|
||||||
This checks that the detached signature gpgme-x.y.z.tar.gz.sig is
|
This checks that the detached signature gpgme-x.y.z.tar.gz.sig is
|
||||||
indeed a a signature of gpgme-x.y.z.tar.gz. The key used to create
|
indeed a a signature of gpgme-x.y.z.tar.gz. The key used to create
|
||||||
this signature is at least one of:
|
this signature is either of:
|
||||||
|
|
||||||
rsa2048 2011-01-12 [expires: 2019-12-31]
|
"pub 2048R/4F25E3B6 2011-01-12 Werner Koch (dist sig)"
|
||||||
Key fingerprint = D869 2123 C406 5DEA 5E0F 3AB5 249B 39D2 4F25 E3B6
|
"pub 1024D/87978569 1999-05-13
|
||||||
Werner Koch (dist sig)
|
Marcus Brinkmann <Marcus.Brinkmann@ruhr-uni-bochum.de>
|
||||||
|
Marcus Brinkmann <mb@g10code.com>"
|
||||||
|
|
||||||
rsa2048 2014-10-29 [expires: 2019-12-31]
|
If you do not have this key, you can get it from any keyserver. You
|
||||||
Key fingerprint = 46CC 7308 65BB 5C78 EBAB ADCF 0437 6F3E E085 6959
|
have to make sure that this is really the key and not a faked one.
|
||||||
David Shaw (GnuPG Release Signing Key) <dshaw 'at' jabberwocky.com>
|
You can do this by comparing the output of:
|
||||||
|
|
||||||
rsa2048 2014-10-29 [expires: 2020-10-30]
|
$ gpg --fingerprint 0x4F25E3B6
|
||||||
Key fingerprint = 031E C253 6E58 0D8E A286 A9F2 2071 B08A 33BD 3F06
|
|
||||||
NIIBE Yutaka (GnuPG Release Key) <gniibe 'at' fsij.org>
|
|
||||||
|
|
||||||
rsa3072 2017-03-17 [expires: 2027-03-15]
|
with the fingerprint published elsewhere.
|
||||||
Key fingerprint = 5B80 C575 4298 F0CB 55D8 ED6A BCEF 7E29 4B09 2E28
|
|
||||||
Andre Heinecke (Release Signing Key)
|
|
||||||
|
|
||||||
The keys are available at <https://gnupg.org/signature_key.html>
|
|
||||||
and in released GnuPG tarballs in the file g10/distsigkey.gpg .
|
|
||||||
You have to make sure that these are really the desired keys and
|
|
||||||
not faked one. You should do this by comparing the fingerprints
|
|
||||||
with the fingerprints published elsewhere.
|
|
||||||
|
|
||||||
b) If you don't have any of the above programs, you have to verify
|
b) If you don't have any of the above programs, you have to verify
|
||||||
the SHA1 checksum:
|
the SHA1 checksum:
|
||||||
@ -108,7 +101,7 @@ Documentation
|
|||||||
|
|
||||||
For information how to use the library you can read the info manual,
|
For information how to use the library you can read the info manual,
|
||||||
which is also a reference book, in the doc/ directory. The programs
|
which is also a reference book, in the doc/ directory. The programs
|
||||||
in the tests/ directory may also prove useful.
|
in the tests/gpg/ directory may also prove useful.
|
||||||
|
|
||||||
Please subscribe to the gnupg-devel@gnupg.org mailing list if you want
|
Please subscribe to the gnupg-devel@gnupg.org mailing list if you want
|
||||||
to do serious work.
|
to do serious work.
|
||||||
|
6
THANKS
6
THANKS
@ -5,7 +5,7 @@ want to thank them for their help. If we forgot you, please let us
|
|||||||
know.
|
know.
|
||||||
|
|
||||||
Adriaan de Groot adridg@cs.kun.nl
|
Adriaan de Groot adridg@cs.kun.nl
|
||||||
Albrecht Dreß albrecht.dress@arcor.de
|
Albrecht Dreß albrecht.dress@arcor.de
|
||||||
Alfons Hoogervorst alfons@proteus.demon.nl
|
Alfons Hoogervorst alfons@proteus.demon.nl
|
||||||
Daniel Mueller daniel@danm.de
|
Daniel Mueller daniel@danm.de
|
||||||
Enno Cramer uebergeek@web.de
|
Enno Cramer uebergeek@web.de
|
||||||
@ -13,13 +13,13 @@ Frank Heckenbach frank@g-n-u.de
|
|||||||
Igor Belyi gpgme@katehok.ac93.org
|
Igor Belyi gpgme@katehok.ac93.org
|
||||||
Jan-Oliver Wagner jan@intevation.de
|
Jan-Oliver Wagner jan@intevation.de
|
||||||
Johannes Poehlmann jhp@caldera.de
|
Johannes Poehlmann jhp@caldera.de
|
||||||
Jose C. García Sogo jose@jaimedelamo.eu.org
|
Jose C. García Sogo jose@jaimedelamo.eu.org
|
||||||
Leo Gaspard ekleog@gmail.com
|
Leo Gaspard ekleog@gmail.com
|
||||||
Mark Mutz mutz@kde.org
|
Mark Mutz mutz@kde.org
|
||||||
Miguel Coca mcoca@gnu.org
|
Miguel Coca mcoca@gnu.org
|
||||||
Noel Torres envite@rolamasao.org
|
Noel Torres envite@rolamasao.org
|
||||||
Patrick Spendrin patrick.spendrin@kdab.com
|
Patrick Spendrin patrick.spendrin@kdab.com
|
||||||
Stéphane Corthésy stephane@sente.ch
|
Stéphane Corthésy stephane@sente.ch
|
||||||
Timo Schulz twoaday@freakmail.de
|
Timo Schulz twoaday@freakmail.de
|
||||||
Tommy Reynolds reynolds@redhat.com
|
Tommy Reynolds reynolds@redhat.com
|
||||||
W. Trevor King wking@tremily.us
|
W. Trevor King wking@tremily.us
|
||||||
|
522
TODO
522
TODO
@ -1,254 +1,58 @@
|
|||||||
#+TITLE: TODO List
|
|
||||||
Hey Emacs, this is -*- org -*- mode!
|
Hey Emacs, this is -*- org -*- mode!
|
||||||
|
|
||||||
* IMPORTANT!
|
* Document all the new stuff.
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: dev-gnupg-org
|
|
||||||
:END:
|
|
||||||
|
|
||||||
There was a nine year gap (2009 to 2018) between edits of this file,
|
|
||||||
so it is likely that much of the old information in it is wrong or
|
|
||||||
no longer applicable.
|
|
||||||
|
|
||||||
Bugs, feature requests and other development related work will be
|
|
||||||
tracked through the [[https://dev.gnupg.org/][dev.gnupg.org]] site.
|
|
||||||
|
|
||||||
|
|
||||||
* Documentation
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: documentation
|
|
||||||
:END:
|
|
||||||
|
|
||||||
** Document all the new stuff.
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: more-docs-is-better
|
|
||||||
:END:
|
|
||||||
|
|
||||||
*** TODO Fix this TODO list.
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: fix-todo
|
|
||||||
:END:
|
|
||||||
|
|
||||||
Clean up the current TODO list. Include properties as relevant (so
|
|
||||||
if someone does make a PDF or HTML version the TOC will work).
|
|
||||||
|
|
||||||
Also check to see if some of these ancient things can be removed
|
|
||||||
(e.g. do we really need to fix things that were broken in GPG
|
|
||||||
1.3.x? I'm thinking not so much).
|
|
||||||
|
|
||||||
**** DONE fix TODO items
|
|
||||||
CLOSED: [2018-03-04 Sun 08:55]
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: fix-todo-items
|
|
||||||
:END:
|
|
||||||
|
|
||||||
Adjust todo items so each can now be referenced by custom-id and
|
|
||||||
checked off as necessary.
|
|
||||||
|
|
||||||
** TODO Document validity and trust issues.
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: valid-trust-issues
|
|
||||||
:END:
|
|
||||||
|
|
||||||
** In gpgme.texi: Register callbacks under the right letter in the index.
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: gpgme-texi
|
|
||||||
:END:
|
|
||||||
|
|
||||||
|
|
||||||
* Fix the remaining UI Server problems:
|
* Fix the remaining UI Server problems:
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: ui-server-fix
|
|
||||||
:END:
|
|
||||||
** VERIFY --silent support.
|
** VERIFY --silent support.
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: verify-silent
|
|
||||||
:END:
|
|
||||||
** ENCRYPT/DECRYPT/VERIFY/SIGN reset the engine, shouldn't be done with UISERVER?
|
** ENCRYPT/DECRYPT/VERIFY/SIGN reset the engine, shouldn't be done with UISERVER?
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: reset-engine-not-ui
|
|
||||||
:END:
|
|
||||||
|
|
||||||
|
|
||||||
* IMPORTANT
|
* IMPORTANT
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: important-stuff-really
|
|
||||||
:END:
|
|
||||||
** When using descriptor passing, we need to set the fd to blocking before
|
** When using descriptor passing, we need to set the fd to blocking before
|
||||||
:PROPERTIES:
|
issueing simple commands, because we are mixing synchronous
|
||||||
:CUSTOM_ID: set-fd-blocking
|
|
||||||
:END:
|
|
||||||
issuing simple commands, because we are mixing synchronous
|
|
||||||
commands into potentially asynchronous operations.
|
commands into potentially asynchronous operations.
|
||||||
** Might want to implement nonblock for w32 native backend!
|
** Might want to implement nonblock for w32 native backend! Right now,
|
||||||
:PROPERTIES:
|
we block reading the next line with assuan.
|
||||||
:CUSTOM_ID: nonblock-win32
|
|
||||||
:END:
|
|
||||||
Right now we block reading the next line with assuan.
|
|
||||||
|
|
||||||
|
|
||||||
* Before release:
|
* Before release:
|
||||||
:PROPERTIES:
|
** Some gpg tests fail with gpg 1.3.4-cvs (gpg/t-keylist-sig)
|
||||||
:CUSTOM_ID: pre-release
|
|
||||||
:END:
|
|
||||||
|
|
||||||
** CANCELLED Some gpg tests fail with gpg 1.3.4-cvs (gpg/t-keylist-sig)
|
|
||||||
CLOSED: [2018-03-09 Fri 08:16]
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: gpg-1-3-4-really
|
|
||||||
:END:
|
|
||||||
- State "CANCELLED" from "TODO" [2018-03-09 Fri 08:16] \\
|
|
||||||
WON'T FIX — too old or no longer applies.
|
|
||||||
The test is currently disabled there and in gpg/t-import.
|
The test is currently disabled there and in gpg/t-import.
|
||||||
|
|
||||||
** When gpg supports it, write binary subpackets directly,
|
** When gpg supports it, write binary subpackets directly,
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: binary-subpackets
|
|
||||||
:END:
|
|
||||||
and parse SUBPACKET status lines.
|
and parse SUBPACKET status lines.
|
||||||
|
|
||||||
|
|
||||||
* ABI's to break:
|
* ABI's to break:
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: abi-breakage-apparently-on-purpose
|
|
||||||
:END:
|
|
||||||
|
|
||||||
** Old opassuan interface.
|
** Old opassuan interface.
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: old-opassuan
|
|
||||||
:END:
|
|
||||||
|
|
||||||
** Implementation: Remove support for old style error codes in
|
** Implementation: Remove support for old style error codes in
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: remove-old-error-codes
|
|
||||||
:END:
|
|
||||||
conversion.c::_gpgme_map_gnupg_error.
|
conversion.c::_gpgme_map_gnupg_error.
|
||||||
|
|
||||||
** gpgme_edit_cb_t: Add "processed" return argument
|
** gpgme_edit_cb_t: Add "processed" return argument
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: add-processed-return
|
|
||||||
:END:
|
|
||||||
(see edit.c::command_handler).
|
(see edit.c::command_handler).
|
||||||
|
|
||||||
** I/O and User Data could be made extensible. But this can be done
|
** I/O and User Data could be made extensible. But this can be done
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: add-io-user-data
|
|
||||||
:END:
|
|
||||||
without breaking the ABI hopefully.
|
without breaking the ABI hopefully.
|
||||||
|
|
||||||
** All enums should be replaced by ints and simple macros for
|
** All enums should be replaced by ints and simple macros for
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: enums-should-be-ints
|
|
||||||
:END:
|
|
||||||
maximum compatibility.
|
maximum compatibility.
|
||||||
|
|
||||||
** Compatibility interfaces that can be removed in future versions:
|
** Compatibility interfaces that can be removed in future versions:
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: compat-interfaces-to-go
|
|
||||||
:END:
|
|
||||||
|
|
||||||
*** gpgme_data_new_from_filepart
|
*** gpgme_data_new_from_filepart
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: gpgme-data-new-from-filepart
|
|
||||||
:END:
|
|
||||||
|
|
||||||
*** gpgme_data_new_from_file
|
*** gpgme_data_new_from_file
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: gpgme-data-new-from-file
|
|
||||||
:END:
|
|
||||||
|
|
||||||
*** gpgme_data_new_with_read_cb
|
*** gpgme_data_new_with_read_cb
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: gpgme-data-new-with-read-cb
|
|
||||||
:END:
|
|
||||||
|
|
||||||
*** gpgme_data_rewind
|
*** gpgme_data_rewind
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: gpgme-data-rewind
|
|
||||||
:END:
|
|
||||||
|
|
||||||
*** gpgme_op_import_ext
|
*** gpgme_op_import_ext
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: gpgme-op-import-ext
|
|
||||||
:END:
|
|
||||||
|
|
||||||
*** gpgme_get_sig_key
|
*** gpgme_get_sig_key
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: gpgme-get-sig-key
|
|
||||||
:END:
|
|
||||||
|
|
||||||
*** gpgme_get_sig_ulong_attr
|
*** gpgme_get_sig_ulong_attr
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: gpgme-get-sig-ulong-attr
|
|
||||||
:END:
|
|
||||||
|
|
||||||
*** gpgme_get_sig_string_attr
|
*** gpgme_get_sig_string_attr
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: gpgme-get-sig-string-attr
|
|
||||||
:END:
|
|
||||||
|
|
||||||
*** GPGME_SIG_STAT_*
|
*** GPGME_SIG_STAT_*
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: gpgme-sig-stat
|
|
||||||
:END:
|
|
||||||
|
|
||||||
*** gpgme_get_sig_status
|
*** gpgme_get_sig_status
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: gpgme-get-sig-status
|
|
||||||
:END:
|
|
||||||
|
|
||||||
*** gpgme_trust_item_release
|
*** gpgme_trust_item_release
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: gpgme-trust-item-release
|
|
||||||
:END:
|
|
||||||
|
|
||||||
*** gpgme_trust_item_get_string_attr
|
*** gpgme_trust_item_get_string_attr
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: gpgme-trust-item-get-string-attr
|
|
||||||
:END:
|
|
||||||
|
|
||||||
*** gpgme_trust_item_get_ulong_attr
|
*** gpgme_trust_item_get_ulong_attr
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: gpgme-trust-item-get-ulong-attr
|
|
||||||
:END:
|
|
||||||
|
|
||||||
*** gpgme_attr_t
|
*** gpgme_attr_t
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: gpgme-attr-t
|
|
||||||
:END:
|
|
||||||
|
|
||||||
*** All Gpgme* typedefs.
|
*** All Gpgme* typedefs.
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: all-gpgme-typedefs
|
|
||||||
:END:
|
|
||||||
|
|
||||||
|
|
||||||
* Thread support:
|
* Thread support:
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: threads
|
|
||||||
:END:
|
|
||||||
|
|
||||||
** When GNU Pth supports sendmsg/recvmsg, wrap them properly.
|
** When GNU Pth supports sendmsg/recvmsg, wrap them properly.
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: wrap-oth
|
|
||||||
:END:
|
|
||||||
|
|
||||||
** Without timegm (3) support our ISO time parser is not thread safe.
|
** Without timegm (3) support our ISO time parser is not thread safe.
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: time-threads
|
|
||||||
:END:
|
|
||||||
There is a configure time warning, though.
|
There is a configure time warning, though.
|
||||||
|
|
||||||
|
|
||||||
* New features:
|
* New features:
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: new-features
|
|
||||||
:END:
|
|
||||||
|
|
||||||
** Flow control for data objects.
|
** Flow control for data objects.
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: flow-control-is-not-a-euphemism-for-an-s-bend
|
|
||||||
:END:
|
|
||||||
Currently, gpgme_data_t objects are assumed to be blocking. To
|
Currently, gpgme_data_t objects are assumed to be blocking. To
|
||||||
break this assumption, we need either (A) a way for an user I/O
|
break this assumption, we need either (A) a way for an user I/O
|
||||||
callback to store the current operation in a continuation that can
|
callback to store the current operation in a continuation that can
|
||||||
@ -257,99 +61,49 @@ Hey Emacs, this is -*- org -*- mode!
|
|||||||
respective event loop. or (B) a way for gpgme data objects to be
|
respective event loop. or (B) a way for gpgme data objects to be
|
||||||
associated with a waitable object, that can be registered with the
|
associated with a waitable object, that can be registered with the
|
||||||
user event loop. Neither is particularly simple.
|
user event loop. Neither is particularly simple.
|
||||||
|
|
||||||
** Extended notation support. When gpg supports arbitrary binary
|
** Extended notation support. When gpg supports arbitrary binary
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: extended-notation
|
|
||||||
:END:
|
|
||||||
notation data, provide a user interface for that.
|
notation data, provide a user interface for that.
|
||||||
|
|
||||||
** notification system
|
** notification system
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: notification-system
|
|
||||||
:END:
|
|
||||||
We need a simple notification system, probably a simple callback
|
We need a simple notification system, probably a simple callback
|
||||||
with a string and some optional arguments. This is for example
|
with a string and some optional arguments. This is for example
|
||||||
required to notify an application of a changed smartcard, The
|
required to notify an application of a changed smartcard, The
|
||||||
application can then do whatever is required. There are other
|
application can then do whatever is required. There are other
|
||||||
usages too. This notification system should be independent of any
|
usages too. This notfication system should be independent of any
|
||||||
contextes of course.
|
contextes of course.
|
||||||
|
|
||||||
Not sure whether this is still required. GPGME_PROTOCOL_ASSUAN is
|
Not sure whether this is still required. GPGME_PROTOCOL_ASSUAN is
|
||||||
sufficient for this.
|
sufficient for this.
|
||||||
|
|
||||||
** --learn-code support
|
** --learn-code support
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: learn-code
|
|
||||||
:END:
|
|
||||||
This might be integrated with import. we still need to work out how
|
This might be integrated with import. we still need to work out how
|
||||||
to learn a card when gpg and gpgsm have support for smartcards. In
|
to learn a card when gpg and gpgsm have support for smartcards. In
|
||||||
GPA we currently invoke gpg directly.
|
GPA we currently invoke gpg directly.
|
||||||
|
|
||||||
** Might need a stat() for data objects and use it for length param to gpg.
|
** Might need a stat() for data objects and use it for length param to gpg.
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: stat-data
|
|
||||||
:END:
|
|
||||||
|
|
||||||
** Implement support for photo ids.
|
** Implement support for photo ids.
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: photo-id
|
|
||||||
:END:
|
|
||||||
|
|
||||||
** Allow selection of subkeys
|
** Allow selection of subkeys
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: subkey-selection
|
|
||||||
:END:
|
|
||||||
|
|
||||||
** Allow to return time stamps in ISO format
|
** Allow to return time stamps in ISO format
|
||||||
:PROPERTIES:
|
This allows us to handle years later than 2037 properly. With the
|
||||||
:CUSTOM_ID: iso-format-datetime
|
time_t interface they are all mapped to 2037-12-31
|
||||||
:END:
|
|
||||||
This allows us to handle years later than 2037 properly. With the
|
|
||||||
time_t interface they are all mapped to 2037-12-31
|
|
||||||
|
|
||||||
** New features requested by our dear users, but rejected or left for
|
** New features requested by our dear users, but rejected or left for
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: feature-requests
|
|
||||||
:END:
|
|
||||||
later consideration:
|
later consideration:
|
||||||
|
|
||||||
*** Allow to export secret keys.
|
*** Allow to export secret keys.
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: export-secret-keys
|
|
||||||
:END:
|
|
||||||
Rejected because this is conceptually flawed. Secret keys on a
|
Rejected because this is conceptually flawed. Secret keys on a
|
||||||
smart card can not be exported, for example.
|
smart card can not be exported, for example.
|
||||||
May eventually e supproted with a keywrapping system.
|
May eventually e supproted with a keywrapping system.
|
||||||
|
|
||||||
*** Selecting the key ring, setting the version or comment in output.
|
*** Selecting the key ring, setting the version or comment in output.
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: select-keyring-version
|
|
||||||
:END:
|
|
||||||
Rejected because the naive implementation is engine specific, the
|
Rejected because the naive implementation is engine specific, the
|
||||||
configuration is part of the engine's configuration or readily
|
configuration is part of the engine's configuration or readily
|
||||||
worked around in a different way
|
worked around in a different way
|
||||||
|
|
||||||
*** Selecting the symmetric cipher.
|
*** Selecting the symmetric cipher.
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: symmetric-cipher-selection
|
|
||||||
:END:
|
|
||||||
|
|
||||||
*** Exchanging keys with key servers.
|
*** Exchanging keys with key servers.
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: key-server-exchange
|
|
||||||
:END:
|
|
||||||
|
|
||||||
|
* Documentation
|
||||||
|
** Document validity and trust issues.
|
||||||
|
** In gpgme.texi: Register callbacks under the right letter in the index.
|
||||||
|
|
||||||
* Engines
|
* Engines
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: engines
|
|
||||||
:END:
|
|
||||||
|
|
||||||
** Do not create/destroy engines, but create engine and then reset it.
|
** Do not create/destroy engines, but create engine and then reset it.
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: reset-engine-is-not-quite-just-ignition
|
|
||||||
:END:
|
|
||||||
Internally the reset operation still spawns a new engine process,
|
Internally the reset operation still spawns a new engine process,
|
||||||
but this can be replaced with a reset later. Also, be very sure to
|
but this can be replaced with a reset later. Also, be very sure to
|
||||||
release everything properly at a reset and at an error. Think hard
|
release everything properly at a reset and at an error. Think hard
|
||||||
@ -358,255 +112,85 @@ Hey Emacs, this is -*- org -*- mode!
|
|||||||
Note that we need support in gpgsm to set include-certs to default
|
Note that we need support in gpgsm to set include-certs to default
|
||||||
as RESET does not reset it, also for no_encrypt_to and probably
|
as RESET does not reset it, also for no_encrypt_to and probably
|
||||||
other options.
|
other options.
|
||||||
|
|
||||||
** Optimize the case where a data object has an underlying fd we can pass
|
** Optimize the case where a data object has an underlying fd we can pass
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: optimus-data-cousin-of-optimus-prime
|
|
||||||
:END:
|
|
||||||
directly to the engine. This will be automatic with socket I/O and
|
directly to the engine. This will be automatic with socket I/O and
|
||||||
descriptor passing.
|
descriptor passing.
|
||||||
|
|
||||||
** Move code common to all engines up from gpg to engine.
|
** Move code common to all engines up from gpg to engine.
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: move-code-common-to-engines-out-of-gpg
|
|
||||||
:END:
|
|
||||||
|
|
||||||
** engine operations can return General Error on unknown protocol
|
** engine operations can return General Error on unknown protocol
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: general-error-looking-to-be-court-martialled
|
|
||||||
:END:
|
|
||||||
(it's an internal error, as select_protocol checks already).
|
(it's an internal error, as select_protocol checks already).
|
||||||
|
|
||||||
** When server mode is implemented properly, more care has to be taken to
|
** When server mode is implemented properly, more care has to be taken to
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: server-mode
|
|
||||||
:END:
|
|
||||||
release all resources on error (for example to free assuan_cmd).
|
release all resources on error (for example to free assuan_cmd).
|
||||||
|
** op_import_keys and op_export_keys have a limit ion the number of keys.
|
||||||
** op_import_keys and op_export_keys have a limit in the number of keys.
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: import-export-problems
|
|
||||||
:END:
|
|
||||||
This is because we pass them in gpg via the command line and gpgsm
|
This is because we pass them in gpg via the command line and gpgsm
|
||||||
via an assuan control line. We should pipe them instead and maybe
|
via an assuan control line. We should pipe them instead and maybe
|
||||||
change gpg/gpgsm to not put them in memory.
|
change gpg/gpgsm to not put them in memory.
|
||||||
|
|
||||||
|
|
||||||
* GPG breakage:
|
* GPG breakage:
|
||||||
:PROPERTIES:
|
** gpg 1.4.2 lacks error reporting if sign/encrypt with revoked key.
|
||||||
:CUSTOM_ID: gpg-breakage
|
** gpg 1.4.2 does crappy error reporting (namely none at all) when
|
||||||
:END:
|
|
||||||
|
|
||||||
** CANCELLED gpg 1.4.2 lacks error reporting if sign/encrypt with revoked key.
|
|
||||||
CLOSED: [2018-03-09 Fri 08:19]
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: gpg-classic-lacks-stuff
|
|
||||||
:END:
|
|
||||||
- State "CANCELLED" from "TODO" [2018-03-09 Fri 08:19] \\
|
|
||||||
WON'T FIX.
|
|
||||||
|
|
||||||
** CANCELLED gpg 1.4.2 does crappy error reporting (namely none at all) when
|
|
||||||
CLOSED: [2018-03-09 Fri 08:20]
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: gpg-classic-problems-but-do-we-care
|
|
||||||
:END:
|
|
||||||
- State "CANCELLED" from "TODO" [2018-03-09 Fri 08:20] \\
|
|
||||||
WON'T FIX.
|
|
||||||
smart card is missing for sign operation:
|
smart card is missing for sign operation:
|
||||||
[GNUPG:] CARDCTRL 4
|
[GNUPG:] CARDCTRL 4
|
||||||
gpg: selecting openpgp failed: ec=6.110
|
gpg: selecting openpgp failed: ec=6.110
|
||||||
gpg: signing failed: general error
|
gpg: signing failed: general error
|
||||||
[GNUPG:] BEGIN_ENCRYPTION 2 10
|
[GNUPG:] BEGIN_ENCRYPTION 2 10
|
||||||
gpg: test: sign+encrypt failed: general error
|
gpg: test: sign+encrypt failed: general error
|
||||||
|
** Without agent and with wrong passphrase, gpg 1.4.2 enters into an
|
||||||
** DONE Without agent and with wrong passphrase, gpg 1.4.2 enters into an
|
|
||||||
CLOSED: [2018-03-09 Fri 08:20]
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: recursive-gpg-classic
|
|
||||||
:END:
|
|
||||||
- State "DONE" from "TODO" [2018-03-09 Fri 08:20] \\
|
|
||||||
Must have been fixed in a subsequent release.
|
|
||||||
infinite loop.
|
infinite loop.
|
||||||
|
** Use correct argv[0]
|
||||||
** CANCELLED Use correct argv[0]
|
|
||||||
CLOSED: [2018-03-09 Fri 08:24]
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: correct-argv
|
|
||||||
:END:
|
|
||||||
- State "CANCELLED" from "TODO" [2018-03-09 Fri 08:24] \\
|
|
||||||
WON'T FIX.
|
|
||||||
|
|
||||||
Also, there is no rungpg.c file in GPGME (or in GPG or most, if not
|
|
||||||
all of the rest of the libs and packages; I suspect there hasn't been
|
|
||||||
for a very long time).
|
|
||||||
In rungpg.c:build_argv we use
|
In rungpg.c:build_argv we use
|
||||||
argv[argc] = strdup ("gpg"); /* argv[0] */
|
argv[argc] = strdup ("gpg"); /* argv[0] */
|
||||||
This should be changed to take the real file name used in account.
|
This should be changed to take the real file name used in account.
|
||||||
|
|
||||||
|
|
||||||
* Operations
|
* Operations
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: operations-are-not-surgical
|
|
||||||
:END:
|
|
||||||
|
|
||||||
** Include cert values -2, -1, 0 and 1 should be defined as macros.
|
** Include cert values -2, -1, 0 and 1 should be defined as macros.
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: certified-macros
|
|
||||||
:END:
|
|
||||||
|
|
||||||
** If an operation failed, make sure that the result functions don't return
|
** If an operation failed, make sure that the result functions don't return
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: operation-failure
|
|
||||||
:END:
|
|
||||||
corrupt partial information. !!!
|
corrupt partial information. !!!
|
||||||
NOTE: The EOF status handler is not called in this case !!!
|
NOTE: The EOF status handler is not called in this case !!!
|
||||||
|
|
||||||
** Verify must not fail on NODATA premature if auto-key-retrieval failed.
|
** Verify must not fail on NODATA premature if auto-key-retrieval failed.
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: autobot-key-retrieval
|
|
||||||
:END:
|
|
||||||
It should not fail silently if it knows there is an error. !!!
|
It should not fail silently if it knows there is an error. !!!
|
||||||
|
|
||||||
** All operations: Better error reporting. !!
|
** All operations: Better error reporting. !!
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: better-reporting-not-like-fox-news
|
|
||||||
:END:
|
|
||||||
|
|
||||||
** Export status handler need much more work. !!!
|
** Export status handler need much more work. !!!
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: export-status-handler
|
|
||||||
:END:
|
|
||||||
|
|
||||||
** Import should return a useful error when one happened.
|
** Import should return a useful error when one happened.
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: import-useful-stuff-even-wrong-stuff
|
|
||||||
:END:
|
|
||||||
|
|
||||||
*** Import does not take notice of NODATA status report.
|
*** Import does not take notice of NODATA status report.
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: import-no-data
|
|
||||||
:END:
|
|
||||||
|
|
||||||
*** When GPGSM does issue IMPORT_OK status reports, make sure to check for
|
*** When GPGSM does issue IMPORT_OK status reports, make sure to check for
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: gpgsm-import-ok
|
|
||||||
:END:
|
|
||||||
them in tests/gpgs m/t-import.c.
|
them in tests/gpgs m/t-import.c.
|
||||||
|
|
||||||
** Verify can include info about version/algo/class, but currently
|
** Verify can include info about version/algo/class, but currently
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: verify-class
|
|
||||||
:END:
|
|
||||||
this is only available for gpg, not gpgsm.
|
this is only available for gpg, not gpgsm.
|
||||||
|
|
||||||
** Return ENC_TO output in verify result. Again, this is not available
|
** Return ENC_TO output in verify result. Again, this is not available
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: return-to-enc
|
|
||||||
:END:
|
|
||||||
for gpgsm.
|
for gpgsm.
|
||||||
|
|
||||||
** Genkey should return something more useful than General_Error.
|
** Genkey should return something more useful than General_Error.
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: general-key-assumed-command-from-general-error
|
|
||||||
:END:
|
|
||||||
|
|
||||||
** If possible, use --file-setsize to set the file size for proper progress
|
** If possible, use --file-setsize to set the file size for proper progress
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: file-setsize
|
|
||||||
:END:
|
|
||||||
callback handling. Write data interface for file size.
|
callback handling. Write data interface for file size.
|
||||||
|
|
||||||
** Optimize the file descriptor list, so the number of open fds is
|
** Optimize the file descriptor list, so the number of open fds is
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: optimus-descriptus-younger-brother-of-optimus-prime
|
|
||||||
:END:
|
|
||||||
always known easily.
|
always known easily.
|
||||||
|
|
||||||
** Encryption: It should be verified that the behaviour for partially untrusted
|
** Encryption: It should be verified that the behaviour for partially untrusted
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: only-mostly-dead-means-partially-alive
|
|
||||||
:END:
|
|
||||||
recipients is correct.
|
recipients is correct.
|
||||||
|
|
||||||
** When GPG issues INV_something for invalid signers, catch them.
|
** When GPG issues INV_something for invalid signers, catch them.
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: invalid-sig
|
|
||||||
:END:
|
|
||||||
|
|
||||||
|
|
||||||
* Error Values
|
* Error Values
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: error-value
|
|
||||||
:END:
|
|
||||||
|
|
||||||
** Map ASSUAN/GpgSM ERR error values in a better way than is done now. !!
|
** Map ASSUAN/GpgSM ERR error values in a better way than is done now. !!
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: map-ass-error
|
|
||||||
:END:
|
|
||||||
|
|
||||||
** Some error values should identify the source more correctly (mostly error
|
** Some error values should identify the source more correctly (mostly error
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: source-errors
|
|
||||||
:END:
|
|
||||||
values derived from status messages).
|
values derived from status messages).
|
||||||
|
|
||||||
** In rungpg.c we need to check the version of the engine
|
** In rungpg.c we need to check the version of the engine
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: rungpg-c-engine-ver
|
|
||||||
:END:
|
|
||||||
This requires a way to get the cached version number from the
|
This requires a way to get the cached version number from the
|
||||||
engine layer.
|
engine layer.
|
||||||
|
|
||||||
|
|
||||||
* Tests
|
* Tests
|
||||||
:PROPERTIES:
|
** Write a fake gpg-agent so that we can supply known passphrases to
|
||||||
:CUSTOM_ID: tests
|
|
||||||
:END:
|
|
||||||
|
|
||||||
** TODO Write a fake gpg-agent so that we can supply known passphrases to
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: test-fake-gpg-agent
|
|
||||||
:END:
|
|
||||||
gpgsm and setup the configuration files to use the agent. Without
|
gpgsm and setup the configuration files to use the agent. Without
|
||||||
this we are testing a currently running gpg-agent which is not a
|
this we are testing a currently running gpg-agent which is not a
|
||||||
clever idea. !
|
clever idea. !
|
||||||
|
|
||||||
** t-data
|
** t-data
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: test-data
|
|
||||||
:END:
|
|
||||||
|
|
||||||
*** Test gpgme_data_release_and_get_mem.
|
*** Test gpgme_data_release_and_get_mem.
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: test-gpgme-data-release-mem
|
|
||||||
:END:
|
|
||||||
|
|
||||||
*** Test gpgme_data_seek for invalid types.
|
*** Test gpgme_data_seek for invalid types.
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: test-gpgme-data-seek
|
|
||||||
:END:
|
|
||||||
|
|
||||||
** t-keylist
|
** t-keylist
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: test-keylist
|
|
||||||
:END:
|
|
||||||
Write a test for ext_keylist.
|
Write a test for ext_keylist.
|
||||||
|
|
||||||
** Test reading key signatures.
|
** Test reading key signatures.
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: test-key-sig
|
|
||||||
:END:
|
|
||||||
|
|
||||||
|
|
||||||
* Debug
|
* Debug
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: debug
|
|
||||||
:END:
|
|
||||||
|
|
||||||
** Tracepoints should be added at: Every public interface enter/leave,
|
** Tracepoints should be added at: Every public interface enter/leave,
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: tracepoint-pub-int
|
|
||||||
:END:
|
|
||||||
before and in every callback, at major decision points, at every
|
before and in every callback, at major decision points, at every
|
||||||
internal data point which might easily be observed by the outside
|
internal data point which might easily be observed by the outside
|
||||||
(system handles). We also trace handles and I/O support threads in
|
(system handles). We also trace handles and I/O support threads in
|
||||||
@ -618,83 +202,21 @@ Hey Emacs, this is -*- org -*- mode!
|
|||||||
decrypt-verify.c delete.c edit.c encrypt.c encrypt-sign.c export.c
|
decrypt-verify.c delete.c edit.c encrypt.c encrypt-sign.c export.c
|
||||||
genkey.c import.c key.c keylist.c passphrase.c progress.c signers.c
|
genkey.c import.c key.c keylist.c passphrase.c progress.c signers.c
|
||||||
sig-notation.c trust-item.c trustlist.c verify.c
|
sig-notation.c trust-item.c trustlist.c verify.c
|
||||||
|
** Handle malloc and vasprintf errors. But decide first if they should be
|
||||||
** TODO Handle malloc and vasprintf errors. But decide first if they should be
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: malloc-vasprintf
|
|
||||||
:END:
|
|
||||||
|
|
||||||
ignored (and logged with 255?!), or really be assertions. !
|
ignored (and logged with 255?!), or really be assertions. !
|
||||||
|
|
||||||
|
|
||||||
* Build suite
|
* Build suite
|
||||||
:PROPERTIES:
|
** Make sure everything is cleaned correctly (esp. test area).
|
||||||
:CUSTOM_ID: build-suite
|
** Enable AC_CONFIG_MACRO_DIR and bump up autoconf version requirement.
|
||||||
:END:
|
|
||||||
|
|
||||||
** TODO Make sure everything is cleaned correctly (esp. test area).
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: clean-tests
|
|
||||||
:END:
|
|
||||||
|
|
||||||
** TODO Enable AC_CONFIG_MACRO_DIR and bump up autoconf version requirement.
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: autoconf-macros
|
|
||||||
:END:
|
|
||||||
(To fix "./autogen.sh; ./configure --enable-maintainer-mode; touch
|
(To fix "./autogen.sh; ./configure --enable-maintainer-mode; touch
|
||||||
configure.ac; make"). Currently worked around with ACLOCAL_AMFLAGS???
|
configure.ac; make"). Currently worked around with ACLOCAL_AMFLAGS???
|
||||||
|
|
||||||
|
|
||||||
* Error checking
|
* Error checking
|
||||||
:PROPERTIES:
|
** engine-gpgsm, with-validation
|
||||||
:CUSTOM_ID: error-checking
|
|
||||||
:END:
|
|
||||||
|
|
||||||
** TODO engine-gpgsm, with-validation
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: gpgsm-validation
|
|
||||||
:END:
|
|
||||||
Add error checking some time after releasing a new gpgsm.
|
Add error checking some time after releasing a new gpgsm.
|
||||||
|
|
||||||
|
|
||||||
* Language bindings and related components
|
Copyright 2004, 2005 g10 Code GmbH
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: language-bindings-and-related-stuff
|
|
||||||
:END:
|
|
||||||
|
|
||||||
** TODO Emacs and elisp binding
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: emacs-and-elisp
|
|
||||||
:END:
|
|
||||||
|
|
||||||
Currently GNU Emacs uses EPA and EPG to provide GnuPG support. EPG
|
|
||||||
does this by calling the GPG executable and wrapping the commands
|
|
||||||
with elisp functions. A more preferable solution would be to
|
|
||||||
implement an epgme.el which integrated with GPGME, then if it could
|
|
||||||
not to attempt calling the gpgme-tool and only if those failed to
|
|
||||||
fall back to the current epg.el and calling the command line
|
|
||||||
binaries.
|
|
||||||
|
|
||||||
** TODO API of an API
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: api-squared
|
|
||||||
:END:
|
|
||||||
|
|
||||||
See the more detailed notes on this in the [[lang/python/docs/TODO.org][python TODO]].
|
|
||||||
|
|
||||||
** TODO GPGME installation and package management guide
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: package-management
|
|
||||||
:END:
|
|
||||||
|
|
||||||
Write a guide/best practices for maintainers of GPGME packages with
|
|
||||||
third party package management systems.
|
|
||||||
|
|
||||||
|
|
||||||
* Copyright 2004, 2005, 2018 g10 Code GmbH
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: copyright-and-license
|
|
||||||
:END:
|
|
||||||
|
|
||||||
This file is free software; as a special exception the author gives
|
This file is free software; as a special exception the author gives
|
||||||
unlimited permission to copy and/or distribute it, with or without
|
unlimited permission to copy and/or distribute it, with or without
|
||||||
|
16
acinclude.m4
16
acinclude.m4
@ -58,19 +58,3 @@ AC_DEFUN([GNUPG_CHECK_VA_COPY],
|
|||||||
AC_MSG_RESULT($gnupg_cv_must_copy_va_byval)
|
AC_MSG_RESULT($gnupg_cv_must_copy_va_byval)
|
||||||
fi
|
fi
|
||||||
])
|
])
|
||||||
|
|
||||||
dnl LIST_MEMBER()
|
|
||||||
dnl Check whether an element ist contained in a list. Set `found' to
|
|
||||||
dnl `1' if the element is found in the list, to `0' otherwise.
|
|
||||||
AC_DEFUN([LIST_MEMBER],
|
|
||||||
[
|
|
||||||
name=$1
|
|
||||||
list=$2
|
|
||||||
found=0
|
|
||||||
|
|
||||||
for n in $list; do
|
|
||||||
if test "x$name" = "x$n"; then
|
|
||||||
found=1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
])
|
|
||||||
|
12
autogen.rc
12
autogen.rc
@ -2,13 +2,19 @@
|
|||||||
|
|
||||||
case "$myhost" in
|
case "$myhost" in
|
||||||
w32)
|
w32)
|
||||||
configure_opts=""
|
configure_opts="
|
||||||
|
--with-gpg-error-prefix=@SYSROOT@
|
||||||
|
--with-libassuan-prefix=@SYSROOT@
|
||||||
|
"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
amd64)
|
amd64)
|
||||||
configure_opts=""
|
configure_opts="
|
||||||
|
--with-gpg-error-prefix=@SYSROOT@
|
||||||
|
--with-libassuan-prefix=@SYSROOT@
|
||||||
|
"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
final_info="mkdir build && cd build && ../configure --enable-maintainer-mode && make"
|
final_info="./configure --enable-maintainer-mode && make"
|
||||||
|
187
autogen.sh
187
autogen.sh
@ -1,6 +1,6 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# autogen.sh
|
# autogen.sh
|
||||||
# Copyright (C) 2003, 2014, 2017, 2018, 2022 g10 Code GmbH
|
# Copyright (C) 2003, 2014 g10 Code GmbH
|
||||||
#
|
#
|
||||||
# This file is free software; as a special exception the author gives
|
# This file is free software; as a special exception the author gives
|
||||||
# unlimited permission to copy and/or distribute it, with or without
|
# unlimited permission to copy and/or distribute it, with or without
|
||||||
@ -15,7 +15,7 @@
|
|||||||
# configure it for the respective package. It is maintained as part of
|
# configure it for the respective package. It is maintained as part of
|
||||||
# GnuPG and source copied by other packages.
|
# GnuPG and source copied by other packages.
|
||||||
#
|
#
|
||||||
# Version: 2023-03-15
|
# Version: 2014-01-10
|
||||||
|
|
||||||
configure_ac="configure.ac"
|
configure_ac="configure.ac"
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ fatal () {
|
|||||||
|
|
||||||
info () {
|
info () {
|
||||||
if [ -z "${SILENT}" ]; then
|
if [ -z "${SILENT}" ]; then
|
||||||
echo "autogen.sh:" "$*" >&2
|
echo "autogen.sh:" "$*"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,8 +70,6 @@ MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX}
|
|||||||
DIE=no
|
DIE=no
|
||||||
FORCE=
|
FORCE=
|
||||||
SILENT=
|
SILENT=
|
||||||
PRINT_HOST=no
|
|
||||||
PRINT_BUILD=no
|
|
||||||
tmp=$(dirname "$0")
|
tmp=$(dirname "$0")
|
||||||
tsdir=$(cd "${tmp}"; pwd)
|
tsdir=$(cd "${tmp}"; pwd)
|
||||||
|
|
||||||
@ -79,18 +77,7 @@ if [ -n "${AUTOGEN_SH_SILENT}" ]; then
|
|||||||
SILENT=" --silent"
|
SILENT=" --silent"
|
||||||
fi
|
fi
|
||||||
if test x"$1" = x"--help"; then
|
if test x"$1" = x"--help"; then
|
||||||
echo "usage: ./autogen.sh [OPTIONS] [ARGS]"
|
echo "usage: ./autogen.sh [--silent] [--force] [--build-TYPE] [ARGS]"
|
||||||
echo " Options:"
|
|
||||||
echo " --silent Silent operation"
|
|
||||||
echo " --force Pass --force to autoconf"
|
|
||||||
echo " --find-version Helper for configure.ac"
|
|
||||||
echo " --git-build Run all commands to build from a Git"
|
|
||||||
echo " --print-host Print only the host triplet"
|
|
||||||
echo " --print-build Print only the build platform triplet"
|
|
||||||
echo " --build-TYPE Configure to cross build for TYPE"
|
|
||||||
echo ""
|
|
||||||
echo " ARGS are passed to configure in --build-TYPE mode."
|
|
||||||
echo " Configuration for this script is expected in autogen.rc"
|
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
if test x"$1" = x"--silent"; then
|
if test x"$1" = x"--silent"; then
|
||||||
@ -101,14 +88,6 @@ if test x"$1" = x"--force"; then
|
|||||||
FORCE=" --force"
|
FORCE=" --force"
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
if test x"$1" = x"--print-host"; then
|
|
||||||
PRINT_HOST=yes
|
|
||||||
shift
|
|
||||||
fi
|
|
||||||
if test x"$1" = x"--print-build"; then
|
|
||||||
PRINT_BUILD=yes
|
|
||||||
shift
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# Reject unsafe characters in $HOME, $tsdir and cwd. We consider spaces
|
# Reject unsafe characters in $HOME, $tsdir and cwd. We consider spaces
|
||||||
@ -137,6 +116,8 @@ extraoptions=
|
|||||||
# List of optional variables sourced from autogen.rc and ~/.gnupg-autogen.rc
|
# List of optional variables sourced from autogen.rc and ~/.gnupg-autogen.rc
|
||||||
w32_toolprefixes=
|
w32_toolprefixes=
|
||||||
w32_extraoptions=
|
w32_extraoptions=
|
||||||
|
w32ce_toolprefixes=
|
||||||
|
w32ce_extraoptions=
|
||||||
w64_toolprefixes=
|
w64_toolprefixes=
|
||||||
w64_extraoptions=
|
w64_extraoptions=
|
||||||
amd64_toolprefixes=
|
amd64_toolprefixes=
|
||||||
@ -144,6 +125,7 @@ amd64_toolprefixes=
|
|||||||
# What follows are variables which are sourced but default to
|
# What follows are variables which are sourced but default to
|
||||||
# environment variables or lacking them hardcoded values.
|
# environment variables or lacking them hardcoded values.
|
||||||
#w32root=
|
#w32root=
|
||||||
|
#w32ce_root=
|
||||||
#w64root=
|
#w64root=
|
||||||
#amd64root=
|
#amd64root=
|
||||||
|
|
||||||
@ -151,19 +133,15 @@ amd64_toolprefixes=
|
|||||||
myhost=""
|
myhost=""
|
||||||
myhostsub=""
|
myhostsub=""
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--find-version)
|
|
||||||
myhost="find-version"
|
|
||||||
SILENT=" --silent"
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
--git-build)
|
|
||||||
myhost="git-build"
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
--build-w32)
|
--build-w32)
|
||||||
myhost="w32"
|
myhost="w32"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--build-w32ce)
|
||||||
|
myhost="w32"
|
||||||
|
myhostsub="ce"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
--build-w64)
|
--build-w64)
|
||||||
myhost="w32"
|
myhost="w32"
|
||||||
myhostsub="64"
|
myhostsub="64"
|
||||||
@ -183,25 +161,6 @@ esac
|
|||||||
die_p
|
die_p
|
||||||
|
|
||||||
|
|
||||||
# **** GIT BUILD ****
|
|
||||||
# This is a helper to build from git.
|
|
||||||
if [ "$myhost" = "git-build" ]; then
|
|
||||||
tmp="$(pwd)"
|
|
||||||
cd "$tsdir" || fatal "error cd-ing to $tsdir"
|
|
||||||
./autogen.sh || fatal "error running ./autogen.sh"
|
|
||||||
cd "$tmp" || fatal "error cd-ing back to $tmp"
|
|
||||||
die_p
|
|
||||||
"$tsdir"/configure || fatal "error running $tsdir/configure"
|
|
||||||
die_p
|
|
||||||
make || fatal "error running make"
|
|
||||||
die_p
|
|
||||||
make check || fatal "error running make check"
|
|
||||||
die_p
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
# **** end GIT BUILD ****
|
|
||||||
|
|
||||||
|
|
||||||
# Source our configuration
|
# Source our configuration
|
||||||
if [ -f "${tsdir}/autogen.rc" ]; then
|
if [ -f "${tsdir}/autogen.rc" ]; then
|
||||||
. "${tsdir}/autogen.rc"
|
. "${tsdir}/autogen.rc"
|
||||||
@ -213,90 +172,23 @@ if [ -f "$HOME/.gnupg-autogen.rc" ]; then
|
|||||||
. "$HOME/.gnupg-autogen.rc"
|
. "$HOME/.gnupg-autogen.rc"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# **** FIND VERSION ****
|
|
||||||
# This is a helper for the configure.ac M4 magic
|
|
||||||
# Called
|
|
||||||
# ./autogen.sh --find-version PACKAGE MAJOR MINOR [MICRO]
|
|
||||||
# returns a complete version string with automatic beta numbering.
|
|
||||||
if [ "$myhost" = "find-version" ]; then
|
|
||||||
package="$1"
|
|
||||||
major="$2"
|
|
||||||
minor="$3"
|
|
||||||
micro="$4"
|
|
||||||
|
|
||||||
if [ -z "$package" -o -z "$major" -o -z "$minor" ]; then
|
|
||||||
echo "usage: ./autogen.sh --find-version PACKAGE MAJOR MINOR [MICRO]" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$micro" ]; then
|
|
||||||
matchstr1="$package-$major.[0-9]*"
|
|
||||||
matchstr2="$package-$major-base"
|
|
||||||
matchstr3=""
|
|
||||||
vers="$major.$minor"
|
|
||||||
else
|
|
||||||
matchstr1="$package-$major.$minor.[0-9]*"
|
|
||||||
matchstr2="$package-$major.[0-9]*-base"
|
|
||||||
matchstr3="$package-$major-base"
|
|
||||||
vers="$major.$minor.$micro"
|
|
||||||
fi
|
|
||||||
|
|
||||||
beta=no
|
|
||||||
if [ -e .git ]; then
|
|
||||||
ingit=yes
|
|
||||||
tmp=$(git describe --match "${matchstr1}" --long 2>/dev/null)
|
|
||||||
if [ -n "$tmp" ]; then
|
|
||||||
tmp=$(echo "$tmp" | sed s/^"$package"// \
|
|
||||||
| awk -F- '$3!=0 && $3 !~ /^beta/ {print"-beta"$3}')
|
|
||||||
else
|
|
||||||
# (due tof "-base" in the tag we need to take the 4th field)
|
|
||||||
tmp=$(git describe --match "${matchstr2}" --long 2>/dev/null)
|
|
||||||
if [ -n "$tmp" ]; then
|
|
||||||
tmp=$(echo "$tmp" | sed s/^"$package"// \
|
|
||||||
| awk -F- '$4!=0 && $4 !~ /^beta/ {print"-beta"$4}')
|
|
||||||
elif [ -n "${matchstr3}" ]; then
|
|
||||||
tmp=$(git describe --match "${matchstr3}" --long 2>/dev/null)
|
|
||||||
if [ -n "$tmp" ]; then
|
|
||||||
tmp=$(echo "$tmp" | sed s/^"$package"// \
|
|
||||||
| awk -F- '$4!=0 && $4 !~ /^beta/ {print"-beta"$4}')
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
[ -n "$tmp" ] && beta=yes
|
|
||||||
rev=$(git rev-parse --short HEAD | tr -d '\n\r')
|
|
||||||
rvd=$((0x$(echo ${rev} | dd bs=1 count=4 2>/dev/null)))
|
|
||||||
else
|
|
||||||
ingit=no
|
|
||||||
beta=yes
|
|
||||||
tmp="-unknown"
|
|
||||||
rev="0000000"
|
|
||||||
rvd="0"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "$package-$vers$tmp:$beta:$ingit:$vers$tmp:$vers:$tmp:$rev:$rvd:"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
# **** end FIND VERSION ****
|
|
||||||
|
|
||||||
|
|
||||||
if [ ! -f "$tsdir/build-aux/config.guess" ]; then
|
|
||||||
fatal "$tsdir/build-aux/config.guess not found"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
build=`$tsdir/build-aux/config.guess`
|
|
||||||
if [ $PRINT_BUILD = yes ]; then
|
|
||||||
echo "$build"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ******************
|
# ******************
|
||||||
# W32 build script
|
# W32 build script
|
||||||
# ******************
|
# ******************
|
||||||
if [ "$myhost" = "w32" ]; then
|
if [ "$myhost" = "w32" ]; then
|
||||||
|
if [ ! -f "$tsdir/build-aux/config.guess" ]; then
|
||||||
|
fatal "$tsdir/build-aux/config.guess not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
build=`$tsdir/build-aux/config.guess`
|
||||||
|
|
||||||
case $myhostsub in
|
case $myhostsub in
|
||||||
|
ce)
|
||||||
|
w32root="$w32ce_root"
|
||||||
|
[ -z "$w32root" ] && w32root="$HOME/w32ce_root"
|
||||||
|
toolprefixes="$w32ce_toolprefixes arm-mingw32ce"
|
||||||
|
extraoptions="$extraoptions $w32ce_extraoptions"
|
||||||
|
;;
|
||||||
64)
|
64)
|
||||||
w32root="$w64root"
|
w32root="$w64root"
|
||||||
[ -z "$w32root" ] && w32root="$HOME/w64root"
|
[ -z "$w32root" ] && w32root="$HOME/w64root"
|
||||||
@ -330,10 +222,6 @@ if [ "$myhost" = "w32" ]; then
|
|||||||
fi
|
fi
|
||||||
die_p
|
die_p
|
||||||
fi
|
fi
|
||||||
if [ $PRINT_HOST = yes ]; then
|
|
||||||
echo "$host"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f "$tsdir/config.log" ]; then
|
if [ -f "$tsdir/config.log" ]; then
|
||||||
if ! head $tsdir/config.log | grep "$host" >/dev/null; then
|
if ! head $tsdir/config.log | grep "$host" >/dev/null; then
|
||||||
@ -344,8 +232,7 @@ if [ "$myhost" = "w32" ]; then
|
|||||||
|
|
||||||
$tsdir/configure --enable-maintainer-mode ${SILENT} \
|
$tsdir/configure --enable-maintainer-mode ${SILENT} \
|
||||||
--prefix=${w32root} \
|
--prefix=${w32root} \
|
||||||
--host=${host} --build=${build} SYSROOT=${w32root} \
|
--host=${host} --build=${build} \
|
||||||
PKG_CONFIG_LIBDIR=${w32root}/lib/pkgconfig \
|
|
||||||
${configure_opts} ${extraoptions} "$@"
|
${configure_opts} ${extraoptions} "$@"
|
||||||
rc=$?
|
rc=$?
|
||||||
exit $rc
|
exit $rc
|
||||||
@ -355,6 +242,13 @@ fi
|
|||||||
# ***** AMD64 cross build script *******
|
# ***** AMD64 cross build script *******
|
||||||
# Used to cross-compile for AMD64 (for testing)
|
# Used to cross-compile for AMD64 (for testing)
|
||||||
if [ "$myhost" = "amd64" ]; then
|
if [ "$myhost" = "amd64" ]; then
|
||||||
|
shift
|
||||||
|
if [ ! -f $tsdir/build-aux/config.guess ]; then
|
||||||
|
echo "$tsdir/build-aux/config.guess not found" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
build=`$tsdir/build-aux/config.guess`
|
||||||
|
|
||||||
[ -z "$amd64root" ] && amd64root="$HOME/amd64root"
|
[ -z "$amd64root" ] && amd64root="$HOME/amd64root"
|
||||||
info "Using $amd64root as standard install directory"
|
info "Using $amd64root as standard install directory"
|
||||||
replace_sysroot
|
replace_sysroot
|
||||||
@ -375,10 +269,6 @@ if [ "$myhost" = "amd64" ]; then
|
|||||||
echo "Stop." >&2
|
echo "Stop." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [ $PRINT_HOST = yes ]; then
|
|
||||||
echo "$host"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f "$tsdir/config.log" ]; then
|
if [ -f "$tsdir/config.log" ]; then
|
||||||
if ! head $tsdir/config.log | grep "$host" >/dev/null; then
|
if ! head $tsdir/config.log | grep "$host" >/dev/null; then
|
||||||
@ -451,16 +341,13 @@ fi
|
|||||||
|
|
||||||
# Check the git setup.
|
# Check the git setup.
|
||||||
if [ -d .git ]; then
|
if [ -d .git ]; then
|
||||||
CP="cp -p"
|
CP="cp -a"
|
||||||
# If we have a GNU cp we can add -v
|
[ -z "${SILENT}" ] && CP="$CP -v"
|
||||||
if cp --version >/dev/null 2>/dev/null; then
|
|
||||||
[ -z "${SILENT}" ] && CP="$CP -v"
|
|
||||||
fi
|
|
||||||
if [ -f .git/hooks/pre-commit.sample -a ! -f .git/hooks/pre-commit ] ; then
|
if [ -f .git/hooks/pre-commit.sample -a ! -f .git/hooks/pre-commit ] ; then
|
||||||
[ -z "${SILENT}" ] && cat <<EOF
|
[ -z "${SILENT}" ] && cat <<EOF
|
||||||
*** Activating trailing whitespace git pre-commit hook. ***
|
*** Activating trailing whitespace git pre-commit hook. ***
|
||||||
For more information see this thread:
|
For more information see this thread:
|
||||||
https://mail.gnome.org/archives/desktop-devel-list/2009-May/msg00084.html
|
http://mail.gnome.org/archives/desktop-devel-list/2009-May/msg00084html
|
||||||
To deactivate this pre-commit hook again move .git/hooks/pre-commit
|
To deactivate this pre-commit hook again move .git/hooks/pre-commit
|
||||||
and .git/hooks/pre-commit.sample out of the way.
|
and .git/hooks/pre-commit.sample out of the way.
|
||||||
EOF
|
EOF
|
||||||
@ -484,10 +371,6 @@ EOF
|
|||||||
EOF
|
EOF
|
||||||
$CP build-aux/git-hooks/commit-msg .git/hooks/commit-msg
|
$CP build-aux/git-hooks/commit-msg .git/hooks/commit-msg
|
||||||
chmod +x .git/hooks/commit-msg
|
chmod +x .git/hooks/commit-msg
|
||||||
if [ x"${display_name}" != x ]; then
|
|
||||||
git config format.subjectPrefix "PATCH ${display_name}"
|
|
||||||
git config sendemail.to "${patches_to}"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ scriptversion=2012-10-14.11; # UTC
|
|||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# As a special exception to the GNU General Public License, if you
|
# As a special exception to the GNU General Public License, if you
|
||||||
# distribute this file as part of a program that contains a
|
# distribute this file as part of a program that contains a
|
||||||
|
1691
build-aux/config.guess
vendored
1691
build-aux/config.guess
vendored
File diff suppressed because it is too large
Load Diff
2899
build-aux/config.sub
vendored
2899
build-aux/config.sub
vendored
File diff suppressed because it is too large
Load Diff
@ -16,7 +16,7 @@ scriptversion=2013-05-30.07; # UTC
|
|||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# As a special exception to the GNU General Public License, if you
|
# As a special exception to the GNU General Public License, if you
|
||||||
# distribute this file as part of a program that contains a
|
# distribute this file as part of a program that contains a
|
||||||
|
@ -1,68 +0,0 @@
|
|||||||
#
|
|
||||||
# This is a sed script to patch the generated libtool,
|
|
||||||
# which works well against both of libtool 2.4.2 and 2.4.7.
|
|
||||||
#
|
|
||||||
# You may use this work under the terms of a Creative Commons CC0 1.0
|
|
||||||
# License/Waiver.
|
|
||||||
#
|
|
||||||
# CC0 Public Domain Dedication
|
|
||||||
# https://creativecommons.org/publicdomain/zero/1.0/
|
|
||||||
|
|
||||||
#
|
|
||||||
# This sed script applys two hunks of the patch:
|
|
||||||
#
|
|
||||||
# Part1: after the comment "# bleh windows"
|
|
||||||
# Part2: after the comment "#extension on DOS 8.3..."
|
|
||||||
#
|
|
||||||
# Only when those two parts are patched correctly, it exits with 0 or
|
|
||||||
# else, it exits with 1
|
|
||||||
#
|
|
||||||
|
|
||||||
# Find the part 1, by the comment
|
|
||||||
/^[ \t]*# bleh windows$/b part1_start
|
|
||||||
# Not found the part1, raise an error
|
|
||||||
$ q1
|
|
||||||
b
|
|
||||||
|
|
||||||
:part1_start
|
|
||||||
n
|
|
||||||
# The first line in the part 1 must be the begining of the case statement.
|
|
||||||
/^[ \t]*case \$host in$/! q1
|
|
||||||
n
|
|
||||||
# Insert the entry for x86_64-*mingw32*, for modified versuffix.
|
|
||||||
i\
|
|
||||||
x86_64-*mingw32*)
|
|
||||||
i\
|
|
||||||
func_arith $current - $age
|
|
||||||
i\
|
|
||||||
major=$func_arith_result
|
|
||||||
i\
|
|
||||||
versuffix="6-$major"
|
|
||||||
i\
|
|
||||||
;;
|
|
||||||
:part1_0
|
|
||||||
# Find the end of the case statement
|
|
||||||
/^[ \t]*esac$/b find_part2
|
|
||||||
# Not found the end of the case statement, raise an error
|
|
||||||
$ q1
|
|
||||||
n
|
|
||||||
b part1_0
|
|
||||||
|
|
||||||
:find_part2
|
|
||||||
/^[ \t]*# extension on DOS 8.3 file.*systems.$/b part2_process
|
|
||||||
# Not found the part2, raise an error
|
|
||||||
$ q1
|
|
||||||
n
|
|
||||||
b find_part2
|
|
||||||
|
|
||||||
:part2_process
|
|
||||||
$ q1
|
|
||||||
s/^[ \t]*\(versuffix=\)\(.*\)\(-$major\)\(.*\)$/\t case \$host in\n\t x86_64-*mingw32*)\n\t \1\26\3\4\n\t ;;\n\t *)\n\t \1\2\3\4\n\t ;;\n\t esac/
|
|
||||||
t part2_done
|
|
||||||
n
|
|
||||||
b part2_process
|
|
||||||
|
|
||||||
:part2_done
|
|
||||||
$ q0
|
|
||||||
n
|
|
||||||
b part2_done
|
|
@ -24,7 +24,7 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with GNU Libtool; see the file COPYING. If not, a copy
|
# along with GNU Libtool; see the file COPYING. If not, a copy
|
||||||
# can be downloaded from https://www.gnu.org/licenses/gpl.html,
|
# can be downloaded from http://www.gnu.org/licenses/gpl.html,
|
||||||
# or obtained by writing to the Free Software Foundation, Inc.,
|
# or obtained by writing to the Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
@ -75,8 +75,8 @@
|
|||||||
# autoconf: $autoconf_version
|
# autoconf: $autoconf_version
|
||||||
#
|
#
|
||||||
# Report bugs to <bug-libtool@gnu.org>.
|
# Report bugs to <bug-libtool@gnu.org>.
|
||||||
# GNU libtool home page: <https://www.gnu.org/software/libtool/>.
|
# GNU libtool home page: <http://www.gnu.org/software/libtool/>.
|
||||||
# General help using GNU software: <https://www.gnu.org/gethelp/>.
|
# General help using GNU software: <http://www.gnu.org/gethelp/>.
|
||||||
|
|
||||||
PROGRAM=libtool
|
PROGRAM=libtool
|
||||||
PACKAGE=libtool
|
PACKAGE=libtool
|
||||||
|
@ -18,7 +18,7 @@ scriptversion=2010-08-21.06; # UTC
|
|||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# As a special exception to the GNU General Public License, if you
|
# As a special exception to the GNU General Public License, if you
|
||||||
# distribute this file as part of a program that contains a
|
# distribute this file as part of a program that contains a
|
||||||
|
@ -17,7 +17,7 @@ scriptversion=2013-10-28.13; # UTC
|
|||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
|
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# As a special exception to the GNU General Public License, if you
|
# As a special exception to the GNU General Public License, if you
|
||||||
# distribute this file as part of a program that contains a
|
# distribute this file as part of a program that contains a
|
||||||
@ -103,7 +103,7 @@ fi
|
|||||||
|
|
||||||
perl_URL=http://www.perl.org/
|
perl_URL=http://www.perl.org/
|
||||||
flex_URL=http://flex.sourceforge.net/
|
flex_URL=http://flex.sourceforge.net/
|
||||||
gnu_software_URL=https://www.gnu.org/software
|
gnu_software_URL=http://www.gnu.org/software
|
||||||
|
|
||||||
program_details ()
|
program_details ()
|
||||||
{
|
{
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
% General Public License for more details.
|
% General Public License for more details.
|
||||||
%
|
%
|
||||||
% You should have received a copy of the GNU General Public License
|
% You should have received a copy of the GNU General Public License
|
||||||
% along with this program. If not, see <https://www.gnu.org/licenses/>.
|
% along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
%
|
%
|
||||||
% As a special exception, when this file is read by TeX when processing
|
% As a special exception, when this file is read by TeX when processing
|
||||||
% a Texinfo source document, you may use the result without
|
% a Texinfo source document, you may use the result without
|
||||||
@ -31,7 +31,7 @@
|
|||||||
% reports; you can get the latest version from:
|
% reports; you can get the latest version from:
|
||||||
% http://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or
|
% http://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or
|
||||||
% http://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or
|
% http://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or
|
||||||
% https://www.gnu.org/software/texinfo/ (the Texinfo home page)
|
% http://www.gnu.org/software/texinfo/ (the Texinfo home page)
|
||||||
% The texinfo.tex in any given distribution could well be out
|
% The texinfo.tex in any given distribution could well be out
|
||||||
% of date, so if that's what you're using, please check.
|
% of date, so if that's what you're using, please check.
|
||||||
%
|
%
|
||||||
@ -55,7 +55,7 @@
|
|||||||
% extent. You can get the existing language-specific files from the
|
% extent. You can get the existing language-specific files from the
|
||||||
% full Texinfo distribution.
|
% full Texinfo distribution.
|
||||||
%
|
%
|
||||||
% The GNU Texinfo home page is https://www.gnu.org/software/texinfo.
|
% The GNU Texinfo home page is http://www.gnu.org/software/texinfo.
|
||||||
|
|
||||||
|
|
||||||
\message{Loading texinfo [version \texinfoversion]:}
|
\message{Loading texinfo [version \texinfoversion]:}
|
||||||
@ -482,7 +482,7 @@
|
|||||||
% \def\foo{\parsearg\Xfoo}
|
% \def\foo{\parsearg\Xfoo}
|
||||||
% \def\Xfoo#1{...}
|
% \def\Xfoo#1{...}
|
||||||
%
|
%
|
||||||
% Actually, I use \csname\string\foo\endcsname, i.e. \\foo, as it is my
|
% Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my
|
||||||
% favourite TeX trick. --kasal, 16nov03
|
% favourite TeX trick. --kasal, 16nov03
|
||||||
|
|
||||||
\def\parseargdef#1{%
|
\def\parseargdef#1{%
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
Configuration files may go here. Note that config.h.in is
|
|
||||||
auto-generated so that this file is not in git.
|
|
809
configure.ac
809
configure.ac
File diff suppressed because it is too large
Load Diff
49
contrib/ChangeLog-2011
Normal file
49
contrib/ChangeLog-2011
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
2011-12-02 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
|
NB: ChangeLog files are no longer manually maintained. Starting
|
||||||
|
on December 1st, 2011 we put change information only in the GIT
|
||||||
|
commit log, and generate a top-level ChangeLog file from logs at
|
||||||
|
"make dist". See doc/HACKING for details.
|
||||||
|
|
||||||
|
2010-11-15 Marcus Brinkmann <mb@g10code.com>
|
||||||
|
|
||||||
|
* conf-w32ce-msc/fcntl.h: New file.
|
||||||
|
* conf-w32ce-msc/build.mk (conf_sources): Add fnctl.h.
|
||||||
|
(sources): Remove memrchr.c.
|
||||||
|
|
||||||
|
* conf-w32ce-msc/io.h: New file.
|
||||||
|
* conf-w32ce-msc/build.mk (conf_sources): Add io.h.
|
||||||
|
|
||||||
|
* conf-w32ce-msc/stdint.h: New file.
|
||||||
|
* conf-w32ce-msc/build.mk (conf_sources): Add stdint.h.
|
||||||
|
* conf-w32ce-msc/build.mk (copy-static-source): Revert last change.
|
||||||
|
|
||||||
|
2010-11-15 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
|
* conf-w32ce-msc/build.mk (copy-static-source): Create stdint.h.
|
||||||
|
(all): Add ws2.lib
|
||||||
|
(clean): New.
|
||||||
|
|
||||||
|
2010-11-04 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
|
* conf-w32ce-msc/build.mk (copy-built-source): Revert last
|
||||||
|
change. Does not work with W32CE where MSC defines it in except.h.
|
||||||
|
|
||||||
|
2010-11-03 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
|
* conf-w32ce-msc/build.mk (copy-built-source): Create dummy sehmap.h.
|
||||||
|
|
||||||
|
2010-11-01 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
|
* conf-w32ce-msc/config.h: New.
|
||||||
|
* conf-w32ce-msc/build.mk: New.
|
||||||
|
|
||||||
|
Copyright (C) 2010 g10 Code GmbH
|
||||||
|
|
||||||
|
This file is free software; as a special exception the author gives
|
||||||
|
unlimited permission to copy and/or distribute it, with or without
|
||||||
|
modifications, as long as this notice is preserved.
|
||||||
|
|
||||||
|
This file 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.
|
256
contrib/conf-w32ce-msc/build.mk
Executable file
256
contrib/conf-w32ce-msc/build.mk
Executable file
@ -0,0 +1,256 @@
|
|||||||
|
# build.mk - Makefile to build libgpg-error using Visual-C
|
||||||
|
# Copyright 2010 g10 Code GmbH
|
||||||
|
#
|
||||||
|
# This file is free software; as a special exception the author gives
|
||||||
|
# unlimited permission to copy and/or distribute it, with or without
|
||||||
|
# modifications, as long as this notice is preserved.
|
||||||
|
#
|
||||||
|
# This file 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.
|
||||||
|
|
||||||
|
# This is a helper make script to build libgpg-error for WindowsCE
|
||||||
|
# using the Microsoft Visual C compiler.
|
||||||
|
|
||||||
|
targetdir = /home/smb/xppro-gnu/src/gpgme/src
|
||||||
|
# The target build directory where we run the Visual C compiler/ This
|
||||||
|
# needs to be an absolute directory name. Further we expect this
|
||||||
|
# structure of the tree:
|
||||||
|
#
|
||||||
|
# TARGET/src - Source directories: One directory for each project
|
||||||
|
# /bin - Installed DLLs
|
||||||
|
# /lib - Installed import libs.
|
||||||
|
# /include - Instaled header files.
|
||||||
|
|
||||||
|
targetdir = /home/smb/xppro-gnu
|
||||||
|
targetsrc = $(targetdir)/src
|
||||||
|
|
||||||
|
# Install directories (relative)
|
||||||
|
bindir = ../../../bin
|
||||||
|
libdir = ../../../lib
|
||||||
|
incdir = ../../../include
|
||||||
|
|
||||||
|
|
||||||
|
help:
|
||||||
|
@echo "Run "
|
||||||
|
@echo " make -f ../contrib/conf-w32ce-msc/build.mk copy-source"
|
||||||
|
@echo "on the POSIX system and then"
|
||||||
|
@echo " nmake -f build.mk all"
|
||||||
|
@echo " nmake -f build.mk install"
|
||||||
|
@echo "on the Windows system"
|
||||||
|
|
||||||
|
ce_defines = -DWINCE -D_WIN32_WCE=0x502 -DUNDER_CE \
|
||||||
|
-DWIN32_PLATFORM_PSPC -D_UNICODE -DUNICODE \
|
||||||
|
-D_CONSOLE -DARM -D_ARM_
|
||||||
|
#-D_DEBUG -DDEBUG
|
||||||
|
|
||||||
|
CFLAGS = -nologo -W3 -fp:fast -Os $(ce_defines) \
|
||||||
|
-DHAVE_CONFIG_H -DDLL_EXPORT -D_CRT_SECURE_NO_WARNINGS \
|
||||||
|
-I. -I$(incdir) -I$(incdir)/gpg-extra
|
||||||
|
|
||||||
|
LDFLAGS =
|
||||||
|
|
||||||
|
# Standard source files
|
||||||
|
sources = \
|
||||||
|
assuan-support.c \
|
||||||
|
ath-pth.c \
|
||||||
|
ath-pthread.c \
|
||||||
|
ath.c \
|
||||||
|
ath.h \
|
||||||
|
context.h \
|
||||||
|
conversion.c \
|
||||||
|
data-compat.c \
|
||||||
|
data-fd.c \
|
||||||
|
data-mem.c \
|
||||||
|
data-stream.c \
|
||||||
|
data-user.c \
|
||||||
|
data.c \
|
||||||
|
data.h \
|
||||||
|
debug.c \
|
||||||
|
debug.h \
|
||||||
|
decrypt-verify.c \
|
||||||
|
decrypt.c \
|
||||||
|
delete.c \
|
||||||
|
dirinfo.c \
|
||||||
|
edit.c \
|
||||||
|
encrypt-sign.c \
|
||||||
|
encrypt.c \
|
||||||
|
engine-assuan.c \
|
||||||
|
engine-backend.h \
|
||||||
|
engine-g13.c \
|
||||||
|
engine-gpg.c \
|
||||||
|
engine-gpgconf.c \
|
||||||
|
engine-gpgsm.c \
|
||||||
|
engine-uiserver.c \
|
||||||
|
engine.c \
|
||||||
|
engine.h \
|
||||||
|
error.c \
|
||||||
|
export.c \
|
||||||
|
funopen.c \
|
||||||
|
genkey.c \
|
||||||
|
get-env.c \
|
||||||
|
getauditlog.c \
|
||||||
|
gpgconf.c \
|
||||||
|
gpgme-tool.c \
|
||||||
|
gpgme-w32spawn.c \
|
||||||
|
gpgme.c \
|
||||||
|
import.c \
|
||||||
|
isascii.c \
|
||||||
|
kdpipeiodevice.h \
|
||||||
|
key.c \
|
||||||
|
keylist.c \
|
||||||
|
op-support.c \
|
||||||
|
opassuan.c \
|
||||||
|
ops.h \
|
||||||
|
passphrase.c \
|
||||||
|
passwd.c \
|
||||||
|
priv-io.h \
|
||||||
|
progress.c \
|
||||||
|
putc_unlocked.c \
|
||||||
|
sema.h \
|
||||||
|
setenv.c \
|
||||||
|
sig-notation.c \
|
||||||
|
sign.c \
|
||||||
|
signers.c \
|
||||||
|
stpcpy.c \
|
||||||
|
trust-item.c \
|
||||||
|
trustlist.c \
|
||||||
|
ttyname_r.c \
|
||||||
|
util.h \
|
||||||
|
vasprintf.c \
|
||||||
|
verify.c \
|
||||||
|
version.c \
|
||||||
|
vfs-create.c \
|
||||||
|
vfs-mount.c \
|
||||||
|
w32-ce.c \
|
||||||
|
w32-ce.h \
|
||||||
|
w32-glib-io.c \
|
||||||
|
w32-io.c \
|
||||||
|
w32-sema.c \
|
||||||
|
w32-util.c \
|
||||||
|
wait-global.c \
|
||||||
|
wait-private.c \
|
||||||
|
wait-user.c \
|
||||||
|
wait.c \
|
||||||
|
wait.h \
|
||||||
|
gpgme.def
|
||||||
|
|
||||||
|
# The object files we need to create from sources.
|
||||||
|
objs = \
|
||||||
|
conversion.obj \
|
||||||
|
get-env.obj \
|
||||||
|
data.obj \
|
||||||
|
data-fd.obj \
|
||||||
|
data-stream.obj \
|
||||||
|
data-mem.obj \
|
||||||
|
data-user.obj \
|
||||||
|
data-compat.obj \
|
||||||
|
signers.obj \
|
||||||
|
sig-notation.obj \
|
||||||
|
wait.obj \
|
||||||
|
wait-global.obj \
|
||||||
|
wait-private.obj \
|
||||||
|
wait-user.obj \
|
||||||
|
op-support.obj \
|
||||||
|
encrypt.obj \
|
||||||
|
encrypt-sign.obj \
|
||||||
|
decrypt.obj \
|
||||||
|
decrypt-verify.obj \
|
||||||
|
verify.obj \
|
||||||
|
sign.obj \
|
||||||
|
passphrase.obj \
|
||||||
|
progress.obj \
|
||||||
|
key.obj \
|
||||||
|
keylist.obj \
|
||||||
|
trust-item.obj \
|
||||||
|
trustlist.obj \
|
||||||
|
import.obj \
|
||||||
|
export.obj \
|
||||||
|
genkey.obj \
|
||||||
|
delete.obj \
|
||||||
|
edit.obj \
|
||||||
|
getauditlog.obj \
|
||||||
|
opassuan.obj \
|
||||||
|
passwd.obj \
|
||||||
|
engine.obj \
|
||||||
|
engine-gpg.obj \
|
||||||
|
engine-gpgsm.obj \
|
||||||
|
assuan-support.obj \
|
||||||
|
engine-assuan.obj \
|
||||||
|
engine-gpgconf.obj \
|
||||||
|
engine-g13.obj \
|
||||||
|
vfs-mount.obj \
|
||||||
|
vfs-create.obj \
|
||||||
|
gpgconf.obj \
|
||||||
|
w32-ce.obj \
|
||||||
|
w32-util.obj \
|
||||||
|
w32-sema.obj \
|
||||||
|
w32-io.obj \
|
||||||
|
dirinfo.obj \
|
||||||
|
debug.obj \
|
||||||
|
gpgme.obj \
|
||||||
|
version.obj \
|
||||||
|
error.obj \
|
||||||
|
ath.obj \
|
||||||
|
vasprintf.obj \
|
||||||
|
ttyname_r.obj \
|
||||||
|
stpcpy.obj \
|
||||||
|
setenv.obj
|
||||||
|
|
||||||
|
|
||||||
|
# Sources files in this directory inclduing this Makefile
|
||||||
|
conf_sources = \
|
||||||
|
build.mk \
|
||||||
|
config.h \
|
||||||
|
stdint.h io.h fcntl.h
|
||||||
|
|
||||||
|
# Source files built by running the standard build system.
|
||||||
|
built_sources = \
|
||||||
|
gpgme.h \
|
||||||
|
status-table.h
|
||||||
|
|
||||||
|
copy-static-source:
|
||||||
|
@if [ ! -f ./gpgme.c ]; then \
|
||||||
|
echo "Please cd to the src/ directory first"; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
cp -t $(targetsrc)/gpgme/src $(sources);
|
||||||
|
cd ../contrib/conf-w32ce-msc ; \
|
||||||
|
cp -t $(targetsrc)/gpgme/src $(conf_sources)
|
||||||
|
|
||||||
|
copy-built-source:
|
||||||
|
@if [ ! -f ./gpgme.h ]; then \
|
||||||
|
echo "Please build using ./autogen.sh --build-w32ce first"; \
|
||||||
|
exit 1; \
|
||||||
|
fi
|
||||||
|
cp -t $(targetsrc)/gpgme/src $(built_sources)
|
||||||
|
|
||||||
|
copy-source: copy-static-source copy-built-source
|
||||||
|
|
||||||
|
|
||||||
|
.c.obj:
|
||||||
|
$(CC) $(CFLAGS) -c $<
|
||||||
|
|
||||||
|
all: $(sources) $(conf_sources) $(built_sources) $(objs)
|
||||||
|
link /DLL /IMPLIB:libgpgme-11-msc.lib \
|
||||||
|
/OUT:libgpgme-11-msc.dll \
|
||||||
|
/DEF:gpgme.def /NOLOGO /MANIFEST:NO \
|
||||||
|
/NODEFAULTLIB:"oldnames.lib" /DYNAMICBASE:NO \
|
||||||
|
$(objs) \
|
||||||
|
$(libdir)/libgpg-error-0-msc.lib \
|
||||||
|
$(libdir)/libassuan-0-msc.lib \
|
||||||
|
coredll.lib corelibc.lib ole32.lib oleaut32.lib uuid.lib \
|
||||||
|
commctrl.lib ws2.lib /subsystem:windowsce,5.02
|
||||||
|
|
||||||
|
# Note that we don't need to create the install directories because
|
||||||
|
# libgpg-error must have been build and installed prior to this
|
||||||
|
# package.
|
||||||
|
install: all
|
||||||
|
copy /y gpgme.h $(incdir:/=\)
|
||||||
|
copy /y libgpgme-11-msc.dll $(bindir:/=\)
|
||||||
|
copy /y libgpgme-11-msc.lib $(libdir:/=\)
|
||||||
|
|
||||||
|
|
||||||
|
clean:
|
||||||
|
del *.obj libgpgme-11-msc.lib libgpgme-11-msc.dll libgpgme-11-msc.exp
|
||||||
|
|
314
contrib/conf-w32ce-msc/config.h
Normal file
314
contrib/conf-w32ce-msc/config.h
Normal file
@ -0,0 +1,314 @@
|
|||||||
|
/* config.h for building with Visual-C for WindowsCE.
|
||||||
|
* Copyright 2010 g10 Code GmbH
|
||||||
|
*
|
||||||
|
* This file is free software; as a special exception the author gives
|
||||||
|
* unlimited permission to copy and/or distribute it, with or without
|
||||||
|
* modifications, as long as this notice is preserved.
|
||||||
|
*
|
||||||
|
* This file 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This file was originally created by running
|
||||||
|
* ./autogen.sh --build-w32ce
|
||||||
|
* on svn revision 1495 (gpgme 1.3.1-svn1495) and then adjusted to work
|
||||||
|
* with Visual-C.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Define to the version of this package. */
|
||||||
|
#define PACKAGE_VERSION "1.3.1-svn1495-msc1"
|
||||||
|
|
||||||
|
/* Name of this package */
|
||||||
|
#define PACKAGE "gpgme"
|
||||||
|
|
||||||
|
/* Define to the address where bug reports for this package should be sent. */
|
||||||
|
#define PACKAGE_BUGREPORT "bug-gpgme@gnupg.org"
|
||||||
|
|
||||||
|
/* Define to the full name of this package. */
|
||||||
|
#define PACKAGE_NAME "gpgme"
|
||||||
|
|
||||||
|
/* Define to the full name and version of this package. */
|
||||||
|
#define PACKAGE_STRING "gpgme " PACKAGE_VERSION
|
||||||
|
|
||||||
|
/* Define to the one symbol short name of this package. */
|
||||||
|
#define PACKAGE_TARNAME "gpgme"
|
||||||
|
|
||||||
|
/* Define to the home page for this package. */
|
||||||
|
#define PACKAGE_URL ""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Whether Assuan support is enabled */
|
||||||
|
#define ENABLE_ASSUAN 1
|
||||||
|
|
||||||
|
/* Whether G13 support is enabled */
|
||||||
|
#define ENABLE_G13 1
|
||||||
|
|
||||||
|
/* Whether GPGCONF support is enabled */
|
||||||
|
#define ENABLE_GPGCONF 1
|
||||||
|
|
||||||
|
/* Whether GPGSM support is enabled */
|
||||||
|
#define ENABLE_GPGSM 1
|
||||||
|
|
||||||
|
/* Defined if we are building with uiserver support. */
|
||||||
|
/* #undef ENABLE_UISERVER */
|
||||||
|
|
||||||
|
/* Path to the G13 binary. */
|
||||||
|
#define G13_PATH "c:\\gnupg\\g13.exe"
|
||||||
|
|
||||||
|
/* Path to the GPGCONF binary. */
|
||||||
|
#define GPGCONF_PATH "c:\\gnupg\\gpgconf.exe"
|
||||||
|
|
||||||
|
/* version of the libassuan library */
|
||||||
|
#define GPGME_LIBASSUAN_VERSION "2.0.2-svn381"
|
||||||
|
|
||||||
|
/* Path to the GPGSM binary. */
|
||||||
|
#define GPGSM_PATH "c:\\gnupg\\gpgsm.exe"
|
||||||
|
|
||||||
|
/* The default error source for GPGME. */
|
||||||
|
#define GPG_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_GPGME
|
||||||
|
|
||||||
|
/* Path to the GnuPG binary. */
|
||||||
|
#define GPG_PATH "c:\\gnupg\\gpg.exe"
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||||
|
/* #undef HAVE_DLFCN_H */
|
||||||
|
|
||||||
|
/* Defined if we run on some of the PCDOS like systems (DOS, Windoze. OS/2)
|
||||||
|
with special properties like no file modes */
|
||||||
|
#define HAVE_DOSISH_SYSTEM 1
|
||||||
|
|
||||||
|
/* Define to 1 if the system has the type `error_t'. */
|
||||||
|
/* #undef HAVE_ERROR_T */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `fopencookie' function. */
|
||||||
|
/* #undef HAVE_FOPENCOOKIE */
|
||||||
|
|
||||||
|
/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
|
||||||
|
/* #undef HAVE_FSEEKO */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `funopen' function. */
|
||||||
|
/* #undef HAVE_FUNOPEN */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `getegid' function. */
|
||||||
|
/* #undef HAVE_GETEGID */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `getenv_r' function. */
|
||||||
|
/* #undef HAVE_GETENV_R */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `getgid' function. */
|
||||||
|
/* #undef HAVE_GETGID */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||||
|
#define HAVE_INTTYPES_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <locale.h> header file. */
|
||||||
|
/* #undef HAVE_LOCALE_H */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <memory.h> header file. */
|
||||||
|
#define HAVE_MEMORY_H 1
|
||||||
|
|
||||||
|
/* Define if we have Pth. */
|
||||||
|
/* #undef HAVE_PTH */
|
||||||
|
|
||||||
|
/* Define if we have pthread. */
|
||||||
|
/* #undef HAVE_PTHREAD */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `setenv' function. */
|
||||||
|
/* #undef HAVE_SETENV */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `setlocale' function. */
|
||||||
|
/* #undef HAVE_SETLOCALE */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdint.h> header file. */
|
||||||
|
#define HAVE_STDINT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||||
|
#define HAVE_STDLIB_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `stpcpy' function. */
|
||||||
|
/* #undef HAVE_STPCPY */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <strings.h> header file. */
|
||||||
|
/* #undef HAVE_STRINGS_H */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <string.h> header file. */
|
||||||
|
#define HAVE_STRING_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/select.h> header file. */
|
||||||
|
/* #undef HAVE_SYS_SELECT_H */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||||
|
/* #undef HAVE_SYS_STAT_H */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||||
|
/* #undef HAVE_SYS_TYPES_H */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/uio.h> header file. */
|
||||||
|
/* #undef HAVE_SYS_UIO_H */
|
||||||
|
|
||||||
|
/* Define if getenv() is thread-safe */
|
||||||
|
/* #undef HAVE_THREAD_SAFE_GETENV */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `timegm' function. */
|
||||||
|
/* #undef HAVE_TIMEGM */
|
||||||
|
|
||||||
|
/* Define if __thread is supported */
|
||||||
|
/* #define HAVE_TLS 1 */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `ttyname_r' function. */
|
||||||
|
/* #undef HAVE_TTYNAME_R */
|
||||||
|
|
||||||
|
/* Define to 1 if the system has the type `uintptr_t'. */
|
||||||
|
#define HAVE_UINTPTR_T 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <unistd.h> header file. */
|
||||||
|
/* #define HAVE_UNISTD_H 1 */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `vasprintf' function. */
|
||||||
|
/* #undef HAVE_VASPRINTF */
|
||||||
|
|
||||||
|
/* Defined if we run on a W32 CE API based system */
|
||||||
|
#define HAVE_W32CE_SYSTEM 1
|
||||||
|
|
||||||
|
/* Defined if we run on a W32 API based system */
|
||||||
|
#define HAVE_W32_SYSTEM 1
|
||||||
|
|
||||||
|
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||||
|
*/
|
||||||
|
#define LT_OBJDIR ".libs/"
|
||||||
|
|
||||||
|
/* used to implement the va_copy macro */
|
||||||
|
/* #undef MUST_COPY_VA_BYVAL */
|
||||||
|
|
||||||
|
/* Min. needed G13 version. */
|
||||||
|
#define NEED_G13_VERSION "2.1.0"
|
||||||
|
|
||||||
|
/* Min. needed GPGCONF version. */
|
||||||
|
#define NEED_GPGCONF_VERSION "2.0.4"
|
||||||
|
|
||||||
|
/* Min. needed GPGSM version. */
|
||||||
|
#define NEED_GPGSM_VERSION "1.9.6"
|
||||||
|
|
||||||
|
/* Min. needed GnuPG version. */
|
||||||
|
#define NEED_GPG_VERSION "1.4.0"
|
||||||
|
|
||||||
|
|
||||||
|
/* Separators as used in $PATH. */
|
||||||
|
#ifdef HAVE_DOSISH_SYSTEM
|
||||||
|
#define PATHSEP_C ';'
|
||||||
|
#else
|
||||||
|
#define PATHSEP_C ':'
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* The size of `unsigned int', as computed by sizeof. */
|
||||||
|
#define SIZEOF_UNSIGNED_INT 4
|
||||||
|
|
||||||
|
/* Define to 1 if you have the ANSI C header files. */
|
||||||
|
#define STDC_HEADERS 1
|
||||||
|
|
||||||
|
/* Defined if descriptor passing is enabled and supported */
|
||||||
|
/* #undef USE_DESCRIPTOR_PASSING */
|
||||||
|
|
||||||
|
/* Enable extensions on AIX 3, Interix. */
|
||||||
|
#ifndef _ALL_SOURCE
|
||||||
|
# define _ALL_SOURCE 1
|
||||||
|
#endif
|
||||||
|
/* Enable GNU extensions on systems that have them. */
|
||||||
|
#ifndef _GNU_SOURCE
|
||||||
|
# define _GNU_SOURCE 1
|
||||||
|
#endif
|
||||||
|
/* Enable threading extensions on Solaris. */
|
||||||
|
#ifndef _POSIX_PTHREAD_SEMANTICS
|
||||||
|
# define _POSIX_PTHREAD_SEMANTICS 1
|
||||||
|
#endif
|
||||||
|
/* Enable extensions on HP NonStop. */
|
||||||
|
#ifndef _TANDEM_SOURCE
|
||||||
|
# define _TANDEM_SOURCE 1
|
||||||
|
#endif
|
||||||
|
/* Enable general extensions on Solaris. */
|
||||||
|
#ifndef __EXTENSIONS__
|
||||||
|
# define __EXTENSIONS__ 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Version of this package */
|
||||||
|
#define VERSION PACKAGE_VERSION
|
||||||
|
|
||||||
|
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||||
|
/* #undef _FILE_OFFSET_BITS */
|
||||||
|
|
||||||
|
/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
|
||||||
|
/* #undef _LARGEFILE_SOURCE */
|
||||||
|
|
||||||
|
/* Define for large files, on AIX-style hosts. */
|
||||||
|
/* #undef _LARGE_FILES */
|
||||||
|
|
||||||
|
/* Define to 1 if on MINIX. */
|
||||||
|
/* #undef _MINIX */
|
||||||
|
|
||||||
|
/* Define to 2 if the system does not provide POSIX.1 features except with
|
||||||
|
this defined. */
|
||||||
|
/* #undef _POSIX_1_SOURCE */
|
||||||
|
|
||||||
|
/* Define to 1 if you need to in order for `stat' and other things to work. */
|
||||||
|
/* #undef _POSIX_SOURCE */
|
||||||
|
|
||||||
|
/* To allow the use of GPGME in multithreaded programs we have to use
|
||||||
|
special features from the library.
|
||||||
|
IMPORTANT: gpgme is not yet fully reentrant and you should use it
|
||||||
|
only from one thread. */
|
||||||
|
#ifndef _REENTRANT
|
||||||
|
# define _REENTRANT 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Activate POSIX interface on MacOS X */
|
||||||
|
/* #undef _XOPEN_SOURCE */
|
||||||
|
|
||||||
|
/* Define to a type to use for `error_t' if it is not otherwise available. */
|
||||||
|
#define error_t int
|
||||||
|
|
||||||
|
/* Define to `__inline__' or `__inline' if that's what the C compiler
|
||||||
|
calls it, or to nothing if 'inline' is not supported under any name. */
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#define inline __inline
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Define to `long int' if <sys/types.h> does not define. */
|
||||||
|
/* #undef off_t */
|
||||||
|
|
||||||
|
/* Define to the type of an unsigned integer type wide enough to hold a
|
||||||
|
pointer, if such a type exists, and if the system does not define it. */
|
||||||
|
/* #undef uintptr_t */
|
||||||
|
|
||||||
|
|
||||||
|
/* Definition of GCC specific attributes. */
|
||||||
|
#if __GNUC__ > 2
|
||||||
|
# define GPGME_GCC_A_PURE __attribute__ ((__pure__))
|
||||||
|
#else
|
||||||
|
# define GPGME_GCC_A_PURE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Under WindowsCE we need gpg-error's strerror macro. */
|
||||||
|
#define GPG_ERR_ENABLE_ERRNO_MACROS 1
|
||||||
|
|
||||||
|
/* snprintf is not part of oldnames.lib thus we redefine it here. */
|
||||||
|
#define snprintf _snprintf
|
||||||
|
|
||||||
|
/* We don't want warnings like this:
|
||||||
|
|
||||||
|
warning C4996: e.g. "The POSIX name for this item is
|
||||||
|
deprecated. Instead, use the ISO C++ conformant name: _fileno"
|
||||||
|
|
||||||
|
warning C4018: '<' : signed/unsigned mismatch
|
||||||
|
|
||||||
|
warning C4244: '=' : conversion from 'time_t' to
|
||||||
|
'unsigned long', possible loss of data
|
||||||
|
|
||||||
|
*/
|
||||||
|
#pragma warning(disable:4996 4018 4244)
|
||||||
|
|
||||||
|
|
||||||
|
|
1
contrib/conf-w32ce-msc/fcntl.h
Executable file
1
contrib/conf-w32ce-msc/fcntl.h
Executable file
@ -0,0 +1 @@
|
|||||||
|
/* Dummy fcntl.h header. */
|
2
contrib/conf-w32ce-msc/io.h
Executable file
2
contrib/conf-w32ce-msc/io.h
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
/* Dummy io.h header. */
|
||||||
|
|
9
contrib/conf-w32ce-msc/stdint.h
Executable file
9
contrib/conf-w32ce-msc/stdint.h
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
typedef unsigned long long uint64_t;
|
||||||
|
typedef long long int64_t;
|
||||||
|
typedef unsigned int uint32_t;
|
||||||
|
typedef int int32_t;
|
||||||
|
typedef unsigned short uint16_t;
|
||||||
|
typedef short int16_t;
|
||||||
|
typedef unsigned int uintptr_t;
|
||||||
|
typedef int intptr_t;
|
||||||
|
|
@ -397,7 +397,7 @@
|
|||||||
(Listing Keys): Update examples.
|
(Listing Keys): Update examples.
|
||||||
(Decrypt): Result might also be available when operation failed.
|
(Decrypt): Result might also be available when operation failed.
|
||||||
(Verify): Result might also be available when operation failed.
|
(Verify): Result might also be available when operation failed.
|
||||||
All spotted by Stéphane Corthésy.
|
All spotted by Stéphane Corthésy.
|
||||||
|
|
||||||
2003-07-22 Marcus Brinkmann <marcus@g10code.de>
|
2003-07-22 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
@ -700,7 +700,7 @@
|
|||||||
|
|
||||||
2002-05-26 Marcus Brinkmann <marcus@g10code.de>
|
2002-05-26 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
* gpgme.texi: Some typographical corrections throughout.
|
* gpgme.texi: Some typographical correctons throughout.
|
||||||
|
|
||||||
2002-05-09 Marcus Brinkmann <marcus@g10code.de>
|
2002-05-09 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
@ -720,7 +720,7 @@
|
|||||||
* gpgme.texi (Manipulating Data Buffers): Changed some data types
|
* gpgme.texi (Manipulating Data Buffers): Changed some data types
|
||||||
to void*.
|
to void*.
|
||||||
(Protocol Selection): Added gpgme_get_protocol.
|
(Protocol Selection): Added gpgme_get_protocol.
|
||||||
(Verify): Updated to include the new attribute functions and
|
(Verify): Updated to include the new attribute fucntions and
|
||||||
status codes.
|
status codes.
|
||||||
|
|
||||||
2002-04-27 Werner Koch <wk@gnupg.org>
|
2002-04-27 Werner Koch <wk@gnupg.org>
|
||||||
@ -839,7 +839,7 @@
|
|||||||
2002-01-29 Marcus Brinkmann <marcus@g10code.de>
|
2002-01-29 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
* gpgme.texi (Run Control): New section.
|
* gpgme.texi (Run Control): New section.
|
||||||
(Verify): Document gpgme_get_notation.
|
(Verify): Docuent gpgme_get_notation.
|
||||||
(More Information): New section describing gpgme_get_op_info.
|
(More Information): New section describing gpgme_get_op_info.
|
||||||
|
|
||||||
2002-01-22 Marcus Brinkmann <marcus@g10code.de>
|
2002-01-22 Marcus Brinkmann <marcus@g10code.de>
|
||||||
@ -865,7 +865,7 @@
|
|||||||
|
|
||||||
* gpgme.texi (Top): Complete detailmenu.
|
* gpgme.texi (Top): Complete detailmenu.
|
||||||
|
|
||||||
* gpgme.texi: Convert embarrassing cruft to the real thing.
|
* gpgme.texi: Convert embarassing cruft to the real thing.
|
||||||
|
|
||||||
2002-01-16 Marcus Brinkmann <marcus@g10code.de>
|
2002-01-16 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
@ -14,45 +14,18 @@
|
|||||||
# Public License for more details.
|
# Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
# License along with this program; if not, see <https://gnu.org/licenses/>.
|
# License along with this program; if not, write to the Free Software
|
||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
|
|
||||||
## Process this file with automake to produce Makefile.in
|
## Process this file with automake to produce Makefile.in
|
||||||
|
|
||||||
DISTCLEANFILES = gpgme.tmp
|
DISTCLEANFILES = gpgme.tmp
|
||||||
CLEANFILES = mkdefsinc defs.inc
|
|
||||||
|
|
||||||
EXTRA_DIST = module-overview.sk HACKING DCO ChangeLog-2011 \
|
|
||||||
mkdefsinc.c defsincdate \
|
|
||||||
examples/gpgme-mozilla.json examples/gpgme-chrome.json
|
|
||||||
|
|
||||||
BUILT_SOURCES = defsincdate defs.inc
|
|
||||||
|
|
||||||
|
EXTRA_DIST = module-overview.sk HACKING DCO ChangeLog-2011
|
||||||
|
|
||||||
info_TEXINFOS = gpgme.texi
|
info_TEXINFOS = gpgme.texi
|
||||||
gpgme_TEXINFOS = uiserver.texi lesser.texi gpl.texi
|
gpgme_TEXINFOS = uiserver.texi lesser.texi gpl.texi
|
||||||
|
|
||||||
gpgme.texi : defs.inc
|
|
||||||
|
|
||||||
mkdefsinc: mkdefsinc.c Makefile $(top_builddir)/conf/config.h
|
|
||||||
$(CC_FOR_BUILD) -I. -I$(top_builddir)/conf -I$(srcdir) \
|
|
||||||
$(AM_CPPFLAGS) -o $@ $(srcdir)/mkdefsinc.c
|
|
||||||
|
|
||||||
dist-hook: defsincdate
|
|
||||||
|
|
||||||
defsincdate: $(gpgme_TEXINFOS)
|
|
||||||
: >defsincdate ; \
|
|
||||||
if test -e $(top_srcdir)/.git; then \
|
|
||||||
(cd $(srcdir) && git log -1 --format='%ct' -- \
|
|
||||||
$(info_TEXINFOS) $(gpgme_TEXINFOS) 2>/dev/null) >>defsincdate; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
defs.inc: defsincdate Makefile mkdefsinc
|
|
||||||
incd="`test -f defsincdate || echo '$(srcdir)/'`defsincdate"; \
|
|
||||||
./mkdefsinc -C $(srcdir) --date "`cat $$incd 2>/dev/null`" \
|
|
||||||
$(info_TEXINFOS) $(gpgme_TEXINFOS) >$@
|
|
||||||
|
|
||||||
|
|
||||||
online: gpgme.html gpgme.pdf
|
online: gpgme.html gpgme.pdf
|
||||||
set -e; \
|
set -e; \
|
||||||
echo "Uploading current manuals to www.gnupg.org ..."; \
|
echo "Uploading current manuals to www.gnupg.org ..."; \
|
||||||
@ -60,3 +33,4 @@ online: gpgme.html gpgme.pdf
|
|||||||
(cd gpgme.html && rsync -vr --exclude='.svn' . \
|
(cd gpgme.html && rsync -vr --exclude='.svn' . \
|
||||||
$${user}@ftp.gnupg.org:webspace/manuals/gpgme/ ); \
|
$${user}@ftp.gnupg.org:webspace/manuals/gpgme/ ); \
|
||||||
rsync -v gpgme.pdf $${user}@ftp.gnupg.org:webspace/manuals/
|
rsync -v gpgme.pdf $${user}@ftp.gnupg.org:webspace/manuals/
|
||||||
|
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "gpgmejson",
|
|
||||||
"description": "Integration with GnuPG",
|
|
||||||
"path": "/usr/bin/gpgme-json",
|
|
||||||
"type": "stdio",
|
|
||||||
"allowed_origins": [
|
|
||||||
"chrome-extension://kajibbejlbohfaggdiogboambcijhkke/"
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "gpgmejson",
|
|
||||||
"description": "Integration with GnuPG",
|
|
||||||
"path": "/usr/bin/gpgme-json",
|
|
||||||
"type": "stdio",
|
|
||||||
"allowed_extensions": [
|
|
||||||
"jid1-AQqSMBYb0a8ADg@jetpack"
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
/* show-group-options.c - Example code to retrieve the group option.
|
/* show-group-options.c - Example code to retriev the group option.
|
||||||
Copyright (C) 2008 g10 Code GmbH
|
Copyright (C) 2008 g10 Code GmbH
|
||||||
|
|
||||||
This file is part of GPGME.
|
This file is part of GPGME.
|
||||||
@ -14,7 +14,7 @@
|
|||||||
Lesser General Public License for more details.
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
You should have received a copy of the GNU Lesser General Public
|
||||||
License along with this program; if not, see <https://www.gnu.org/licenses/>.
|
License along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
4749
doc/gpgme.texi
4749
doc/gpgme.texi
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,7 @@
|
|||||||
@c This file is intended to be included in another file.
|
@c This file is intended to be included in another file.
|
||||||
|
|
||||||
@display
|
@display
|
||||||
Copyright @copyright{} 2007 Free Software Foundation, Inc. @url{https://fsf.org/}
|
Copyright @copyright{} 2007 Free Software Foundation, Inc. @url{http://fsf.org/}
|
||||||
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies of this
|
Everyone is permitted to copy and distribute verbatim copies of this
|
||||||
license document, but changing it is not allowed.
|
license document, but changing it is not allowed.
|
||||||
@ -696,7 +696,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|||||||
General Public License for more details.
|
General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see @url{https://www.gnu.org/licenses/}.
|
along with this program. If not, see @url{http://www.gnu.org/licenses/}.
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
@ -722,11 +722,11 @@ use an ``about box''.
|
|||||||
You should also get your employer (if you work as a programmer) or school,
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
if any, to sign a ``copyright disclaimer'' for the program, if necessary.
|
if any, to sign a ``copyright disclaimer'' for the program, if necessary.
|
||||||
For more information on this, and how to apply and follow the GNU GPL, see
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
@url{https://www.gnu.org/licenses/}.
|
@url{http://www.gnu.org/licenses/}.
|
||||||
|
|
||||||
The GNU General Public License does not permit incorporating your
|
The GNU General Public License does not permit incorporating your
|
||||||
program into proprietary programs. If your program is a subroutine
|
program into proprietary programs. If your program is a subroutine
|
||||||
library, you may consider it more useful to permit linking proprietary
|
library, you may consider it more useful to permit linking proprietary
|
||||||
applications with the library. If this is what you want to do, use
|
applications with the library. If this is what you want to do, use
|
||||||
the GNU Lesser General Public License instead of this License. But
|
the GNU Lesser General Public License instead of this License. But
|
||||||
first, please read @url{https://www.gnu.org/philosophy/why-not-lgpl.html}.
|
first, please read @url{http://www.gnu.org/philosophy/why-not-lgpl.html}.
|
||||||
|
310
doc/mkdefsinc.c
310
doc/mkdefsinc.c
@ -1,310 +0,0 @@
|
|||||||
/* mkdefsinc.c - Tool to create defs.inc
|
|
||||||
* Copyright (C) 2015 g10 Code GmbH
|
|
||||||
*
|
|
||||||
* This file is free software; as a special exception the author gives
|
|
||||||
* unlimited permission to copy and/or distribute it, with or without
|
|
||||||
* modifications, as long as this notice is preserved.
|
|
||||||
*
|
|
||||||
* This file 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* This tool needs to be build with command line supplied -D options
|
|
||||||
for the various directory variables. It is easier to do this in
|
|
||||||
build file than to use fragile make rules and a template file. */
|
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#define PGM "mkdefsinc"
|
|
||||||
|
|
||||||
/* We include config.h after all include files because the config.h
|
|
||||||
values are not valid for the build platform but we need some values
|
|
||||||
nevertheless. */
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
|
|
||||||
static int verbose;
|
|
||||||
|
|
||||||
|
|
||||||
/* The usual free wrapper. */
|
|
||||||
static void
|
|
||||||
xfree (void *a)
|
|
||||||
{
|
|
||||||
if (a)
|
|
||||||
free (a);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static char *
|
|
||||||
xmalloc (size_t n)
|
|
||||||
{
|
|
||||||
char *p;
|
|
||||||
|
|
||||||
p = malloc (n);
|
|
||||||
if (!p)
|
|
||||||
{
|
|
||||||
fputs (PGM ": out of core\n", stderr);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static char *
|
|
||||||
xstrdup (const char *string)
|
|
||||||
{
|
|
||||||
char *p;
|
|
||||||
|
|
||||||
p = xmalloc (strlen (string)+1);
|
|
||||||
strcpy (p, string);
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Return a malloced string with the last modification date of the
|
|
||||||
FILES. Returns NULL on error. */
|
|
||||||
static char *
|
|
||||||
get_date_from_files (char **files)
|
|
||||||
{
|
|
||||||
const char *file;
|
|
||||||
const char *usedfile = NULL;
|
|
||||||
struct stat sb;
|
|
||||||
struct tm *tp;
|
|
||||||
int errors = 0;
|
|
||||||
time_t stamp = 0;
|
|
||||||
char *result;
|
|
||||||
|
|
||||||
for (; (file = *files); files++)
|
|
||||||
{
|
|
||||||
if (!*file || !strcmp (file, ".") || !strcmp (file, ".."))
|
|
||||||
continue;
|
|
||||||
if (stat (file, &sb))
|
|
||||||
{
|
|
||||||
fprintf (stderr, PGM ": stat failed for '%s': %s\n",
|
|
||||||
file, strerror (errno));
|
|
||||||
errors = 1;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (sb.st_mtime > stamp)
|
|
||||||
{
|
|
||||||
stamp = sb.st_mtime;
|
|
||||||
usedfile = file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (errors)
|
|
||||||
exit (1);
|
|
||||||
|
|
||||||
if (usedfile)
|
|
||||||
fprintf (stderr, PGM ": taking date from '%s'\n", usedfile);
|
|
||||||
|
|
||||||
tp = gmtime (&stamp);
|
|
||||||
if (!tp)
|
|
||||||
return NULL;
|
|
||||||
result = xmalloc (4+1+2+1+2+1);
|
|
||||||
snprintf (result, 4+1+2+1+2+1, "%04d-%02d-%02d",
|
|
||||||
tp->tm_year + 1900, tp->tm_mon+1, tp->tm_mday);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* We need to escape file names for Texinfo. */
|
|
||||||
static void
|
|
||||||
print_filename (const char *prefix, const char *name)
|
|
||||||
{
|
|
||||||
const char *s;
|
|
||||||
|
|
||||||
fputs (prefix, stdout);
|
|
||||||
for (s=name; *s; s++)
|
|
||||||
switch (*s)
|
|
||||||
{
|
|
||||||
case '@': fputs ("@atchar{}", stdout); break;
|
|
||||||
case '{': fputs ("@lbracechar{}", stdout); break;
|
|
||||||
case '}': fputs ("@rbracechar{}", stdout); break;
|
|
||||||
case ',': fputs ("@comma{}", stdout); break;
|
|
||||||
case '\\':fputs ("@backslashchar{}", stdout); break;
|
|
||||||
case '#': fputs ("@hashchar{}", stdout); break;
|
|
||||||
default: putchar (*s); break;
|
|
||||||
}
|
|
||||||
putchar('\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
main (int argc, char **argv)
|
|
||||||
{
|
|
||||||
int last_argc = -1;
|
|
||||||
char *opt_date = NULL;
|
|
||||||
int monthoff;
|
|
||||||
char *p, *pend;
|
|
||||||
size_t n;
|
|
||||||
|
|
||||||
/* Option parsing. */
|
|
||||||
if (argc)
|
|
||||||
{
|
|
||||||
argc--; argv++;
|
|
||||||
}
|
|
||||||
while (argc && last_argc != argc )
|
|
||||||
{
|
|
||||||
last_argc = argc;
|
|
||||||
if (!strcmp (*argv, "--"))
|
|
||||||
{
|
|
||||||
argc--; argv++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (!strcmp (*argv, "--help"))
|
|
||||||
{
|
|
||||||
fputs ("Usage: " PGM " [OPTION] [FILES]\n"
|
|
||||||
"Create defs.inc file.\nOptions:\n"
|
|
||||||
" -C DIR Change to DIR before doing anything\n"
|
|
||||||
" --date STRING Take publication date from STRING\n"
|
|
||||||
" --verbose Enable extra informational output\n"
|
|
||||||
" --help Display this help and exit\n"
|
|
||||||
, stdout);
|
|
||||||
exit (0);
|
|
||||||
}
|
|
||||||
else if (!strcmp (*argv, "--verbose"))
|
|
||||||
{
|
|
||||||
verbose = 1;
|
|
||||||
argc--; argv++;
|
|
||||||
}
|
|
||||||
else if (!strcmp (*argv, "-C"))
|
|
||||||
{
|
|
||||||
argc--; argv++;
|
|
||||||
if (argc)
|
|
||||||
{
|
|
||||||
if (chdir (*argv))
|
|
||||||
{
|
|
||||||
fprintf (stderr, PGM ": chdir to '%s' failed: %s\n",
|
|
||||||
*argv, strerror (errno));
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
argc--; argv++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!strcmp (*argv, "--date"))
|
|
||||||
{
|
|
||||||
argc--; argv++;
|
|
||||||
if (argc)
|
|
||||||
{
|
|
||||||
opt_date = xstrdup (*argv);
|
|
||||||
argc--; argv++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!strncmp (*argv, "--", 2))
|
|
||||||
{
|
|
||||||
fprintf (stderr, PGM ": unknown option '%s'\n", *argv);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opt_date && *opt_date)
|
|
||||||
{
|
|
||||||
time_t stamp;
|
|
||||||
struct tm *tp;
|
|
||||||
|
|
||||||
if (*opt_date == '2' && strlen (opt_date) >= 10
|
|
||||||
&& opt_date[4] == '-' && opt_date[7] == '-')
|
|
||||||
{
|
|
||||||
opt_date[10] = 0;
|
|
||||||
}
|
|
||||||
else if ((stamp = strtoul (opt_date, NULL, 10)) > 0
|
|
||||||
&& (tp = gmtime (&stamp)))
|
|
||||||
{
|
|
||||||
p = xmalloc (4+1+2+1+2+1);
|
|
||||||
snprintf (p, 4+1+2+1+2+1, "%04d-%02d-%02d",
|
|
||||||
tp->tm_year + 1900, tp->tm_mon+1, tp->tm_mday);
|
|
||||||
xfree (opt_date);
|
|
||||||
opt_date = p;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf (stderr, PGM ": bad date '%s'\n", opt_date);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
xfree (opt_date);
|
|
||||||
opt_date = argc? get_date_from_files (argv) : NULL;
|
|
||||||
}
|
|
||||||
if (!opt_date)
|
|
||||||
{
|
|
||||||
opt_date = xstrdup ("unknown");
|
|
||||||
monthoff = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const char *month = "?";
|
|
||||||
|
|
||||||
switch (atoi (opt_date+5))
|
|
||||||
{
|
|
||||||
case 1: month = "January"; break;
|
|
||||||
case 2: month = "February"; break;
|
|
||||||
case 3: month = "March"; break;
|
|
||||||
case 4: month = "April"; break;
|
|
||||||
case 5: month = "May"; break;
|
|
||||||
case 6: month = "June"; break;
|
|
||||||
case 7: month = "July"; break;
|
|
||||||
case 8: month = "August"; break;
|
|
||||||
case 9: month = "September"; break;
|
|
||||||
case 10: month = "October"; break;
|
|
||||||
case 11: month = "November"; break;
|
|
||||||
case 12: month = "December"; break;
|
|
||||||
}
|
|
||||||
n = strlen (opt_date) + strlen (month) + 2 + 1;
|
|
||||||
p = xmalloc (n);
|
|
||||||
snprintf (p, n, "%d %n%s %d",
|
|
||||||
atoi (opt_date+8), &monthoff, month, atoi (opt_date));
|
|
||||||
xfree (opt_date);
|
|
||||||
opt_date = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fputs ("@c defs.inc -*- texinfo -*-\n"
|
|
||||||
"@c Common and build specific constants for the manuals.\n"
|
|
||||||
"@c This file has been created by " PGM ".\n\n", stdout);
|
|
||||||
|
|
||||||
fputs ("@ifclear defsincincluded\n"
|
|
||||||
"@set defsincincluded 1\n\n", stdout);
|
|
||||||
|
|
||||||
|
|
||||||
fputs ("\n@c Flags\n\n", stdout);
|
|
||||||
|
|
||||||
fputs ("\n@c Directories\n\n", stdout);
|
|
||||||
|
|
||||||
/* print_filename ("@set BINDIR ", GNUPG_BINDIR ); */
|
|
||||||
|
|
||||||
fputs ("\n@c Version information a la version.texi\n\n", stdout);
|
|
||||||
|
|
||||||
printf ("@set UPDATED %s\n", opt_date);
|
|
||||||
printf ("@set UPDATED-MONTH %s\n", opt_date + monthoff);
|
|
||||||
printf ("@set EDITION %s\n", PACKAGE_VERSION);
|
|
||||||
printf ("@set VERSION %s\n", PACKAGE_VERSION);
|
|
||||||
|
|
||||||
fputs ("\n@c Macros\n\n", stdout);
|
|
||||||
|
|
||||||
/* Trailer. */
|
|
||||||
fputs ("\n"
|
|
||||||
"@end ifclear\n"
|
|
||||||
"\n"
|
|
||||||
"@c Loc" "al Variables:\n"
|
|
||||||
"@c buffer-read-only: t\n"
|
|
||||||
"@c End:\n", stdout);
|
|
||||||
|
|
||||||
if (ferror (stdout))
|
|
||||||
{
|
|
||||||
fprintf (stderr, PGM ": error writing to stdout: %s\n", strerror (errno));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
136
doc/texinfo.tex
136
doc/texinfo.tex
@ -20,7 +20,7 @@
|
|||||||
% General Public License for more details.
|
% General Public License for more details.
|
||||||
%
|
%
|
||||||
% You should have received a copy of the GNU General Public License
|
% You should have received a copy of the GNU General Public License
|
||||||
% along with this program. If not, see <https://www.gnu.org/licenses/>.
|
% along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
%
|
%
|
||||||
% As a special exception, when this file is read by TeX when processing
|
% As a special exception, when this file is read by TeX when processing
|
||||||
% a Texinfo source document, you may use the result without
|
% a Texinfo source document, you may use the result without
|
||||||
@ -28,7 +28,7 @@
|
|||||||
%
|
%
|
||||||
% Please try the latest version of texinfo.tex before submitting bug
|
% Please try the latest version of texinfo.tex before submitting bug
|
||||||
% reports; you can get the latest version from:
|
% reports; you can get the latest version from:
|
||||||
% https://www.gnu.org/software/texinfo/ (the Texinfo home page), or
|
% http://www.gnu.org/software/texinfo/ (the Texinfo home page), or
|
||||||
% ftp://tug.org/tex/texinfo.tex
|
% ftp://tug.org/tex/texinfo.tex
|
||||||
% (and all CTAN mirrors, see http://www.ctan.org).
|
% (and all CTAN mirrors, see http://www.ctan.org).
|
||||||
% The texinfo.tex in any given distribution could well be out
|
% The texinfo.tex in any given distribution could well be out
|
||||||
@ -54,7 +54,7 @@
|
|||||||
% extent. You can get the existing language-specific files from the
|
% extent. You can get the existing language-specific files from the
|
||||||
% full Texinfo distribution.
|
% full Texinfo distribution.
|
||||||
%
|
%
|
||||||
% The GNU Texinfo home page is https://www.gnu.org/software/texinfo.
|
% The GNU Texinfo home page is http://www.gnu.org/software/texinfo.
|
||||||
|
|
||||||
|
|
||||||
\message{Loading texinfo [version \texinfoversion]:}
|
\message{Loading texinfo [version \texinfoversion]:}
|
||||||
@ -354,7 +354,7 @@
|
|||||||
% We don't want .vr (or whatever) entries like this:
|
% We don't want .vr (or whatever) entries like this:
|
||||||
% \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}}
|
% \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}}
|
||||||
% "\acronym" won't work when it's read back in;
|
% "\acronym" won't work when it's read back in;
|
||||||
% it needs to be
|
% it needs to be
|
||||||
% {\code {{\tt \backslashcurfont }acronym}
|
% {\code {{\tt \backslashcurfont }acronym}
|
||||||
\shipout\vbox{%
|
\shipout\vbox{%
|
||||||
% Do this early so pdf references go to the beginning of the page.
|
% Do this early so pdf references go to the beginning of the page.
|
||||||
@ -460,7 +460,7 @@
|
|||||||
\def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
|
\def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
|
||||||
\def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
|
\def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
|
||||||
|
|
||||||
% Each occurrence of `\^^M' or `<space>\^^M' is replaced by a single space.
|
% Each occurence of `\^^M' or `<space>\^^M' is replaced by a single space.
|
||||||
%
|
%
|
||||||
% \argremovec might leave us with trailing space, e.g.,
|
% \argremovec might leave us with trailing space, e.g.,
|
||||||
% @end itemize @c foo
|
% @end itemize @c foo
|
||||||
@ -485,7 +485,7 @@
|
|||||||
% to get _exactly_ the rest of the line, we had to prevent such situation.
|
% to get _exactly_ the rest of the line, we had to prevent such situation.
|
||||||
% We prepended an \empty token at the very beginning and we expand it now,
|
% We prepended an \empty token at the very beginning and we expand it now,
|
||||||
% just before passing the control to \argtorun.
|
% just before passing the control to \argtorun.
|
||||||
% (Similarly, we have to think about #3 of \argcheckspacesY above: it is
|
% (Similarily, we have to think about #3 of \argcheckspacesY above: it is
|
||||||
% either the null string, or it ends with \^^M---thus there is no danger
|
% either the null string, or it ends with \^^M---thus there is no danger
|
||||||
% that a pair of braces would be stripped.
|
% that a pair of braces would be stripped.
|
||||||
%
|
%
|
||||||
@ -498,7 +498,7 @@
|
|||||||
% \def\foo{\parsearg\Xfoo}
|
% \def\foo{\parsearg\Xfoo}
|
||||||
% \def\Xfoo#1{...}
|
% \def\Xfoo#1{...}
|
||||||
%
|
%
|
||||||
% Actually, I use \csname\string\foo\endcsname, i.e. \\foo, as it is my
|
% Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my
|
||||||
% favourite TeX trick. --kasal, 16nov03
|
% favourite TeX trick. --kasal, 16nov03
|
||||||
|
|
||||||
\def\parseargdef#1{%
|
\def\parseargdef#1{%
|
||||||
@ -542,7 +542,7 @@
|
|||||||
% used to check whether the current environment is the one expected.
|
% used to check whether the current environment is the one expected.
|
||||||
%
|
%
|
||||||
% Non-false conditionals (@iftex, @ifset) don't fit into this, so they
|
% Non-false conditionals (@iftex, @ifset) don't fit into this, so they
|
||||||
% are not treated as environments; they don't open a group. (The
|
% are not treated as enviroments; they don't open a group. (The
|
||||||
% implementation of @end takes care not to call \endgroup in this
|
% implementation of @end takes care not to call \endgroup in this
|
||||||
% special case.)
|
% special case.)
|
||||||
|
|
||||||
@ -565,7 +565,7 @@
|
|||||||
\fi
|
\fi
|
||||||
}
|
}
|
||||||
|
|
||||||
% Environment mismatch, #1 expected:
|
% Evironment mismatch, #1 expected:
|
||||||
\def\badenverr{%
|
\def\badenverr{%
|
||||||
\errhelp = \EMsimple
|
\errhelp = \EMsimple
|
||||||
\errmessage{This command can appear only \inenvironment\temp,
|
\errmessage{This command can appear only \inenvironment\temp,
|
||||||
@ -705,7 +705,7 @@
|
|||||||
\def\?{?\spacefactor=\endofsentencespacefactor\space}
|
\def\?{?\spacefactor=\endofsentencespacefactor\space}
|
||||||
|
|
||||||
% @frenchspacing on|off says whether to put extra space after punctuation.
|
% @frenchspacing on|off says whether to put extra space after punctuation.
|
||||||
%
|
%
|
||||||
\def\onword{on}
|
\def\onword{on}
|
||||||
\def\offword{off}
|
\def\offword{off}
|
||||||
%
|
%
|
||||||
@ -1260,7 +1260,7 @@ where each line of input produces a line of output.}
|
|||||||
% that's what we do).
|
% that's what we do).
|
||||||
|
|
||||||
% double active backslashes.
|
% double active backslashes.
|
||||||
%
|
%
|
||||||
{\catcode`\@=0 \catcode`\\=\active
|
{\catcode`\@=0 \catcode`\\=\active
|
||||||
@gdef@activebackslashdouble{%
|
@gdef@activebackslashdouble{%
|
||||||
@catcode`@\=@active
|
@catcode`@\=@active
|
||||||
@ -1272,11 +1272,11 @@ where each line of input produces a line of output.}
|
|||||||
% us) handles it with this amazing macro to replace tokens, with minor
|
% us) handles it with this amazing macro to replace tokens, with minor
|
||||||
% changes for Texinfo. It is included here under the GPL by permission
|
% changes for Texinfo. It is included here under the GPL by permission
|
||||||
% from the author, Heiko Oberdiek.
|
% from the author, Heiko Oberdiek.
|
||||||
%
|
%
|
||||||
% #1 is the tokens to replace.
|
% #1 is the tokens to replace.
|
||||||
% #2 is the replacement.
|
% #2 is the replacement.
|
||||||
% #3 is the control sequence with the string.
|
% #3 is the control sequence with the string.
|
||||||
%
|
%
|
||||||
\def\HyPsdSubst#1#2#3{%
|
\def\HyPsdSubst#1#2#3{%
|
||||||
\def\HyPsdReplace##1#1##2\END{%
|
\def\HyPsdReplace##1#1##2\END{%
|
||||||
##1%
|
##1%
|
||||||
@ -1542,7 +1542,7 @@ output) for that.)}
|
|||||||
% tried to figure out what each command should do in the context
|
% tried to figure out what each command should do in the context
|
||||||
% of @url. for now, just make @/ a no-op, that's the only one
|
% of @url. for now, just make @/ a no-op, that's the only one
|
||||||
% people have actually reported a problem with.
|
% people have actually reported a problem with.
|
||||||
%
|
%
|
||||||
\normalturnoffactive
|
\normalturnoffactive
|
||||||
\def\@{@}%
|
\def\@{@}%
|
||||||
\let\/=\empty
|
\let\/=\empty
|
||||||
@ -1941,7 +1941,7 @@ end
|
|||||||
|
|
||||||
% Definitions for a main text size of 11pt. This is the default in
|
% Definitions for a main text size of 11pt. This is the default in
|
||||||
% Texinfo.
|
% Texinfo.
|
||||||
%
|
%
|
||||||
\def\definetextfontsizexi{%
|
\def\definetextfontsizexi{%
|
||||||
% Text fonts (11.2pt, magstep1).
|
% Text fonts (11.2pt, magstep1).
|
||||||
\def\textnominalsize{11pt}
|
\def\textnominalsize{11pt}
|
||||||
@ -2074,7 +2074,7 @@ end
|
|||||||
% section, chapter, etc., sizes following suit. This is for the GNU
|
% section, chapter, etc., sizes following suit. This is for the GNU
|
||||||
% Press printing of the Emacs 22 manual. Maybe other manuals in the
|
% Press printing of the Emacs 22 manual. Maybe other manuals in the
|
||||||
% future. Used with @smallbook, which sets the leading to 12pt.
|
% future. Used with @smallbook, which sets the leading to 12pt.
|
||||||
%
|
%
|
||||||
\def\definetextfontsizex{%
|
\def\definetextfontsizex{%
|
||||||
% Text fonts (10pt).
|
% Text fonts (10pt).
|
||||||
\def\textnominalsize{10pt}
|
\def\textnominalsize{10pt}
|
||||||
@ -2165,7 +2165,7 @@ end
|
|||||||
\setfont\secsf\sfbshape{12}{1000}{OT1}
|
\setfont\secsf\sfbshape{12}{1000}{OT1}
|
||||||
\let\secbf\secrm
|
\let\secbf\secrm
|
||||||
\setfont\secsc\scbshape{10}{\magstep1}{OT1}
|
\setfont\secsc\scbshape{10}{\magstep1}{OT1}
|
||||||
\font\seci=cmmi12
|
\font\seci=cmmi12
|
||||||
\font\secsy=cmsy10 scaled \magstep1
|
\font\secsy=cmsy10 scaled \magstep1
|
||||||
\def\sececsize{1200}
|
\def\sececsize{1200}
|
||||||
|
|
||||||
@ -2209,7 +2209,7 @@ end
|
|||||||
% We provide the user-level command
|
% We provide the user-level command
|
||||||
% @fonttextsize 10
|
% @fonttextsize 10
|
||||||
% (or 11) to redefine the text font size. pt is assumed.
|
% (or 11) to redefine the text font size. pt is assumed.
|
||||||
%
|
%
|
||||||
\def\xword{10}
|
\def\xword{10}
|
||||||
\def\xiword{11}
|
\def\xiword{11}
|
||||||
%
|
%
|
||||||
@ -2219,7 +2219,7 @@ end
|
|||||||
%
|
%
|
||||||
% Set \globaldefs so that documents can use this inside @tex, since
|
% Set \globaldefs so that documents can use this inside @tex, since
|
||||||
% makeinfo 4.8 does not support it, but we need it nonetheless.
|
% makeinfo 4.8 does not support it, but we need it nonetheless.
|
||||||
%
|
%
|
||||||
\begingroup \globaldefs=1
|
\begingroup \globaldefs=1
|
||||||
\ifx\textsizearg\xword \definetextfontsizex
|
\ifx\textsizearg\xword \definetextfontsizex
|
||||||
\else \ifx\textsizearg\xiword \definetextfontsizexi
|
\else \ifx\textsizearg\xiword \definetextfontsizexi
|
||||||
@ -2505,7 +2505,7 @@ end
|
|||||||
% each of the four underscores in __typeof__. This is undesirable in
|
% each of the four underscores in __typeof__. This is undesirable in
|
||||||
% some manuals, especially if they don't have long identifiers in
|
% some manuals, especially if they don't have long identifiers in
|
||||||
% general. @allowcodebreaks provides a way to control this.
|
% general. @allowcodebreaks provides a way to control this.
|
||||||
%
|
%
|
||||||
\newif\ifallowcodebreaks \allowcodebreakstrue
|
\newif\ifallowcodebreaks \allowcodebreakstrue
|
||||||
|
|
||||||
\def\keywordtrue{true}
|
\def\keywordtrue{true}
|
||||||
@ -2636,7 +2636,7 @@ end
|
|||||||
% @acronym for "FBI", "NATO", and the like.
|
% @acronym for "FBI", "NATO", and the like.
|
||||||
% We print this one point size smaller, since it's intended for
|
% We print this one point size smaller, since it's intended for
|
||||||
% all-uppercase.
|
% all-uppercase.
|
||||||
%
|
%
|
||||||
\def\acronym#1{\doacronym #1,,\finish}
|
\def\acronym#1{\doacronym #1,,\finish}
|
||||||
\def\doacronym#1,#2,#3\finish{%
|
\def\doacronym#1,#2,#3\finish{%
|
||||||
{\selectfonts\lsize #1}%
|
{\selectfonts\lsize #1}%
|
||||||
@ -2648,7 +2648,7 @@ end
|
|||||||
|
|
||||||
% @abbr for "Comput. J." and the like.
|
% @abbr for "Comput. J." and the like.
|
||||||
% No font change, but don't do end-of-sentence spacing.
|
% No font change, but don't do end-of-sentence spacing.
|
||||||
%
|
%
|
||||||
\def\abbr#1{\doabbr #1,,\finish}
|
\def\abbr#1{\doabbr #1,,\finish}
|
||||||
\def\doabbr#1,#2,#3\finish{%
|
\def\doabbr#1,#2,#3\finish{%
|
||||||
{\plainfrenchspacing #1}%
|
{\plainfrenchspacing #1}%
|
||||||
@ -2667,43 +2667,43 @@ end
|
|||||||
% Theiling, which support regular, slanted, bold and bold slanted (and
|
% Theiling, which support regular, slanted, bold and bold slanted (and
|
||||||
% "outlined" (blackboard board, sort of) versions, which we don't need).
|
% "outlined" (blackboard board, sort of) versions, which we don't need).
|
||||||
% It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
|
% It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
|
||||||
%
|
%
|
||||||
% Although only regular is the truly official Euro symbol, we ignore
|
% Although only regular is the truly official Euro symbol, we ignore
|
||||||
% that. The Euro is designed to be slightly taller than the regular
|
% that. The Euro is designed to be slightly taller than the regular
|
||||||
% font height.
|
% font height.
|
||||||
%
|
%
|
||||||
% feymr - regular
|
% feymr - regular
|
||||||
% feymo - slanted
|
% feymo - slanted
|
||||||
% feybr - bold
|
% feybr - bold
|
||||||
% feybo - bold slanted
|
% feybo - bold slanted
|
||||||
%
|
%
|
||||||
% There is no good (free) typewriter version, to my knowledge.
|
% There is no good (free) typewriter version, to my knowledge.
|
||||||
% A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
|
% A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
|
||||||
% Hmm.
|
% Hmm.
|
||||||
%
|
%
|
||||||
% Also doesn't work in math. Do we need to do math with euro symbols?
|
% Also doesn't work in math. Do we need to do math with euro symbols?
|
||||||
% Hope not.
|
% Hope not.
|
||||||
%
|
%
|
||||||
%
|
%
|
||||||
\def\euro{{\eurofont e}}
|
\def\euro{{\eurofont e}}
|
||||||
\def\eurofont{%
|
\def\eurofont{%
|
||||||
% We set the font at each command, rather than predefining it in
|
% We set the font at each command, rather than predefining it in
|
||||||
% \textfonts and the other font-switching commands, so that
|
% \textfonts and the other font-switching commands, so that
|
||||||
% installations which never need the symbol don't have to have the
|
% installations which never need the symbol don't have to have the
|
||||||
% font installed.
|
% font installed.
|
||||||
%
|
%
|
||||||
% There is only one designed size (nominal 10pt), so we always scale
|
% There is only one designed size (nominal 10pt), so we always scale
|
||||||
% that to the current nominal size.
|
% that to the current nominal size.
|
||||||
%
|
%
|
||||||
% By the way, simply using "at 1em" works for cmr10 and the like, but
|
% By the way, simply using "at 1em" works for cmr10 and the like, but
|
||||||
% does not work for cmbx10 and other extended/shrunken fonts.
|
% does not work for cmbx10 and other extended/shrunken fonts.
|
||||||
%
|
%
|
||||||
\def\eurosize{\csname\curfontsize nominalsize\endcsname}%
|
\def\eurosize{\csname\curfontsize nominalsize\endcsname}%
|
||||||
%
|
%
|
||||||
\ifx\curfontstyle\bfstylename
|
\ifx\curfontstyle\bfstylename
|
||||||
% bold:
|
% bold:
|
||||||
\font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
|
\font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
|
||||||
\else
|
\else
|
||||||
% regular:
|
% regular:
|
||||||
\font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
|
\font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
|
||||||
\fi
|
\fi
|
||||||
@ -2756,7 +2756,7 @@ end
|
|||||||
% Laurent Siebenmann reports \Orb undefined with:
|
% Laurent Siebenmann reports \Orb undefined with:
|
||||||
% Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38
|
% Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38
|
||||||
% so we'll define it if necessary.
|
% so we'll define it if necessary.
|
||||||
%
|
%
|
||||||
\ifx\Orb\undefined
|
\ifx\Orb\undefined
|
||||||
\def\Orb{\mathhexbox20D}
|
\def\Orb{\mathhexbox20D}
|
||||||
\fi
|
\fi
|
||||||
@ -3105,7 +3105,7 @@ end
|
|||||||
% cause the example and the item to crash together. So we use this
|
% cause the example and the item to crash together. So we use this
|
||||||
% bizarre value of 10001 as a signal to \aboveenvbreak to insert
|
% bizarre value of 10001 as a signal to \aboveenvbreak to insert
|
||||||
% \parskip glue after all. Section titles are handled this way also.
|
% \parskip glue after all. Section titles are handled this way also.
|
||||||
%
|
%
|
||||||
\penalty 10001
|
\penalty 10001
|
||||||
\endgroup
|
\endgroup
|
||||||
\itemxneedsnegativevskipfalse
|
\itemxneedsnegativevskipfalse
|
||||||
@ -3901,7 +3901,7 @@ end
|
|||||||
% processing continues to some further point. On the other hand, it
|
% processing continues to some further point. On the other hand, it
|
||||||
% seems \endinput does not hurt in the printed index arg, since that
|
% seems \endinput does not hurt in the printed index arg, since that
|
||||||
% is still getting written without apparent harm.
|
% is still getting written without apparent harm.
|
||||||
%
|
%
|
||||||
% Sample source (mac-idx3.tex, reported by Graham Percival to
|
% Sample source (mac-idx3.tex, reported by Graham Percival to
|
||||||
% help-texinfo, 22may06):
|
% help-texinfo, 22may06):
|
||||||
% @macro funindex {WORD}
|
% @macro funindex {WORD}
|
||||||
@ -3909,12 +3909,12 @@ end
|
|||||||
% @end macro
|
% @end macro
|
||||||
% ...
|
% ...
|
||||||
% @funindex commtest
|
% @funindex commtest
|
||||||
%
|
%
|
||||||
% The above is not enough to reproduce the bug, but it gives the flavor.
|
% The above is not enough to reproduce the bug, but it gives the flavor.
|
||||||
%
|
%
|
||||||
% Sample whatsit resulting:
|
% Sample whatsit resulting:
|
||||||
% .@write3{\entry{xyz}{@folio }{@code {xyz@endinput }}}
|
% .@write3{\entry{xyz}{@folio }{@code {xyz@endinput }}}
|
||||||
%
|
%
|
||||||
% So:
|
% So:
|
||||||
\let\endinput = \empty
|
\let\endinput = \empty
|
||||||
%
|
%
|
||||||
@ -4170,11 +4170,11 @@ end
|
|||||||
% makeinfo does not expand macros in the argument to @deffn, which ends up
|
% makeinfo does not expand macros in the argument to @deffn, which ends up
|
||||||
% writing an index entry, and texindex isn't prepared for an index sort entry
|
% writing an index entry, and texindex isn't prepared for an index sort entry
|
||||||
% that starts with \.
|
% that starts with \.
|
||||||
%
|
%
|
||||||
% Since macro invocations are followed by braces, we can just redefine them
|
% Since macro invocations are followed by braces, we can just redefine them
|
||||||
% to take a single TeX argument. The case of a macro invocation that
|
% to take a single TeX argument. The case of a macro invocation that
|
||||||
% goes to end-of-line is not handled.
|
% goes to end-of-line is not handled.
|
||||||
%
|
%
|
||||||
\macrolist
|
\macrolist
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4302,7 +4302,7 @@ end
|
|||||||
% to re-insert the same penalty (values >10000 are used for various
|
% to re-insert the same penalty (values >10000 are used for various
|
||||||
% signals); since we just inserted a non-discardable item, any
|
% signals); since we just inserted a non-discardable item, any
|
||||||
% following glue (such as a \parskip) would be a breakpoint. For example:
|
% following glue (such as a \parskip) would be a breakpoint. For example:
|
||||||
%
|
%
|
||||||
% @deffn deffn-whatever
|
% @deffn deffn-whatever
|
||||||
% @vindex index-whatever
|
% @vindex index-whatever
|
||||||
% Description.
|
% Description.
|
||||||
@ -5368,11 +5368,11 @@ end
|
|||||||
% glue accumulate. (Not a breakpoint because it's preceded by a
|
% glue accumulate. (Not a breakpoint because it's preceded by a
|
||||||
% discardable item.)
|
% discardable item.)
|
||||||
\vskip-\parskip
|
\vskip-\parskip
|
||||||
%
|
%
|
||||||
% This is purely so the last item on the list is a known \penalty >
|
% This is purely so the last item on the list is a known \penalty >
|
||||||
% 10000. This is so \startdefun can avoid allowing breakpoints after
|
% 10000. This is so \startdefun can avoid allowing breakpoints after
|
||||||
% section headings. Otherwise, it would insert a valid breakpoint between:
|
% section headings. Otherwise, it would insert a valid breakpoint between:
|
||||||
%
|
%
|
||||||
% @section sec-whatever
|
% @section sec-whatever
|
||||||
% @deffn def-whatever
|
% @deffn def-whatever
|
||||||
\penalty 10001
|
\penalty 10001
|
||||||
@ -5430,7 +5430,7 @@ end
|
|||||||
% These characters do not print properly in the Computer Modern roman
|
% These characters do not print properly in the Computer Modern roman
|
||||||
% fonts, so we must take special care. This is more or less redundant
|
% fonts, so we must take special care. This is more or less redundant
|
||||||
% with the Texinfo input format setup at the end of this file.
|
% with the Texinfo input format setup at the end of this file.
|
||||||
%
|
%
|
||||||
\def\activecatcodes{%
|
\def\activecatcodes{%
|
||||||
\catcode`\"=\active
|
\catcode`\"=\active
|
||||||
\catcode`\$=\active
|
\catcode`\$=\active
|
||||||
@ -5480,7 +5480,7 @@ end
|
|||||||
|
|
||||||
% redefined for the two-volume lispref. We always output on
|
% redefined for the two-volume lispref. We always output on
|
||||||
% \jobname.toc even if this is redefined.
|
% \jobname.toc even if this is redefined.
|
||||||
%
|
%
|
||||||
\def\tocreadfilename{\jobname.toc}
|
\def\tocreadfilename{\jobname.toc}
|
||||||
|
|
||||||
% Normal (long) toc.
|
% Normal (long) toc.
|
||||||
@ -6035,8 +6035,8 @@ end
|
|||||||
% from cmtt (char 0x0d). The undirected quote is ugly, so don't make it
|
% from cmtt (char 0x0d). The undirected quote is ugly, so don't make it
|
||||||
% the default, but it works for pasting with more pdf viewers (at least
|
% the default, but it works for pasting with more pdf viewers (at least
|
||||||
% evince), the lilypond developers report. xpdf does work with the
|
% evince), the lilypond developers report. xpdf does work with the
|
||||||
% regular 0x27.
|
% regular 0x27.
|
||||||
%
|
%
|
||||||
\def\codequoteright{%
|
\def\codequoteright{%
|
||||||
\expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
|
\expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
|
||||||
\expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
|
\expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
|
||||||
@ -6048,7 +6048,7 @@ end
|
|||||||
% and a similar option for the left quote char vs. a grave accent.
|
% and a similar option for the left quote char vs. a grave accent.
|
||||||
% Modern fonts display ASCII 0x60 as a grave accent, so some people like
|
% Modern fonts display ASCII 0x60 as a grave accent, so some people like
|
||||||
% the code environments to do likewise.
|
% the code environments to do likewise.
|
||||||
%
|
%
|
||||||
\def\codequoteleft{%
|
\def\codequoteleft{%
|
||||||
\expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
|
\expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
|
||||||
\expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
|
\expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
|
||||||
@ -6579,7 +6579,7 @@ end
|
|||||||
% This does \let #1 = #2, with \csnames; that is,
|
% This does \let #1 = #2, with \csnames; that is,
|
||||||
% \let \csname#1\endcsname = \csname#2\endcsname
|
% \let \csname#1\endcsname = \csname#2\endcsname
|
||||||
% (except of course we have to play expansion games).
|
% (except of course we have to play expansion games).
|
||||||
%
|
%
|
||||||
\def\cslet#1#2{%
|
\def\cslet#1#2{%
|
||||||
\expandafter\let
|
\expandafter\let
|
||||||
\csname#1\expandafter\endcsname
|
\csname#1\expandafter\endcsname
|
||||||
@ -7317,7 +7317,7 @@ end
|
|||||||
% In case a @footnote appears in a vbox, save the footnote text and create
|
% In case a @footnote appears in a vbox, save the footnote text and create
|
||||||
% the real \insert just after the vbox finished. Otherwise, the insertion
|
% the real \insert just after the vbox finished. Otherwise, the insertion
|
||||||
% would be lost.
|
% would be lost.
|
||||||
% Similarly, if a @footnote appears inside an alignment, save the footnote
|
% Similarily, if a @footnote appears inside an alignment, save the footnote
|
||||||
% text to a box and make the \insert when a row of the table is finished.
|
% text to a box and make the \insert when a row of the table is finished.
|
||||||
% And the same can be done for other insert classes. --kasal, 16nov03.
|
% And the same can be done for other insert classes. --kasal, 16nov03.
|
||||||
|
|
||||||
@ -7737,7 +7737,7 @@ end
|
|||||||
%
|
%
|
||||||
% If they passed de_DE, and txi-de_DE.tex doesn't exist,
|
% If they passed de_DE, and txi-de_DE.tex doesn't exist,
|
||||||
% try txi-de.tex.
|
% try txi-de.tex.
|
||||||
%
|
%
|
||||||
\def\documentlanguagetrywithoutunderscore#1_#2\finish{%
|
\def\documentlanguagetrywithoutunderscore#1_#2\finish{%
|
||||||
\openin 1 txi-#1.tex
|
\openin 1 txi-#1.tex
|
||||||
\ifeof 1
|
\ifeof 1
|
||||||
@ -7793,7 +7793,7 @@ should work if nowhere else does.}
|
|||||||
\setnonasciicharscatcode\active
|
\setnonasciicharscatcode\active
|
||||||
\lattwochardefs
|
\lattwochardefs
|
||||||
%
|
%
|
||||||
\else \ifx \declaredencoding \latone
|
\else \ifx \declaredencoding \latone
|
||||||
\setnonasciicharscatcode\active
|
\setnonasciicharscatcode\active
|
||||||
\latonechardefs
|
\latonechardefs
|
||||||
%
|
%
|
||||||
@ -7805,7 +7805,7 @@ should work if nowhere else does.}
|
|||||||
\setnonasciicharscatcode\active
|
\setnonasciicharscatcode\active
|
||||||
\utfeightchardefs
|
\utfeightchardefs
|
||||||
%
|
%
|
||||||
\else
|
\else
|
||||||
\message{Unknown document encoding #1, ignoring.}%
|
\message{Unknown document encoding #1, ignoring.}%
|
||||||
%
|
%
|
||||||
\fi % utfeight
|
\fi % utfeight
|
||||||
@ -7817,7 +7817,7 @@ should work if nowhere else does.}
|
|||||||
|
|
||||||
% A message to be logged when using a character that isn't available
|
% A message to be logged when using a character that isn't available
|
||||||
% the default font encoding (OT1).
|
% the default font encoding (OT1).
|
||||||
%
|
%
|
||||||
\def\missingcharmsg#1{\message{Character missing in OT1 encoding: #1.}}
|
\def\missingcharmsg#1{\message{Character missing in OT1 encoding: #1.}}
|
||||||
|
|
||||||
% Take account of \c (plain) vs. \, (Texinfo) difference.
|
% Take account of \c (plain) vs. \, (Texinfo) difference.
|
||||||
@ -7830,21 +7830,21 @@ should work if nowhere else does.}
|
|||||||
%
|
%
|
||||||
% Latin1 (ISO-8859-1) character definitions.
|
% Latin1 (ISO-8859-1) character definitions.
|
||||||
\def\latonechardefs{%
|
\def\latonechardefs{%
|
||||||
\gdef^^a0{~}
|
\gdef^^a0{~}
|
||||||
\gdef^^a1{\exclamdown}
|
\gdef^^a1{\exclamdown}
|
||||||
\gdef^^a2{\missingcharmsg{CENT SIGN}}
|
\gdef^^a2{\missingcharmsg{CENT SIGN}}
|
||||||
\gdef^^a3{{\pounds}}
|
\gdef^^a3{{\pounds}}
|
||||||
\gdef^^a4{\missingcharmsg{CURRENCY SIGN}}
|
\gdef^^a4{\missingcharmsg{CURRENCY SIGN}}
|
||||||
\gdef^^a5{\missingcharmsg{YEN SIGN}}
|
\gdef^^a5{\missingcharmsg{YEN SIGN}}
|
||||||
\gdef^^a6{\missingcharmsg{BROKEN BAR}}
|
\gdef^^a6{\missingcharmsg{BROKEN BAR}}
|
||||||
\gdef^^a7{\S}
|
\gdef^^a7{\S}
|
||||||
\gdef^^a8{\"{}}
|
\gdef^^a8{\"{}}
|
||||||
\gdef^^a9{\copyright}
|
\gdef^^a9{\copyright}
|
||||||
\gdef^^aa{\ordf}
|
\gdef^^aa{\ordf}
|
||||||
\gdef^^ab{\missingcharmsg{LEFT-POINTING DOUBLE ANGLE QUOTATION MARK}}
|
\gdef^^ab{\missingcharmsg{LEFT-POINTING DOUBLE ANGLE QUOTATION MARK}}
|
||||||
\gdef^^ac{$\lnot$}
|
\gdef^^ac{$\lnot$}
|
||||||
\gdef^^ad{\-}
|
\gdef^^ad{\-}
|
||||||
\gdef^^ae{\registeredsymbol}
|
\gdef^^ae{\registeredsymbol}
|
||||||
\gdef^^af{\={}}
|
\gdef^^af{\={}}
|
||||||
%
|
%
|
||||||
\gdef^^b0{\textdegree}
|
\gdef^^b0{\textdegree}
|
||||||
@ -7871,7 +7871,7 @@ should work if nowhere else does.}
|
|||||||
\gdef^^c2{\^A}
|
\gdef^^c2{\^A}
|
||||||
\gdef^^c3{\~A}
|
\gdef^^c3{\~A}
|
||||||
\gdef^^c4{\"A}
|
\gdef^^c4{\"A}
|
||||||
\gdef^^c5{\ringaccent A}
|
\gdef^^c5{\ringaccent A}
|
||||||
\gdef^^c6{\AE}
|
\gdef^^c6{\AE}
|
||||||
\gdef^^c7{\cedilla C}
|
\gdef^^c7{\cedilla C}
|
||||||
\gdef^^c8{\`E}
|
\gdef^^c8{\`E}
|
||||||
@ -8012,7 +8012,7 @@ should work if nowhere else does.}
|
|||||||
\gdef^^d6{\"O}
|
\gdef^^d6{\"O}
|
||||||
\gdef^^d7{$\times$}
|
\gdef^^d7{$\times$}
|
||||||
\gdef^^d8{\v R}
|
\gdef^^d8{\v R}
|
||||||
\gdef^^d9{\ringaccent U}
|
\gdef^^d9{\ringaccent U}
|
||||||
\gdef^^da{\'U}
|
\gdef^^da{\'U}
|
||||||
\gdef^^db{\H U}
|
\gdef^^db{\H U}
|
||||||
\gdef^^dc{\"U}
|
\gdef^^dc{\"U}
|
||||||
@ -8056,11 +8056,11 @@ should work if nowhere else does.}
|
|||||||
}
|
}
|
||||||
|
|
||||||
% UTF-8 character definitions.
|
% UTF-8 character definitions.
|
||||||
%
|
%
|
||||||
% This code to support UTF-8 is based on LaTeX's utf8.def, with some
|
% This code to support UTF-8 is based on LaTeX's utf8.def, with some
|
||||||
% changes for Texinfo conventions. It is included here under the GPL by
|
% changes for Texinfo conventions. It is included here under the GPL by
|
||||||
% permission from Frank Mittelbach and the LaTeX team.
|
% permission from Frank Mittelbach and the LaTeX team.
|
||||||
%
|
%
|
||||||
\newcount\countUTFx
|
\newcount\countUTFx
|
||||||
\newcount\countUTFy
|
\newcount\countUTFy
|
||||||
\newcount\countUTFz
|
\newcount\countUTFz
|
||||||
@ -8900,7 +8900,7 @@ should work if nowhere else does.}
|
|||||||
|
|
||||||
% Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
|
% Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
|
||||||
% the literal character `\'.
|
% the literal character `\'.
|
||||||
%
|
%
|
||||||
@def@normalturnoffactive{%
|
@def@normalturnoffactive{%
|
||||||
@let\=@normalbackslash
|
@let\=@normalbackslash
|
||||||
@let"=@normaldoublequote
|
@let"=@normaldoublequote
|
||||||
|
@ -158,21 +158,21 @@ indicated by a @sc{c:}, server responses by @sc{c:}:
|
|||||||
|
|
||||||
@smallexample
|
@smallexample
|
||||||
@group
|
@group
|
||||||
@clnt{RESET}
|
@clnt RESET
|
||||||
@srvr{OK}
|
@srvr OK
|
||||||
@clnt{RECIPIENT foo@@example.net}
|
@clnt RECIPIENT foo@@example.net
|
||||||
@srvr{OK}
|
@srvr OK
|
||||||
@clnt{RECIPIENT bar@@example.com}
|
@clnt RECIPIENT bar@@example.com
|
||||||
@srvr{OK}
|
@srvr OK
|
||||||
@clnt{PREP_ENCRYPT}
|
@clnt PREP_ENCRYPT
|
||||||
@srvr{S PROTOCOL OpenPGP}
|
@srvr S PROTOCOL OpenPGP
|
||||||
@srvr{OK}
|
@srvr OK
|
||||||
@clnt{INPUT FD=17}
|
@clnt INPUT FD=17
|
||||||
@srvr{OK}
|
@srvr OK
|
||||||
@clnt{OUTPUT FD=18}
|
@clnt OUTPUT FD=18
|
||||||
@srvr{OK}
|
@srvr OK
|
||||||
@clnt{ENCRYPT}
|
@clnt ENCRYPT
|
||||||
@srvr{OK}
|
@srvr OK
|
||||||
@end group
|
@end group
|
||||||
@end smallexample
|
@end smallexample
|
||||||
|
|
||||||
@ -260,14 +260,12 @@ encoded. For details on the file descriptor, see the description of
|
|||||||
@noindent
|
@noindent
|
||||||
The decryption is started with the command:
|
The decryption is started with the command:
|
||||||
|
|
||||||
@deffn Command DECRYPT -@w{}-protocol=@var{name} [-@w{}-no-verify] [-@w{}-export-session-key]
|
@deffn Command DECRYPT -@w{}-protocol=@var{name} [-@w{}-no-verify]
|
||||||
@var{name} is the encryption protocol used for the message. For a
|
@var{name} is the encryption protocol used for the message. For a
|
||||||
description of the allowed protocols see the @code{ENCRYPT} command.
|
description of the allowed protocols see the @code{ENCRYPT} command.
|
||||||
This argument is mandatory. If the option @option{--no-verify} is
|
This argument is mandatory. If the option @option{--no-verify} is given,
|
||||||
given, the server should not try to verify a signature, in case the
|
the server should not try to verify a signature, in case the input data
|
||||||
input data is an OpenPGP combined message. If the option
|
is an OpenPGP combined message.
|
||||||
@option{--export-session-key} is given and the underlying engine knows
|
|
||||||
how to export the session key, it will appear on a status line
|
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
|
|
||||||
@ -484,7 +482,7 @@ First, the input files need to be specified by one or more
|
|||||||
@code{FILE} commands. Afterwards, the actual operation is requested:
|
@code{FILE} commands. Afterwards, the actual operation is requested:
|
||||||
|
|
||||||
@deffn Command CHECKSUM_CREATE_FILES --nohup
|
@deffn Command CHECKSUM_CREATE_FILES --nohup
|
||||||
Request that checksums are created for the files specified by
|
Request that checksums are created for the files specifed by
|
||||||
@code{FILE}. The choice of checksum algorithm and the destination
|
@code{FILE}. The choice of checksum algorithm and the destination
|
||||||
storage and format for the created checksums depend on the preferences
|
storage and format for the created checksums depend on the preferences
|
||||||
of the user and the functionality provided by the UI server. For
|
of the user and the functionality provided by the UI server. For
|
||||||
@ -499,7 +497,7 @@ promptly, and completes the operation asynchronously.
|
|||||||
|
|
||||||
|
|
||||||
@deffn Command CHECKSUM_VERIFY_FILES --nohup
|
@deffn Command CHECKSUM_VERIFY_FILES --nohup
|
||||||
Request that checksums are created for the files specified by
|
Request that checksums are created for the files specifed by
|
||||||
@code{FILE} and verified against previously created and stored
|
@code{FILE} and verified against previously created and stored
|
||||||
checksums. The choice of checksum algorithm and the source storage
|
checksums. The choice of checksum algorithm and the source storage
|
||||||
and format for previously created checksums depend on the preferences
|
and format for previously created checksums depend on the preferences
|
||||||
@ -564,7 +562,7 @@ do this it uses the Assuan command:
|
|||||||
@deffn Command START_KEYMANAGER
|
@deffn Command START_KEYMANAGER
|
||||||
The server shall pop up the main window of the key manager (aka
|
The server shall pop up the main window of the key manager (aka
|
||||||
certificate manager). The client expects that the key manager is brought
|
certificate manager). The client expects that the key manager is brought
|
||||||
into the foregound and that this command immediately returns (does not
|
into the foregound and that this command immediatley returns (does not
|
||||||
wait until the key manager has been fully brought up).
|
wait until the key manager has been fully brought up).
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@ -575,7 +573,7 @@ do this it uses the Assuan command:
|
|||||||
@deffn Command START_CONFDIALOG
|
@deffn Command START_CONFDIALOG
|
||||||
The server shall pop up its configuration dialog. The client expects
|
The server shall pop up its configuration dialog. The client expects
|
||||||
that this dialog is brought into the foregound and that this command
|
that this dialog is brought into the foregound and that this command
|
||||||
immediately returns (i.e. it does not wait until the dialog has been
|
immediatley returns (i.e. it does not wait until the dialog has been
|
||||||
fully brought up).
|
fully brought up).
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@ Summary: GPGME - GnuPG Made Easy
|
|||||||
Name: gpgme
|
Name: gpgme
|
||||||
Version: @pkg_version@
|
Version: @pkg_version@
|
||||||
Release: 1
|
Release: 1
|
||||||
URL: https://gnupg.org/gpgme.html
|
URL: http://www.gnupg.org/gpgme.html
|
||||||
Source: https://www.gnupg.org/ftp/gcrypt/gpgme/%{name}-%{version}.tar.gz
|
Source: ftp://ftp.gnupg.org/gcrypt/alpha/gpgme/%{name}-%{version}.tar.gz
|
||||||
Group: Development/Libraries
|
Group: Development/Libraries
|
||||||
Copyright: GPL
|
Copyright: GPL
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}
|
BuildRoot: %{_tmppath}/%{name}-%{version}
|
||||||
@ -38,12 +38,10 @@ make distclean
|
|||||||
%post
|
%post
|
||||||
/sbin/ldconfig
|
/sbin/ldconfig
|
||||||
/sbin/install-info %{_infodir}/gpgme.info.gz %{_infodir}/dir
|
/sbin/install-info %{_infodir}/gpgme.info.gz %{_infodir}/dir
|
||||||
/sbin/install-info %{_infodir}/gpgme-python-howto.info.gz %{_infodir}/dir
|
|
||||||
|
|
||||||
%preun
|
%preun
|
||||||
if [ "$1" = 0 ]; then
|
if [ "$1" = 0 ]; then
|
||||||
/sbin/install-info --delete %{_infodir}/gpgme.info.gz %{_infodir}/dir
|
/sbin/install-info --delete %{_infodir}/gpgme.info.gz %{_infodir}/dir
|
||||||
/sbin/install-info --delete %{_infodir}/gpgme-python-howto.info.gz %{_infodir}/dir
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
%postun
|
%postun
|
||||||
@ -59,7 +57,6 @@ fi
|
|||||||
%{_includedir}/gpgme.h
|
%{_includedir}/gpgme.h
|
||||||
%{_datadir}/aclocal/gpgme.m4
|
%{_datadir}/aclocal/gpgme.m4
|
||||||
%{_infodir}/gpgme.info*
|
%{_infodir}/gpgme.info*
|
||||||
%{_infodir}/gpgme-python-howto.info*
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Sat Aug 30 2003 Robert Schiele <rschiele@uni-mannheim.de>
|
* Sat Aug 30 2003 Robert Schiele <rschiele@uni-mannheim.de>
|
||||||
|
@ -35,9 +35,9 @@ support OpenPGP and the Cryptographic Message Syntax.
|
|||||||
|
|
||||||
%%GNU: no
|
%%GNU: no
|
||||||
|
|
||||||
%%web-page: https://www.gnupg.org/gpgme.html
|
%%web-page: http://www.gnupg.org/gpgme.html
|
||||||
|
|
||||||
%%support: paid extension/consulting from https://www.g10code.com
|
%%support: paid extension/consulting from http://www.g10code.com
|
||||||
|
|
||||||
%%doc: English programmer reference in Texinfo, Postscript, HTML included
|
%%doc: English programmer reference in Texinfo, Postscript, HTML included
|
||||||
|
|
||||||
@ -47,13 +47,13 @@ support OpenPGP and the Cryptographic Message Syntax.
|
|||||||
|
|
||||||
%%sponsors:
|
%%sponsors:
|
||||||
|
|
||||||
%%source: https://www.gnupg.org/ftp/gcrypt/gpgme/
|
%%source: ftp://ftp.gnupg.org/gcrypt/gpgme/
|
||||||
|
|
||||||
%%debian:
|
%%debian:
|
||||||
|
|
||||||
%%redhat:
|
%%redhat:
|
||||||
|
|
||||||
%%repository: See https://dev.gnupg.org/source/gpgme/
|
%%repository: See http://www.gnupg.org/cvs-access.html
|
||||||
|
|
||||||
%%related:
|
%%related:
|
||||||
|
|
||||||
|
@ -14,10 +14,9 @@
|
|||||||
# Public License for more details.
|
# Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
# License along with this program; if not, see <https://gnu.org/licenses/>.
|
# License along with this program; if not, write to the Free Software
|
||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
|
|
||||||
SUBDIRS = $(ENABLED_LANGUAGES)
|
SUBDIRS = cl
|
||||||
DIST_SUBDIRS = cl cpp qt python js
|
|
||||||
|
|
||||||
EXTRA_DIST = README
|
EXTRA_DIST = README
|
||||||
|
@ -10,7 +10,4 @@ sub-directory.
|
|||||||
Directory Language
|
Directory Language
|
||||||
|
|
||||||
cl Common Lisp
|
cl Common Lisp
|
||||||
cpp C++
|
xml-schemas XML (schema files for Relax-NG, RNG compact, W3C XSD and DTD)
|
||||||
qt Qt-Framework API
|
|
||||||
python Python 2 and 3 (module name: gpg)
|
|
||||||
js Native messaging client for the gpgme-json server.
|
|
||||||
|
@ -13,11 +13,12 @@
|
|||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU Lesser General Public License for more details.
|
# GNU Lesser General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public
|
# You should have received a copy of the GNU General Public License
|
||||||
# License along with this program; if not, see <https://gnu.org/licenses/>.
|
# along with this program; if not, write to the Free Software
|
||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||||
|
# 02111-1307, USA
|
||||||
|
|
||||||
clfiles = gpgme.asd gpgme-package.lisp gpgme-grovel.lisp gpgme.lisp
|
clfiles = gpgme.asd gpgme-package.lisp gpgme.lisp
|
||||||
|
|
||||||
# FIXME: Should be configurable.
|
# FIXME: Should be configurable.
|
||||||
clfilesdir = $(datadir)/common-lisp/source/gpgme
|
clfilesdir = $(datadir)/common-lisp/source/gpgme
|
||||||
|
@ -3,50 +3,33 @@ Common Lisp Support for GPGME
|
|||||||
|
|
||||||
Requirements:
|
Requirements:
|
||||||
|
|
||||||
ASDF Packaging Support
|
ASDF Packaging Support
|
||||||
CFFI Foreign Function Interface
|
CFFI Foreign Function Interface
|
||||||
trivial-garbage Finalizers
|
gpg-error GPG Error Codes
|
||||||
gpg-error GPG Error Codes
|
|
||||||
|
|
||||||
Use with:
|
Use with:
|
||||||
|
|
||||||
> (asdf:load-system "gpgme")
|
> (asdf:operate 'asdf:load-op ':gpgme)
|
||||||
|
|
||||||
|
|
||||||
Examples
|
Examples
|
||||||
--------
|
--------
|
||||||
|
|
||||||
(with-open-file (out "/tmp/myout"
|
(with-open-file (stream "/tmp/myout" :direction :output
|
||||||
:direction :output
|
:if-exists :supersede :element-type '(unsigned-byte 8))
|
||||||
:if-exists :supersede
|
|
||||||
:element-type '(unsigned-byte 8))
|
|
||||||
(with-context (ctx)
|
(with-context (ctx)
|
||||||
(setf (armorp ctx) t)
|
(setf (armor-p ctx) t)
|
||||||
(op-export ctx "DEADBEEF" out)))
|
(op-export ctx "DEADBEEF" out)))
|
||||||
|
|
||||||
(with-context (ctx)
|
(with-context (ctx)
|
||||||
(with-output-to-string (out)
|
(with-output-to-string (out)
|
||||||
(setf (armorp ctx) t)
|
(setf (armor-p ctx) t)
|
||||||
(op-export ctx "McTester" out)))
|
(op-export ctx "McTester" out)))
|
||||||
|
|
||||||
(gpgme:with-context (ctx :armor t)
|
(gpgme:with-context (ctx :armor t)
|
||||||
(with-output-to-string (out)
|
(with-output-to-string (out)
|
||||||
(gpgme:op-export ctx "McTester" out)))
|
(gpgme:op-export ctx "McTester" out)))
|
||||||
|
|
||||||
(gpgme:with-context (ctx :armor t)
|
|
||||||
(let ((recipient1 (gpgme:get-key ctx "DEADBEEF"))
|
|
||||||
(recipient2 (gpgme:get-key ctx "Alice"))
|
|
||||||
(message "Hello, world!"))
|
|
||||||
(with-output-to-string (out)
|
|
||||||
(with-input-from-string (in message)
|
|
||||||
(gpgme:op-encrypt ctx (vector recipient1 recipient2) in out)))))
|
|
||||||
|
|
||||||
(gpgme:with-context (ctx :armor t)
|
|
||||||
(let ((message "Hello, world!"))
|
|
||||||
(with-output-to-string (out)
|
|
||||||
(with-input-from-string (in message)
|
|
||||||
(gpgme:op-sign ctx in out)))))
|
|
||||||
|
|
||||||
|
|
||||||
TODO
|
TODO
|
||||||
----
|
----
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
;;;; gpgme-grovel.lisp
|
|
||||||
|
|
||||||
;;; This file is part of GPGME-CL.
|
|
||||||
;;;
|
|
||||||
;;; GPGME-CL 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 2 of the License, or
|
|
||||||
;;; (at your option) any later version.
|
|
||||||
;;;
|
|
||||||
;;; GPGME-CL 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 General Public License
|
|
||||||
;;; along with GPGME; if not, write to the Free Software Foundation,
|
|
||||||
;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
|
|
||||||
|
|
||||||
(in-package :gpgme)
|
|
||||||
|
|
||||||
|
|
||||||
(include "errno.h" "sys/types.h")
|
|
||||||
|
|
||||||
(constant (+ebadf+ "EBADF"))
|
|
||||||
|
|
||||||
(ctype off-t "off_t")
|
|
||||||
(ctype size-t "size_t")
|
|
||||||
(ctype ssize-t "ssize_t")
|
|
||||||
|
|
||||||
(cvar ("errno" *errno*) :int)
|
|
@ -26,8 +26,7 @@
|
|||||||
|
|
||||||
(defpackage #:gpgme
|
(defpackage #:gpgme
|
||||||
(:use #:common-lisp #:cffi #:gpg-error)
|
(:use #:common-lisp #:cffi #:gpg-error)
|
||||||
(:import-from #:trivial-garbage
|
|
||||||
#:finalize)
|
|
||||||
(:export #:check-version
|
(:export #:check-version
|
||||||
#:*version*
|
#:*version*
|
||||||
#:context
|
#:context
|
||||||
|
@ -25,14 +25,11 @@
|
|||||||
(in-package #:gpgme-system)
|
(in-package #:gpgme-system)
|
||||||
|
|
||||||
(defsystem gpgme
|
(defsystem gpgme
|
||||||
:description "GnuPG Made Easy."
|
:description "GnuPG Made Easy."
|
||||||
:author "g10 Code GmbH"
|
:author "g10 Code GmbH"
|
||||||
:version "@VERSION@"
|
:version "@VERSION@"
|
||||||
:licence "GPL"
|
:licence "GPL"
|
||||||
:defsystem-depends-on ("cffi-grovel")
|
:depends-on ("cffi" "gpg-error")
|
||||||
:depends-on ("cffi" "gpg-error" "trivial-garbage")
|
:components ((:file "gpgme-package")
|
||||||
:components ((:file "gpgme-package")
|
(:file "gpgme"
|
||||||
(:cffi-grovel-file "gpgme-grovel"
|
:depends-on ("gpgme-package"))))
|
||||||
:depends-on ("gpgme-package"))
|
|
||||||
(:file "gpgme"
|
|
||||||
:depends-on ("gpgme-package" "gpgme-grovel"))))
|
|
||||||
|
@ -24,12 +24,6 @@
|
|||||||
|
|
||||||
(in-package :gpgme)
|
(in-package :gpgme)
|
||||||
|
|
||||||
(deftype byte-array ()
|
|
||||||
'(simple-array (unsigned-byte 8) (*)))
|
|
||||||
|
|
||||||
(deftype character-array ()
|
|
||||||
'(simple-array character (*)))
|
|
||||||
|
|
||||||
;;; Debugging.
|
;;; Debugging.
|
||||||
|
|
||||||
(defvar *debug* nil "If debugging output should be given or not.")
|
(defvar *debug* nil "If debugging output should be given or not.")
|
||||||
@ -44,15 +38,23 @@
|
|||||||
|
|
||||||
;;; System dependencies.
|
;;; System dependencies.
|
||||||
|
|
||||||
; Access to ERRNO.
|
; FIXME: Use cffi-grovel? cffi-unix?
|
||||||
|
|
||||||
|
(defctype size-t :unsigned-int "The system size_t type.")
|
||||||
|
|
||||||
|
(defctype ssize-t :int "The system ssize_t type.")
|
||||||
|
|
||||||
|
; FIXME: Ouch. Grovel? Helper function?
|
||||||
|
(defconstant +seek-set+ 0)
|
||||||
|
(defconstant +seek-cur+ 1)
|
||||||
|
(defconstant +seek-end+ 2)
|
||||||
|
(defctype off-t :long-long "The system off_t type.")
|
||||||
|
|
||||||
(defcfun ("strerror" c-strerror) :string
|
(defcfun ("strerror" c-strerror) :string
|
||||||
(err :int))
|
(err :int))
|
||||||
|
|
||||||
(defun get-errno ()
|
; Access to ERRNO.
|
||||||
*errno*)
|
; FIXME: Ouch. Should be grovel + helper function.
|
||||||
|
|
||||||
(defun set-errno (errno)
|
|
||||||
(setf *errno* errno))
|
|
||||||
|
|
||||||
(define-condition system-error (error)
|
(define-condition system-error (error)
|
||||||
((errno :initarg :errno :reader system-error-errno))
|
((errno :initarg :errno :reader system-error-errno))
|
||||||
@ -62,6 +64,14 @@
|
|||||||
(c-strerror (system-error-errno c)))))
|
(c-strerror (system-error-errno c)))))
|
||||||
(:documentation "Signalled when an errno is encountered."))
|
(:documentation "Signalled when an errno is encountered."))
|
||||||
|
|
||||||
|
(defconstant +ebadf+ 1)
|
||||||
|
|
||||||
|
; Ouch.
|
||||||
|
(defun get-errno ()
|
||||||
|
+ebadf+)
|
||||||
|
|
||||||
|
;;; More about errno below.
|
||||||
|
|
||||||
; Needed to write passphrases.
|
; Needed to write passphrases.
|
||||||
(defcfun ("write" c-write) ssize-t
|
(defcfun ("write" c-write) ssize-t
|
||||||
(fd :int)
|
(fd :int)
|
||||||
@ -73,6 +83,14 @@
|
|||||||
(when (< res 0) (error 'system-error :errno (get-errno)))
|
(when (< res 0) (error 'system-error :errno (get-errno)))
|
||||||
res))
|
res))
|
||||||
|
|
||||||
|
;;; More about errno here.
|
||||||
|
|
||||||
|
(defun set-errno (errno)
|
||||||
|
(cond
|
||||||
|
; Works on GNU/Linux.
|
||||||
|
((eql errno +ebadf+) (system-write -1 (null-pointer) 0))
|
||||||
|
(t (error 'invalid-errno :errno errno))))
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
;;; C Interface Definitions
|
;;; C Interface Definitions
|
||||||
;;;
|
;;;
|
||||||
@ -82,39 +100,22 @@
|
|||||||
;;; Some new data types used for easier translation.
|
;;; Some new data types used for easier translation.
|
||||||
|
|
||||||
;;; The number of include certs. Translates to NIL for default.
|
;;; The number of include certs. Translates to NIL for default.
|
||||||
(defctype cert-int-t
|
(defctype cert-int-t :int)
|
||||||
(:wrapper :int
|
|
||||||
:from-c translate-cert-int-t-from-foreign
|
|
||||||
:to-c translate-cert-int-t-to-foreign))
|
|
||||||
|
|
||||||
;;; A string that may be NIL to indicate a null pointer.
|
;;; A string that may be NIL to indicate a null pointer.
|
||||||
(defctype string-or-nil-t
|
(defctype string-or-nil-t :string)
|
||||||
(:wrapper :string
|
|
||||||
:to-c translate-string-or-nil-t-to-foreign))
|
|
||||||
|
|
||||||
;;; Some opaque data types used by GPGME.
|
;;; Some opaque data types used by GPGME.
|
||||||
|
|
||||||
(defctype gpgme-ctx-t
|
(defctype gpgme-ctx-t :pointer "The GPGME context type.")
|
||||||
(:wrapper :pointer
|
|
||||||
:to-c translate-gpgme-ctx-t-to-foreign)
|
|
||||||
"The GPGME context type.")
|
|
||||||
|
|
||||||
(defctype gpgme-data-t
|
(defctype gpgme-data-t :pointer "The GPGME data object type.")
|
||||||
(:wrapper :pointer
|
|
||||||
:to-c translate-gpgme-data-t-to-foreign)
|
|
||||||
"The GPGME data object type.")
|
|
||||||
|
|
||||||
;;; Wrappers for the libgpg-error library.
|
;;; Wrappers for the libgpg-error library.
|
||||||
|
|
||||||
(defctype gpgme-error-t
|
(defctype gpgme-error-t gpg-error::gpg-error-t "The GPGME error type.")
|
||||||
(:wrapper gpg-error::gpg-error-t
|
|
||||||
:from-c translate-gpgme-error-t-from-foreign
|
|
||||||
:to-c translate-gpgme-error-t-to-foreign)
|
|
||||||
"The GPGME error type.")
|
|
||||||
|
|
||||||
(defctype gpgme-error-no-signal-t
|
(defctype gpgme-error-no-signal-t gpg-error::gpg-error-t
|
||||||
(:wrapper gpg-error::gpg-error-t
|
|
||||||
:from-c translate-gpgme-error-no-signal-t-from-foreign)
|
|
||||||
"The GPGME error type (this version does not signal conditions in translation.")
|
"The GPGME error type (this version does not signal conditions in translation.")
|
||||||
|
|
||||||
(defctype gpgme-err-code-t gpg-error::gpg-err-code-t
|
(defctype gpgme-err-code-t gpg-error::gpg-err-code-t
|
||||||
@ -140,11 +141,11 @@
|
|||||||
(gpg-err-source err))
|
(gpg-err-source err))
|
||||||
|
|
||||||
(defun gpgme-strerror (err)
|
(defun gpgme-strerror (err)
|
||||||
"Return a string containing a description of the error code."
|
"Return a string containig a description of the error code."
|
||||||
(gpg-strerror err))
|
(gpg-strerror err))
|
||||||
|
|
||||||
(defun gpgme-strsource (err)
|
(defun gpgme-strsource (err)
|
||||||
"Return a string containing a description of the error source."
|
"Return a string containig a description of the error source."
|
||||||
(gpg-strsource err))
|
(gpg-strsource err))
|
||||||
|
|
||||||
(defun gpgme-err-code-from-errno (err)
|
(defun gpgme-err-code-from-errno (err)
|
||||||
@ -170,11 +171,7 @@
|
|||||||
(:none 0)
|
(:none 0)
|
||||||
(:binary 1)
|
(:binary 1)
|
||||||
(:base64 2)
|
(:base64 2)
|
||||||
(:armor 3)
|
(:armor 3))
|
||||||
(:url 4)
|
|
||||||
(:urlesc 5)
|
|
||||||
(:url0 6)
|
|
||||||
(:mime 7))
|
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
|
|
||||||
@ -185,11 +182,7 @@
|
|||||||
(:rsa-s 3)
|
(:rsa-s 3)
|
||||||
(:elg-e 16)
|
(:elg-e 16)
|
||||||
(:dsa 17)
|
(:dsa 17)
|
||||||
(:ecc 18)
|
(:elg 20))
|
||||||
(:elg 20)
|
|
||||||
(:ecdsa 301)
|
|
||||||
(:ecdh 302)
|
|
||||||
(:eddsa 303))
|
|
||||||
|
|
||||||
(defcenum gpgme-hash-algo-t
|
(defcenum gpgme-hash-algo-t
|
||||||
"Hash algorithms from libgcrypt."
|
"Hash algorithms from libgcrypt."
|
||||||
@ -203,7 +196,6 @@
|
|||||||
(:sha256 8)
|
(:sha256 8)
|
||||||
(:sha384 9)
|
(:sha384 9)
|
||||||
(:sha512 10)
|
(:sha512 10)
|
||||||
(:sha224 11)
|
|
||||||
(:md4 301)
|
(:md4 301)
|
||||||
(:crc32 302)
|
(:crc32 302)
|
||||||
(:crc32-rfc1510 303)
|
(:crc32-rfc1510 303)
|
||||||
@ -233,14 +225,7 @@
|
|||||||
(defcenum gpgme-protocol-t
|
(defcenum gpgme-protocol-t
|
||||||
"The available protocols."
|
"The available protocols."
|
||||||
(:openpgp 0)
|
(:openpgp 0)
|
||||||
(:cms 1)
|
(:cms 1))
|
||||||
(:gpgconf 2)
|
|
||||||
(:assuan 3)
|
|
||||||
(:g13 4)
|
|
||||||
(:uiserver 5)
|
|
||||||
(:spawn 6)
|
|
||||||
(:default 254)
|
|
||||||
(:unknown 255))
|
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
|
|
||||||
@ -249,10 +234,6 @@
|
|||||||
(:local 1)
|
(:local 1)
|
||||||
(:extern 2)
|
(:extern 2)
|
||||||
(:sigs 4)
|
(:sigs 4)
|
||||||
(:sig-notations)
|
|
||||||
(:with-secret 16)
|
|
||||||
(:with-tofu 32)
|
|
||||||
(:ephemeral 128)
|
|
||||||
(:validate 256))
|
(:validate 256))
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
@ -262,12 +243,10 @@
|
|||||||
(:human-readable 1)
|
(:human-readable 1)
|
||||||
(:critical 2))
|
(:critical 2))
|
||||||
|
|
||||||
(defctype gpgme-sig-notation-t
|
(defctype gpgme-sig-notation-t :pointer
|
||||||
(:wrapper :pointer
|
|
||||||
:from-c translate-gpgme-sig-notation-t-from-foreign)
|
|
||||||
"Signature notation pointer type.")
|
"Signature notation pointer type.")
|
||||||
|
|
||||||
;; FIXME: Doesn't this depend on endianness?
|
;; FIXME: Doesn't this depend on endianess?
|
||||||
(defbitfield (gpgme-sig-notation-bitfield :unsigned-int)
|
(defbitfield (gpgme-sig-notation-bitfield :unsigned-int)
|
||||||
(:human-readable 1)
|
(:human-readable 1)
|
||||||
(:critical 2))
|
(:critical 2))
|
||||||
@ -284,115 +263,15 @@
|
|||||||
|
|
||||||
;;;
|
;;;
|
||||||
|
|
||||||
|
;; FIXME: Add status codes.
|
||||||
(defcenum gpgme-status-code-t
|
(defcenum gpgme-status-code-t
|
||||||
"The possible status codes for the edit operation."
|
"The possible status codes for the edit operation."
|
||||||
(:eof 0)
|
(:eof 0)
|
||||||
(:enter 1)
|
(:enter 1))
|
||||||
(:leave 2)
|
|
||||||
(:abort 3)
|
|
||||||
(:goodsig 4)
|
|
||||||
(:badsig 5)
|
|
||||||
(:errsig 6)
|
|
||||||
(:badarmor 7)
|
|
||||||
(:rsa-or-idea 8)
|
|
||||||
(:keyexpired 9)
|
|
||||||
(:keyrevoked 10)
|
|
||||||
(:trust-undefined 11)
|
|
||||||
(:trust-never 12)
|
|
||||||
(:trust-marginal 13)
|
|
||||||
(:trust-fully 14)
|
|
||||||
(:trust-ultimate 15)
|
|
||||||
(:shm-info 16)
|
|
||||||
(:shm-get 17)
|
|
||||||
(:shm-get-bool 18)
|
|
||||||
(:shm-get-hidden 19)
|
|
||||||
(:need-passphrase 20)
|
|
||||||
(:validsig 21)
|
|
||||||
(:sig-id 22)
|
|
||||||
(:enc-to 23)
|
|
||||||
(:nodata 24)
|
|
||||||
(:bad-passphrase 25)
|
|
||||||
(:no-pubkey 26)
|
|
||||||
(:no-seckey 27)
|
|
||||||
(:need-passphrase-sym 28)
|
|
||||||
(:decryption-failed 29)
|
|
||||||
(:decryption-okay 30)
|
|
||||||
(:missing-passphrase 31)
|
|
||||||
(:good-passphrase 32)
|
|
||||||
(:goodmdc 33)
|
|
||||||
(:badmdc 34)
|
|
||||||
(:errmdc 35)
|
|
||||||
(:imported 36)
|
|
||||||
(:import-ok 37)
|
|
||||||
(:import-problem 38)
|
|
||||||
(:import-res 39)
|
|
||||||
(:file-start 40)
|
|
||||||
(:file-done 41)
|
|
||||||
(:file-error 42)
|
|
||||||
(:begin-decryption 43)
|
|
||||||
(:end-decryption 44)
|
|
||||||
(:begin-encryption 45)
|
|
||||||
(:end-encryption 46)
|
|
||||||
(:delete-problem 47)
|
|
||||||
(:get-bool 48)
|
|
||||||
(:get-line 49)
|
|
||||||
(:get-hidden 50)
|
|
||||||
(:got-it 51)
|
|
||||||
(:progress 52)
|
|
||||||
(:sig-created 53)
|
|
||||||
(:session-key 54)
|
|
||||||
(:notation-name 55)
|
|
||||||
(:notation-data 56)
|
|
||||||
(:policy-url 57)
|
|
||||||
(:begin-stream 58)
|
|
||||||
(:end-stream 59)
|
|
||||||
(:key-created 60)
|
|
||||||
(:userid-hint 61)
|
|
||||||
(:unexpected 62)
|
|
||||||
(:inv-recp 63)
|
|
||||||
(:no-recp 64)
|
|
||||||
(:already-signed 65)
|
|
||||||
(:sigexpired 66)
|
|
||||||
(:expsig 67)
|
|
||||||
(:expkeysig 68)
|
|
||||||
(:truncated 69)
|
|
||||||
(:error 70)
|
|
||||||
(:newsig 71)
|
|
||||||
(:revkeysig 72)
|
|
||||||
(:sig-subpacket 73)
|
|
||||||
(:need-passphrase-pin 74)
|
|
||||||
(:sc-op-failure 75)
|
|
||||||
(:sc-op-success 76)
|
|
||||||
(:cardctrl 77)
|
|
||||||
(:backup-key-created 78)
|
|
||||||
(:pka-trust-bad 79)
|
|
||||||
(:pka-trust-good 80)
|
|
||||||
(:plaintext 81)
|
|
||||||
(:inv-sgnr 82)
|
|
||||||
(:no-sgnr 83)
|
|
||||||
(:success 84)
|
|
||||||
(:decryption-info 85)
|
|
||||||
(:plaintext-length 86)
|
|
||||||
(:mountpoint 87)
|
|
||||||
(:pinentry-launched 88)
|
|
||||||
(:attribute 89)
|
|
||||||
(:begin-signing 90)
|
|
||||||
(:key-not-created 91)
|
|
||||||
(:inquire-maxlen 92)
|
|
||||||
(:failure 93)
|
|
||||||
(:key-considered 94)
|
|
||||||
(:tofu-user 95)
|
|
||||||
(:tofu-stats 96)
|
|
||||||
(:tofu-stats-long 97)
|
|
||||||
(:notation-flags 98)
|
|
||||||
(:decryption-compliance-mode 99)
|
|
||||||
(:verification-compliance-mode 100))
|
|
||||||
|
|
||||||
;;;
|
;;;
|
||||||
|
|
||||||
(defctype gpgme-engine-info-t
|
(defctype gpgme-engine-info-t :pointer
|
||||||
(:wrapper :pointer
|
|
||||||
:from-c translate-gpgme-engine-info-t-to-foreign)
|
|
||||||
"The engine information structure pointer type.")
|
"The engine information structure pointer type.")
|
||||||
|
|
||||||
(defcstruct gpgme-engine-info
|
(defcstruct gpgme-engine-info
|
||||||
@ -406,12 +285,9 @@
|
|||||||
|
|
||||||
;;;
|
;;;
|
||||||
|
|
||||||
(defctype gpgme-subkey-t
|
(defctype gpgme-subkey-t :pointer "A subkey from a key.")
|
||||||
(:wrapper :pointer
|
|
||||||
:from-c translate-gpgme-subkey-t-from-foreign)
|
|
||||||
"A subkey from a key.")
|
|
||||||
|
|
||||||
;; FIXME: Doesn't this depend on endianness?
|
;; FIXME: Doesn't this depend on endianess?
|
||||||
(defbitfield (gpgme-subkey-bitfield :unsigned-int)
|
(defbitfield (gpgme-subkey-bitfield :unsigned-int)
|
||||||
"The subkey bitfield."
|
"The subkey bitfield."
|
||||||
(:revoked 1)
|
(:revoked 1)
|
||||||
@ -423,9 +299,7 @@
|
|||||||
(:can-certify 64)
|
(:can-certify 64)
|
||||||
(:secret 128)
|
(:secret 128)
|
||||||
(:can-authenticate 256)
|
(:can-authenticate 256)
|
||||||
(:is-qualified 512)
|
(:is-qualified 512))
|
||||||
(:is-cardkey 1024)
|
|
||||||
(:is-de-vs 2048))
|
|
||||||
|
|
||||||
(defcstruct gpgme-subkey
|
(defcstruct gpgme-subkey
|
||||||
"Subkey from a key."
|
"Subkey from a key."
|
||||||
@ -440,12 +314,10 @@
|
|||||||
(expires :long))
|
(expires :long))
|
||||||
|
|
||||||
|
|
||||||
(defctype gpgme-key-sig-t
|
(defctype gpgme-key-sig-t :pointer
|
||||||
(:wrapper :pointer
|
|
||||||
:from-c translate-gpgme-key-sig-t-from-foreign)
|
|
||||||
"A signature on a user ID.")
|
"A signature on a user ID.")
|
||||||
|
|
||||||
;; FIXME: Doesn't this depend on endianness?
|
;; FIXME: Doesn't this depend on endianess?
|
||||||
(defbitfield (gpgme-key-sig-bitfield :unsigned-int)
|
(defbitfield (gpgme-key-sig-bitfield :unsigned-int)
|
||||||
"The key signature bitfield."
|
"The key signature bitfield."
|
||||||
(:revoked 1)
|
(:revoked 1)
|
||||||
@ -471,12 +343,10 @@
|
|||||||
(sig-class :unsigned-int))
|
(sig-class :unsigned-int))
|
||||||
|
|
||||||
|
|
||||||
(defctype gpgme-user-id-t
|
(defctype gpgme-user-id-t :pointer
|
||||||
(:wrapper :pointer
|
|
||||||
:from-c translate-gpgme-user-id-t-from-foreign)
|
|
||||||
"A user ID from a key.")
|
"A user ID from a key.")
|
||||||
|
|
||||||
;; FIXME: Doesn't this depend on endianness?
|
;; FIXME: Doesn't this depend on endianess?
|
||||||
(defbitfield (gpgme-user-id-bitfield :unsigned-int)
|
(defbitfield (gpgme-user-id-bitfield :unsigned-int)
|
||||||
"The user ID bitfield."
|
"The user ID bitfield."
|
||||||
(:revoked 1)
|
(:revoked 1)
|
||||||
@ -495,13 +365,10 @@
|
|||||||
(-last-keysig gpgme-key-sig-t))
|
(-last-keysig gpgme-key-sig-t))
|
||||||
|
|
||||||
|
|
||||||
(defctype gpgme-key-t
|
(defctype gpgme-key-t :pointer
|
||||||
(:wrapper :pointer
|
|
||||||
:from-c translate-gpgme-key-t-from-foreign
|
|
||||||
:to-c translate-gpgme-key-t-to-foreign)
|
|
||||||
"A key from the keyring.")
|
"A key from the keyring.")
|
||||||
|
|
||||||
;; FIXME: Doesn't this depend on endianness?
|
;; FIXME: Doesn't this depend on endianess?
|
||||||
(defbitfield (gpgme-key-bitfield :unsigned-int)
|
(defbitfield (gpgme-key-bitfield :unsigned-int)
|
||||||
"The key bitfield."
|
"The key bitfield."
|
||||||
(:revoked 1)
|
(:revoked 1)
|
||||||
@ -826,9 +693,7 @@
|
|||||||
|
|
||||||
;;;
|
;;;
|
||||||
|
|
||||||
(defctype gpgme-invalid-key-t
|
(defctype gpgme-invalid-key-t :pointer
|
||||||
(:wrapper :pointer
|
|
||||||
:from-c translate-gpgme-invalid-key-t-from-foreign)
|
|
||||||
"An invalid key structure.")
|
"An invalid key structure.")
|
||||||
|
|
||||||
(defcstruct gpgme-invalid-key
|
(defcstruct gpgme-invalid-key
|
||||||
@ -843,9 +708,7 @@
|
|||||||
"Encryption result structure."
|
"Encryption result structure."
|
||||||
(invalid-recipients gpgme-invalid-key-t))
|
(invalid-recipients gpgme-invalid-key-t))
|
||||||
|
|
||||||
(defctype gpgme-op-encrypt-result-t
|
(defctype gpgme-op-encrypt-result-t :pointer
|
||||||
(:wrapper :pointer
|
|
||||||
:from-c translate-gpgme-op-encrypt-result-t-from-foreign)
|
|
||||||
"An encryption result structure.")
|
"An encryption result structure.")
|
||||||
|
|
||||||
(defcfun ("gpgme_op_encrypt_result" c-gpgme-op-encrypt-result)
|
(defcfun ("gpgme_op_encrypt_result" c-gpgme-op-encrypt-result)
|
||||||
@ -853,15 +716,7 @@
|
|||||||
(ctx gpgme-ctx-t))
|
(ctx gpgme-ctx-t))
|
||||||
|
|
||||||
(defbitfield gpgme-encrypt-flags-t
|
(defbitfield gpgme-encrypt-flags-t
|
||||||
(:always-trust 1)
|
(:always-trust 1))
|
||||||
(:no-encrypt-to 2)
|
|
||||||
(:prepare 4)
|
|
||||||
(:expect-sign 8)
|
|
||||||
(:no-compress 16)
|
|
||||||
(:symmetric 32)
|
|
||||||
(:throw-keyids 64)
|
|
||||||
(:wrap 128)
|
|
||||||
(:want-address 256))
|
|
||||||
|
|
||||||
(defcfun ("gpgme_op_encrypt_start" c-gpgme-op-encrypt-start) gpgme-error-t
|
(defcfun ("gpgme_op_encrypt_start" c-gpgme-op-encrypt-start) gpgme-error-t
|
||||||
(ctx gpgme-ctx-t)
|
(ctx gpgme-ctx-t)
|
||||||
@ -894,9 +749,7 @@
|
|||||||
|
|
||||||
;;; Decryption.
|
;;; Decryption.
|
||||||
|
|
||||||
(defctype gpgme-recipient-t
|
(defctype gpgme-recipient-t :pointer
|
||||||
(:wrapper :pointer
|
|
||||||
:from-c translate-gpgme-recipient-t-from-foreign)
|
|
||||||
"A recipient structure.")
|
"A recipient structure.")
|
||||||
|
|
||||||
(defcstruct gpgme-recipient
|
(defcstruct gpgme-recipient
|
||||||
@ -909,9 +762,7 @@
|
|||||||
|
|
||||||
(defbitfield gpgme-op-decrypt-result-bitfield
|
(defbitfield gpgme-op-decrypt-result-bitfield
|
||||||
"Decryption result structure bitfield."
|
"Decryption result structure bitfield."
|
||||||
(:wrong-key-usage 1)
|
(:wrong-key-usage 1))
|
||||||
(:is-de-vs 2)
|
|
||||||
(:is-mine 4))
|
|
||||||
|
|
||||||
(defcstruct gpgme-op-decrypt-result
|
(defcstruct gpgme-op-decrypt-result
|
||||||
"Decryption result structure."
|
"Decryption result structure."
|
||||||
@ -920,9 +771,7 @@
|
|||||||
(recipients gpgme-recipient-t)
|
(recipients gpgme-recipient-t)
|
||||||
(file-name :string))
|
(file-name :string))
|
||||||
|
|
||||||
(defctype gpgme-op-decrypt-result-t
|
(defctype gpgme-op-decrypt-result-t :pointer
|
||||||
(:wrapper :pointer
|
|
||||||
:from-c translate-gpgme-op-decrypt-result-t-from-foreign)
|
|
||||||
"A decryption result structure.")
|
"A decryption result structure.")
|
||||||
|
|
||||||
(defcfun ("gpgme_op_decrypt_result" c-gpgme-op-decrypt-result)
|
(defcfun ("gpgme_op_decrypt_result" c-gpgme-op-decrypt-result)
|
||||||
@ -952,9 +801,7 @@
|
|||||||
|
|
||||||
;;; Signing.
|
;;; Signing.
|
||||||
|
|
||||||
(defctype gpgme-new-signature-t
|
(defctype gpgme-new-signature-t :pointer
|
||||||
(:wrapper :pointer
|
|
||||||
:from-c translate-gpgme-new-signature-t-from-foreign)
|
|
||||||
"A new signature structure.")
|
"A new signature structure.")
|
||||||
|
|
||||||
(defcstruct gpgme-new-signature
|
(defcstruct gpgme-new-signature
|
||||||
@ -974,9 +821,7 @@
|
|||||||
(invalid-signers gpgme-invalid-key-t)
|
(invalid-signers gpgme-invalid-key-t)
|
||||||
(signatures gpgme-new-signature-t))
|
(signatures gpgme-new-signature-t))
|
||||||
|
|
||||||
(defctype gpgme-op-sign-result-t
|
(defctype gpgme-op-sign-result-t :pointer
|
||||||
(:wrapper :pointer
|
|
||||||
:from-c translate-gpgme-op-sign-result-t-from-foreign)
|
|
||||||
"A signing result structure.")
|
"A signing result structure.")
|
||||||
|
|
||||||
(defcfun ("gpgme_op_sign_result" c-gpgme-op-sign-result)
|
(defcfun ("gpgme_op_sign_result" c-gpgme-op-sign-result)
|
||||||
@ -1009,21 +854,15 @@
|
|||||||
(:crl-missing #x0100)
|
(:crl-missing #x0100)
|
||||||
(:crl-too-old #x0200)
|
(:crl-too-old #x0200)
|
||||||
(:bad-policy #x0400)
|
(:bad-policy #x0400)
|
||||||
(:sys-error #x0800)
|
(:sys-error #x0800))
|
||||||
(:tofu-conflict #x1000))
|
|
||||||
|
|
||||||
(defctype gpgme-signature-t
|
(defctype gpgme-signature-t :pointer
|
||||||
(:wrapper :pointer
|
|
||||||
:from-c translate-gpgme-signature-t-from-foreign)
|
|
||||||
"A signature structure.")
|
"A signature structure.")
|
||||||
|
|
||||||
;; FIXME: Doesn't this depend on endianness?
|
;; FIXME: Doesn't this depend on endianess?
|
||||||
(defbitfield (gpgme-signature-bitfield :unsigned-int)
|
(defbitfield (gpgme-signature-bitfield :unsigned-int)
|
||||||
"The signature bitfield."
|
"The signature bitfield."
|
||||||
(:wrong-key-usage 1)
|
(:wrong-key-usage 1))
|
||||||
(:pka-trust 2)
|
|
||||||
(:chain-model 4)
|
|
||||||
(:is-de-vs 8))
|
|
||||||
|
|
||||||
(defcstruct gpgme-signature
|
(defcstruct gpgme-signature
|
||||||
"Signature structure."
|
"Signature structure."
|
||||||
@ -1045,9 +884,7 @@
|
|||||||
(signatures gpgme-signature-t)
|
(signatures gpgme-signature-t)
|
||||||
(file-name :string))
|
(file-name :string))
|
||||||
|
|
||||||
(defctype gpgme-op-verify-result-t
|
(defctype gpgme-op-verify-result-t :pointer
|
||||||
(:wrapper :pointer
|
|
||||||
:from-c translate-gpgme-op-verify-result-t-from-foreign)
|
|
||||||
"A verify result structure.")
|
"A verify result structure.")
|
||||||
|
|
||||||
(defcfun ("gpgme_op_verify_result" c-gpgme-op-verify-result)
|
(defcfun ("gpgme_op_verify_result" c-gpgme-op-verify-result)
|
||||||
@ -1076,9 +913,7 @@
|
|||||||
(:subkey #x0008)
|
(:subkey #x0008)
|
||||||
(:secret #x0010))
|
(:secret #x0010))
|
||||||
|
|
||||||
(defctype gpgme-import-status-t
|
(defctype gpgme-import-status-t :pointer
|
||||||
(:wrapper :pointer
|
|
||||||
:from-c translate-gpgme-import-status-t-from-foreign)
|
|
||||||
"An import status structure.")
|
"An import status structure.")
|
||||||
|
|
||||||
(defcstruct gpgme-import-status
|
(defcstruct gpgme-import-status
|
||||||
@ -1106,9 +941,7 @@
|
|||||||
(not-imported :int)
|
(not-imported :int)
|
||||||
(imports gpgme-import-status-t))
|
(imports gpgme-import-status-t))
|
||||||
|
|
||||||
(defctype gpgme-op-import-result-t
|
(defctype gpgme-op-import-result-t :pointer
|
||||||
(:wrapper :pointer
|
|
||||||
:from-c translate-gpgme-op-import-result-t-from-foreign)
|
|
||||||
"An import status result structure.")
|
"An import status result structure.")
|
||||||
|
|
||||||
(defcfun ("gpgme_op_import_result" c-gpgme-op-import-result)
|
(defcfun ("gpgme_op_import_result" c-gpgme-op-import-result)
|
||||||
@ -1144,8 +977,7 @@
|
|||||||
(defbitfield (gpgme-genkey-flags-t :unsigned-int)
|
(defbitfield (gpgme-genkey-flags-t :unsigned-int)
|
||||||
"Flags used for the key generation result bitfield."
|
"Flags used for the key generation result bitfield."
|
||||||
(:primary #x0001)
|
(:primary #x0001)
|
||||||
(:sub #x0002)
|
(:sub #x0002))
|
||||||
(:uid #x0004))
|
|
||||||
|
|
||||||
(defcstruct gpgme-op-genkey-result
|
(defcstruct gpgme-op-genkey-result
|
||||||
"Key generation result structure."
|
"Key generation result structure."
|
||||||
@ -1246,20 +1078,21 @@
|
|||||||
;;; cert-int-t is a helper type that takes care of representing the
|
;;; cert-int-t is a helper type that takes care of representing the
|
||||||
;;; default number of certs as NIL.
|
;;; default number of certs as NIL.
|
||||||
|
|
||||||
(defun translate-cert-int-t-from-foreign (value)
|
(defmethod translate-from-foreign (value (type (eql 'cert-int-t)))
|
||||||
(cond
|
(cond
|
||||||
((eql value +include-certs-default+) nil)
|
((eql value +include-certs-default+) nil)
|
||||||
(t value)))
|
(t value)))
|
||||||
|
|
||||||
(defun translate-cert-int-t-to-foreign (value)
|
(defmethod translate-to-foreign (value (type (eql 'cert-int-t)))
|
||||||
(cond
|
(cond
|
||||||
(value value)
|
(value value)
|
||||||
(t +include-certs-default+)))
|
(t +include-certs-default+)))
|
||||||
|
|
||||||
;;; string-or-nil-t translates a null pointer to NIL and vice versa.
|
;;; string-or-nil-t translates a null pointer to NIL and vice versa.
|
||||||
;;; Translation from foreign null pointer already works as expected.
|
;;; Translation from foreign null pointer already works as expected.
|
||||||
|
;;; FIXME: May the "to foreign" conversion problem be a bug in CFFI?
|
||||||
|
|
||||||
(defun translate-string-or-nil-t-to-foreign (value)
|
(defmethod translate-to-foreign (value (type (eql 'string-or-nil-t)))
|
||||||
(cond
|
(cond
|
||||||
(value value)
|
(value value)
|
||||||
(t (null-pointer))))
|
(t (null-pointer))))
|
||||||
@ -1276,12 +1109,12 @@
|
|||||||
;;; FIXME: Should we use a hash table (or struct, or clos) instead of
|
;;; FIXME: Should we use a hash table (or struct, or clos) instead of
|
||||||
;;; property list, as recommended by the Lisp FAQ?
|
;;; property list, as recommended by the Lisp FAQ?
|
||||||
|
|
||||||
(defun translate-gpgme-engine-info-t-from-foreign (value)
|
(defmethod translate-from-foreign (value (type (eql 'gpgme-engine-info-t)))
|
||||||
(cond
|
(cond
|
||||||
((null-pointer-p value) nil)
|
((null-pointer-p value) nil)
|
||||||
(t (with-foreign-slots
|
(t (with-foreign-slots
|
||||||
((next protocol file-name version req-version home-dir)
|
((next protocol file-name version req-version home-dir)
|
||||||
value (:struct gpgme-engine-info))
|
value gpgme-engine-info)
|
||||||
(append (list protocol (list
|
(append (list protocol (list
|
||||||
:file-name file-name
|
:file-name file-name
|
||||||
:version version
|
:version version
|
||||||
@ -1289,53 +1122,55 @@
|
|||||||
:home-dir home-dir))
|
:home-dir home-dir))
|
||||||
next)))))
|
next)))))
|
||||||
|
|
||||||
(defun translate-gpgme-invalid-key-t-from-foreign (value)
|
(defmethod translate-from-foreign (value (type (eql 'gpgme-invalid-key-t)))
|
||||||
(cond
|
(cond
|
||||||
((null-pointer-p value) nil)
|
((null-pointer-p value) nil)
|
||||||
(t (with-foreign-slots
|
(t (with-foreign-slots
|
||||||
((next fpr reason)
|
((next fpr reason)
|
||||||
value (:struct gpgme-invalid-key))
|
value gpgme-invalid-key)
|
||||||
(append (list (list :fpr fpr
|
(append (list (list :fpr fpr
|
||||||
:reason reason))
|
:reason reason))
|
||||||
next)))))
|
next)))))
|
||||||
|
|
||||||
(defun translate-gpgme-op-encrypt-result-t-from-foreign (value)
|
(defmethod translate-from-foreign (value
|
||||||
|
(type (eql 'gpgme-op-encrypt-result-t)))
|
||||||
(cond
|
(cond
|
||||||
((null-pointer-p value) nil)
|
((null-pointer-p value) nil)
|
||||||
(t (with-foreign-slots
|
(t (with-foreign-slots
|
||||||
((invalid-recipients)
|
((invalid-recipients)
|
||||||
value (:struct gpgme-op-encrypt-result))
|
value gpgme-op-encrypt-result)
|
||||||
(list :encrypt
|
(list :encrypt
|
||||||
(list :invalid-recipients invalid-recipients))))))
|
(list :invalid-recipients invalid-recipients))))))
|
||||||
|
|
||||||
(defun translate-gpgme-recipient-t-from-foreign (value)
|
(defmethod translate-from-foreign (value (type (eql 'gpgme-recipient-t)))
|
||||||
(cond
|
(cond
|
||||||
((null-pointer-p value) nil)
|
((null-pointer-p value) nil)
|
||||||
(t (with-foreign-slots
|
(t (with-foreign-slots
|
||||||
((next keyid pubkey-algo status)
|
((next keyid pubkey-algo status)
|
||||||
value (:struct gpgme-recipient))
|
value gpgme-recipient)
|
||||||
(append (list (list :keyid keyid
|
(append (list (list :keyid keyid
|
||||||
:pubkey-algo pubkey-algo
|
:pubkey-algo pubkey-algo
|
||||||
:status status))
|
:status status))
|
||||||
next)))))
|
next)))))
|
||||||
|
|
||||||
(defun translate-gpgme-op-decrypt-result-t-from-foreign (value)
|
(defmethod translate-from-foreign (value
|
||||||
|
(type (eql 'gpgme-op-decrypt-result-t)))
|
||||||
(cond
|
(cond
|
||||||
((null-pointer-p value) nil)
|
((null-pointer-p value) nil)
|
||||||
(t (with-foreign-slots
|
(t (with-foreign-slots
|
||||||
((unsupported-algorithm bitfield recipients file-name)
|
((unsupported-algorithm bitfield recipients file-name)
|
||||||
value (:struct gpgme-op-decrypt-result))
|
value gpgme-op-decrypt-result)
|
||||||
(list :decrypt (list :unsupported-algorithm unsupported-algorithm
|
(list :decrypt (list :unsupported-algorithm unsupported-algorithm
|
||||||
:bitfield bitfield
|
:bitfield bitfield
|
||||||
:recipients recipients
|
:recipients recipients
|
||||||
:file-name file-name))))))
|
:file-name file-name))))))
|
||||||
|
|
||||||
(defun translate-gpgme-new-signature-t-from-foreign (value)
|
(defmethod translate-from-foreign (value (type (eql 'gpgme-new-signature-t)))
|
||||||
(cond
|
(cond
|
||||||
((null-pointer-p value) nil)
|
((null-pointer-p value) nil)
|
||||||
(t (with-foreign-slots
|
(t (with-foreign-slots
|
||||||
((next type pubkey-algo hash-algo timestamp fpr sig-class)
|
((next type pubkey-algo hash-algo timestamp fpr sig-class)
|
||||||
value (:struct gpgme-new-signature))
|
value gpgme-new-signature)
|
||||||
(append (list (list :type type
|
(append (list (list :type type
|
||||||
:pubkey-algo pubkey-algo
|
:pubkey-algo pubkey-algo
|
||||||
:hash-algo hash-algo
|
:hash-algo hash-algo
|
||||||
@ -1344,23 +1179,24 @@
|
|||||||
:sig-class sig-class))
|
:sig-class sig-class))
|
||||||
next)))))
|
next)))))
|
||||||
|
|
||||||
(defun translate-gpgme-op-sign-result-t-from-foreign (value)
|
(defmethod translate-from-foreign (value
|
||||||
|
(type (eql 'gpgme-op-sign-result-t)))
|
||||||
(cond
|
(cond
|
||||||
((null-pointer-p value) nil)
|
((null-pointer-p value) nil)
|
||||||
(t (with-foreign-slots
|
(t (with-foreign-slots
|
||||||
((invalid-signers signatures)
|
((invalid-signers signatures)
|
||||||
value (:struct gpgme-op-sign-result))
|
value gpgme-op-sign-result)
|
||||||
(list :sign (list :invalid-signers invalid-signers
|
(list :sign (list :invalid-signers invalid-signers
|
||||||
:signatures signatures))))))
|
:signatures signatures))))))
|
||||||
|
|
||||||
(defun translate-gpgme-signature-t-from-foreign (value)
|
(defmethod translate-from-foreign (value (type (eql 'gpgme-signature-t)))
|
||||||
(cond
|
(cond
|
||||||
((null-pointer-p value) nil)
|
((null-pointer-p value) nil)
|
||||||
(t (with-foreign-slots
|
(t (with-foreign-slots
|
||||||
((next summary fpr status notations timestamp
|
((next summary fpr status notations timestamp
|
||||||
exp-timestamp bitfield validity validity-reason
|
exp-timestamp bitfield validity validity-reason
|
||||||
pubkey-algo hash-algo)
|
pubkey-algo hash-algo)
|
||||||
value (:struct gpgme-signature))
|
value gpgme-signature)
|
||||||
(append (list (list :summary summary
|
(append (list (list :summary summary
|
||||||
:fpr fpr
|
:fpr fpr
|
||||||
:status status
|
:status status
|
||||||
@ -1373,27 +1209,29 @@
|
|||||||
:pubkey-algo pubkey-algo))
|
:pubkey-algo pubkey-algo))
|
||||||
next)))))
|
next)))))
|
||||||
|
|
||||||
(defun translate-gpgme-op-verify-result-t-from-foreign (value)
|
(defmethod translate-from-foreign (value
|
||||||
|
(type (eql 'gpgme-op-verify-result-t)))
|
||||||
(cond
|
(cond
|
||||||
((null-pointer-p value) nil)
|
((null-pointer-p value) nil)
|
||||||
(t (with-foreign-slots
|
(t (with-foreign-slots
|
||||||
((signatures file-name)
|
((signatures file-name)
|
||||||
value (:struct gpgme-op-verify-result))
|
value gpgme-op-verify-result)
|
||||||
(list :verify (list :signatures signatures
|
(list :verify (list :signatures signatures
|
||||||
:file-name file-name))))))
|
:file-name file-name))))))
|
||||||
|
|
||||||
(defun translate-gpgme-import-status-t-from-foreign (value)
|
(defmethod translate-from-foreign (value (type (eql 'gpgme-import-status-t)))
|
||||||
(cond
|
(cond
|
||||||
((null-pointer-p value) nil)
|
((null-pointer-p value) nil)
|
||||||
(t (with-foreign-slots
|
(t (with-foreign-slots
|
||||||
((next fpr result status)
|
((next fpr result status)
|
||||||
value (:struct gpgme-import-status))
|
value gpgme-import-status)
|
||||||
(append (list (list :fpr fpr
|
(append (list (list :fpr fpr
|
||||||
:result result
|
:result result
|
||||||
:status status))
|
:status status))
|
||||||
next)))))
|
next)))))
|
||||||
|
|
||||||
(defun translate-gpgme-op-import-result-t-from-foreign (value)
|
(defmethod translate-from-foreign (value
|
||||||
|
(type (eql 'gpgme-op-import-result-t)))
|
||||||
(cond
|
(cond
|
||||||
((null-pointer-p value) nil)
|
((null-pointer-p value) nil)
|
||||||
(t (with-foreign-slots
|
(t (with-foreign-slots
|
||||||
@ -1402,7 +1240,7 @@
|
|||||||
new-revocations secret-read secret-imported
|
new-revocations secret-read secret-imported
|
||||||
secret-unchanged skipped-new-keys not-imported
|
secret-unchanged skipped-new-keys not-imported
|
||||||
imports)
|
imports)
|
||||||
value (:struct gpgme-op-import-result))
|
value gpgme-op-import-result)
|
||||||
(list :verify (list :considered considered
|
(list :verify (list :considered considered
|
||||||
:no-user-id no-user-id
|
:no-user-id no-user-id
|
||||||
:imported imported
|
:imported imported
|
||||||
@ -1434,19 +1272,19 @@
|
|||||||
(gpgme-strsource (gpgme-error-value c)))))
|
(gpgme-strsource (gpgme-error-value c)))))
|
||||||
(:documentation "Signalled when a GPGME function returns an error."))
|
(:documentation "Signalled when a GPGME function returns an error."))
|
||||||
|
|
||||||
(defun translate-gpgme-error-t-from-foreign (value)
|
(defmethod translate-from-foreign (value (name (eql 'gpgme-error-t)))
|
||||||
"Raise a GPGME-ERROR if VALUE is non-zero."
|
"Raise a GPGME-ERROR if VALUE is non-zero."
|
||||||
(when (not (eql (gpgme-err-code value) :gpg-err-no-error))
|
(when (not (eql (gpgme-err-code value) :gpg-err-no-error))
|
||||||
(error 'gpgme-error :gpgme-error value))
|
(error 'gpgme-error :gpgme-error value))
|
||||||
(gpg-err-canonicalize value))
|
(gpg-err-canonicalize value))
|
||||||
|
|
||||||
(defun translate-gpgme-error-t-to-foreign (value)
|
(defmethod translate-to-foreign (value (name (eql 'gpgme-error-t)))
|
||||||
"Canonicalize the error value."
|
"Canonicalize the error value."
|
||||||
(if (eql (gpgme-err-code value) :gpg-err-no-error)
|
(if (eql (gpgme-err-code value) :gpg-err-no-error)
|
||||||
0
|
0
|
||||||
(gpg-err-as-value value)))
|
(gpg-err-as-value value)))
|
||||||
|
|
||||||
(defun translate-gpgme-error-no-signal-t-from-foreign (value)
|
(defmethod translate-from-foreign (value (name (eql 'gpgme-error-no-signal-t)))
|
||||||
"Canonicalize the error value."
|
"Canonicalize the error value."
|
||||||
(gpg-err-canonicalize value))
|
(gpg-err-canonicalize value))
|
||||||
|
|
||||||
@ -1683,75 +1521,68 @@
|
|||||||
|
|
||||||
;;; The release callback removes the stream from the *data-handles*
|
;;; The release callback removes the stream from the *data-handles*
|
||||||
;;; hash and releases the CBS structure that is used as the key in
|
;;; hash and releases the CBS structure that is used as the key in
|
||||||
;;; that hash. It is implicitly invoked (through GPGME) by
|
;;; that hash. It is implicitely invoked (through GPGME) by
|
||||||
;;; gpgme-data-release.
|
;;; gpgme-data-release.
|
||||||
(defcallback data-release-cb :void ((handle :pointer))
|
(defcallback data-release-cb :void ((handle :pointer))
|
||||||
(unwind-protect (remhash (pointer-address handle) *data-handles*)
|
(unwind-protect (remhash (pointer-address handle) *data-handles*)
|
||||||
(when (not (null-pointer-p handle)) (foreign-free handle))))
|
(when (not (null-pointer-p handle)) (foreign-free handle))))
|
||||||
|
|
||||||
(defcallback data-read-cb ssize-t ((handle :pointer) (buffer :pointer)
|
(defcallback data-read-cb ssize-t ((handle :pointer) (buffer :pointer)
|
||||||
(size size-t))
|
(size size-t))
|
||||||
(when *debug* (format t "DEBUG: gpgme-data-read-cb: want ~A~%" size))
|
(when *debug* (format t "DEBUG: gpgme-data-read-cb: want ~A~%" size))
|
||||||
(let ((stream (gethash (pointer-address handle) *data-handles*)))
|
(let ((stream (gethash (pointer-address handle) *data-handles*)))
|
||||||
(cond
|
(cond
|
||||||
(stream
|
(stream
|
||||||
(let* ((stream-type (stream-element-type stream))
|
(let* ((stream-type (stream-element-type stream))
|
||||||
(seq (make-array size :element-type stream-type))
|
(seq (make-array size :element-type stream-type))
|
||||||
(read (read-sequence seq stream)))
|
(read (read-sequence seq stream)))
|
||||||
(cond
|
(loop for i from 0 to (- read 1)
|
||||||
((equal stream-type '(unsigned-byte 8))
|
do (setf (mem-aref buffer :unsigned-char i)
|
||||||
(dotimes (i read)
|
;;; FIXME: This is a half-assed attempt at
|
||||||
(setf (mem-aref buffer :unsigned-char i)
|
;;; supporting character streams.
|
||||||
(aref (the byte-array seq) i))))
|
(cond
|
||||||
((eql stream-type 'character)
|
((eql stream-type 'character)
|
||||||
(dotimes (i read)
|
(char-code (elt seq i)))
|
||||||
(setf (mem-aref buffer :unsigned-char i)
|
(t (coerce (elt seq i) stream-type)))))
|
||||||
(char-code (aref (the character-array seq) i)))))
|
(when *debug* (format t "DEBUG: gpgme-data-read-cb: read ~A~%" read))
|
||||||
(t
|
read))
|
||||||
(dotimes (i read)
|
(t (set-errno +ebadf+)
|
||||||
(setf (mem-aref buffer :unsigned-char i)
|
-1))))
|
||||||
(coerce (aref seq i) '(unsigned-byte 8))))))
|
|
||||||
(when *debug* (format t "DEBUG: gpgme-data-read-cb: read ~A~%" read))
|
|
||||||
read))
|
|
||||||
(t
|
|
||||||
(set-errno +ebadf+)
|
|
||||||
-1))))
|
|
||||||
|
|
||||||
(defcallback data-write-cb ssize-t ((handle :pointer) (buffer :pointer)
|
(defcallback data-write-cb ssize-t ((handle :pointer) (buffer :pointer)
|
||||||
(size size-t))
|
(size size-t))
|
||||||
(when *debug* (format t "DEBUG: gpgme-data-write-cb: want ~A~%" size))
|
(when *debug* (format t "DEBUG: gpgme-data-write-cb: want ~A~%" size))
|
||||||
(let ((stream (gethash (pointer-address handle) *data-handles*)))
|
(let ((stream (gethash (pointer-address handle) *data-handles*)))
|
||||||
(cond
|
(cond
|
||||||
(stream
|
(stream
|
||||||
(let* ((stream-type (stream-element-type stream))
|
(let* ((stream-type (stream-element-type stream))
|
||||||
(seq (make-array size :element-type stream-type)))
|
(seq (make-array size :element-type stream-type)))
|
||||||
(cond
|
(loop for i from 0 to (- size 1)
|
||||||
((equal stream-type '(unsigned-byte 8))
|
do (setf (elt seq i)
|
||||||
(dotimes (i size)
|
;;; FIXME: This is a half-assed attempt at
|
||||||
(setf (aref (the byte-array seq) i)
|
;;; supporting character streams.
|
||||||
(mem-aref buffer :unsigned-char i))))
|
(cond
|
||||||
((eql stream-type 'character)
|
((eql stream-type 'character)
|
||||||
(dotimes (i size)
|
(code-char (mem-aref buffer :unsigned-char i)))
|
||||||
(setf (aref (the character-array seq) i)
|
(t (coerce (mem-aref buffer :unsigned-char i)
|
||||||
(code-char (mem-aref buffer :unsigned-char i)))))
|
stream-type)))))
|
||||||
(t
|
(write-sequence seq stream)
|
||||||
(dotimes (i size)
|
;;; FIXME: What about write errors?
|
||||||
(setf (aref seq i)
|
size))
|
||||||
(coerce (mem-aref buffer :unsigned-char i) stream-type)))))
|
(t (set-errno +ebadf+)
|
||||||
(write-sequence seq stream)
|
-1))))
|
||||||
size))
|
|
||||||
(t
|
|
||||||
(set-errno +ebadf+)
|
|
||||||
-1))))
|
|
||||||
|
|
||||||
;;; This little helper macro allows us to swallow the cbs structure by
|
;;; This little helper macro allows us to swallow the cbs structure by
|
||||||
;;; simply setting it to a null pointer, but still protect against
|
;;; simply setting it to a null pointer, but still protect against
|
||||||
;;; conditions.
|
;;; conditions.
|
||||||
(defmacro with-cbs-swallowed ((cbs) &body body)
|
(defmacro with-cbs-swallowed ((cbs) &body body)
|
||||||
`(let ((,cbs (foreign-alloc '(:struct gpgme-data-cbs))))
|
`(let ((,cbs (foreign-alloc 'gpgme-data-cbs)))
|
||||||
(unwind-protect (progn ,@body)
|
(unwind-protect (progn ,@body)
|
||||||
(when (not (null-pointer-p ,cbs)) (foreign-free ,cbs)))))
|
(when (not (null-pointer-p ,cbs)) (foreign-free ,cbs)))))
|
||||||
|
|
||||||
|
;;; FIXME: Wrap the object and attach to it a finalizer. Requires new
|
||||||
|
;;; CFFI. Should we use an OO interface, ie make-instance? For now,
|
||||||
|
;;; we do not provide direct access to data objects.
|
||||||
(defun gpgme-data-new (stream &key encoding file-name)
|
(defun gpgme-data-new (stream &key encoding file-name)
|
||||||
"Allocate a new GPGME data object for STREAM."
|
"Allocate a new GPGME data object for STREAM."
|
||||||
(with-foreign-object (dh-p 'gpgme-data-t)
|
(with-foreign-object (dh-p 'gpgme-data-t)
|
||||||
@ -1761,14 +1592,12 @@
|
|||||||
;;; unique C pointer as handle anyway to look up the stream in the
|
;;; unique C pointer as handle anyway to look up the stream in the
|
||||||
;;; callback. This is a convenient one to use.
|
;;; callback. This is a convenient one to use.
|
||||||
(with-cbs-swallowed (cbs)
|
(with-cbs-swallowed (cbs)
|
||||||
(setf (foreign-slot-value cbs '(:struct gpgme-data-cbs) 'read)
|
(setf
|
||||||
(callback data-read-cb))
|
(foreign-slot-value cbs 'gpgme-data-cbs 'read) (callback data-read-cb)
|
||||||
(setf (foreign-slot-value cbs '(:struct gpgme-data-cbs) 'write)
|
(foreign-slot-value cbs 'gpgme-data-cbs 'write) (callback data-write-cb)
|
||||||
(callback data-write-cb))
|
(foreign-slot-value cbs 'gpgme-data-cbs 'seek) (null-pointer)
|
||||||
(setf (foreign-slot-value cbs '(:struct gpgme-data-cbs) 'seek)
|
(foreign-slot-value cbs 'gpgme-data-cbs 'release) (callback
|
||||||
(null-pointer))
|
data-release-cb))
|
||||||
(setf (foreign-slot-value cbs '(:struct gpgme-data-cbs) 'release)
|
|
||||||
(callback data-release-cb))
|
|
||||||
(c-gpgme-data-new-from-cbs dh-p cbs cbs)
|
(c-gpgme-data-new-from-cbs dh-p cbs cbs)
|
||||||
(let ((dh (mem-ref dh-p 'gpgme-data-t)))
|
(let ((dh (mem-ref dh-p 'gpgme-data-t)))
|
||||||
(when encoding (gpgme-data-set-encoding dh encoding))
|
(when encoding (gpgme-data-set-encoding dh encoding))
|
||||||
@ -1783,40 +1612,19 @@
|
|||||||
(when *debug* (format t "DEBUG: gpgme-data-new: ~A~%" dh))
|
(when *debug* (format t "DEBUG: gpgme-data-new: ~A~%" dh))
|
||||||
dh))))
|
dh))))
|
||||||
|
|
||||||
;;; This function releases a GPGME data object. It implicitly
|
;;; This function releases a GPGME data object. It implicitely
|
||||||
;;; invokes the data-release-cb function to clean up associated junk.
|
;;; invokes the data-release-cb function to clean up associated junk.
|
||||||
(defun gpgme-data-release (dh)
|
(defun gpgme-data-release (dh)
|
||||||
"Release a GPGME data object."
|
"Release a GPGME data object."
|
||||||
(when *debug* (format t "DEBUG: gpgme-data-release: ~A~%" dh))
|
(when *debug* (format t "DEBUG: gpgme-data-release: ~A~%" dh))
|
||||||
(c-gpgme-data-release dh))
|
(c-gpgme-data-release dh))
|
||||||
|
|
||||||
(defclass data ()
|
|
||||||
(c-data) ; The C data object pointer
|
|
||||||
(:documentation "The GPGME data type."))
|
|
||||||
|
|
||||||
(defmethod initialize-instance :after ((data data) &key streamspec
|
|
||||||
&allow-other-keys)
|
|
||||||
(let ((c-data (if (listp streamspec)
|
|
||||||
(apply #'gpgme-data-new streamspec)
|
|
||||||
(gpgme-data-new streamspec)))
|
|
||||||
(cleanup t))
|
|
||||||
(unwind-protect
|
|
||||||
(progn
|
|
||||||
(setf (slot-value data 'c-data) c-data)
|
|
||||||
(finalize data (lambda () (gpgme-data-release c-data)))
|
|
||||||
(setf cleanup nil))
|
|
||||||
(if cleanup (gpgme-data-release c-data)))))
|
|
||||||
|
|
||||||
(defun translate-gpgme-data-t-to-foreign (value)
|
|
||||||
;; Allow a pointer to be passed directly for the finalizer to work.
|
|
||||||
(cond
|
|
||||||
((null value) (null-pointer))
|
|
||||||
((pointerp value) value)
|
|
||||||
(t (slot-value value 'c-data))))
|
|
||||||
|
|
||||||
(defmacro with-gpgme-data ((dh streamspec) &body body)
|
(defmacro with-gpgme-data ((dh streamspec) &body body)
|
||||||
`(let ((,dh (make-instance 'data :streamspec ,streamspec)))
|
`(let ((,dh (if (listp ,streamspec)
|
||||||
,@body))
|
(apply 'gpgme-data-new ,streamspec)
|
||||||
|
(gpgme-data-new ,streamspec))))
|
||||||
|
(unwind-protect (progn ,@body)
|
||||||
|
(when (not (null-pointer-p ,dh)) (gpgme-data-release ,dh)))))
|
||||||
|
|
||||||
(defun gpgme-data-get-encoding (dh)
|
(defun gpgme-data-get-encoding (dh)
|
||||||
"Get the encoding associated with the data object DH."
|
"Get the encoding associated with the data object DH."
|
||||||
@ -1885,7 +1693,7 @@
|
|||||||
(setf cleanup nil))
|
(setf cleanup nil))
|
||||||
(if cleanup (gpgme-release c-ctx)))))
|
(if cleanup (gpgme-release c-ctx)))))
|
||||||
|
|
||||||
(defun translate-gpgme-ctx-t-to-foreign (value)
|
(defmethod translate-to-foreign (value (type (eql 'gpgme-ctx-t)))
|
||||||
;; Allow a pointer to be passed directly for the finalizer to work.
|
;; Allow a pointer to be passed directly for the finalizer to work.
|
||||||
(if (pointerp value) value (slot-value value 'c-ctx)))
|
(if (pointerp value) value (slot-value value 'c-ctx)))
|
||||||
|
|
||||||
@ -1907,7 +1715,7 @@
|
|||||||
(:documentation "Set the protocol of CONTEXT to PROTOCOL."))
|
(:documentation "Set the protocol of CONTEXT to PROTOCOL."))
|
||||||
|
|
||||||
;;; FIXME: Adjust translator to reject invalid protocols. Currently,
|
;;; FIXME: Adjust translator to reject invalid protocols. Currently,
|
||||||
;;; specifying an invalid protocol throws a "NIL is not 32 signed int"
|
;;; specifing an invalid protocol throws a "NIL is not 32 signed int"
|
||||||
;;; error. This is suboptimal.
|
;;; error. This is suboptimal.
|
||||||
(defmethod (setf protocol) (protocol (ctx context))
|
(defmethod (setf protocol) (protocol (ctx context))
|
||||||
(gpgme-set-protocol ctx protocol))
|
(gpgme-set-protocol ctx protocol))
|
||||||
@ -2040,11 +1848,11 @@
|
|||||||
(setf (slot-value key 'c-key) c-key)
|
(setf (slot-value key 'c-key) c-key)
|
||||||
(finalize key (lambda () (gpgme-key-unref c-key))))
|
(finalize key (lambda () (gpgme-key-unref c-key))))
|
||||||
|
|
||||||
(defun translate-gpgme-key-t-from-foreign (value)
|
(defmethod translate-from-foreign (value (type (eql 'gpgme-key-t)))
|
||||||
(when *debug* (format t "DEBUG: import key: ~A~%" value))
|
(when *debug* (format t "DEBUG: import key: ~A~%" value))
|
||||||
(make-instance 'key :c-key value))
|
(make-instance 'key :c-key value))
|
||||||
|
|
||||||
(defun translate-gpgme-key-t-to-foreign (value)
|
(defmethod translate-to-foreign (value (type (eql 'gpgme-key-t)))
|
||||||
;; Allow a pointer to be passed directly for the finalizer to work.
|
;; Allow a pointer to be passed directly for the finalizer to work.
|
||||||
(if (pointerp value) value (slot-value value 'c-key)))
|
(if (pointerp value) value (slot-value value 'c-key)))
|
||||||
|
|
||||||
@ -2059,12 +1867,12 @@
|
|||||||
;;; and zero length value (omit?) and human-readable (convert to string).
|
;;; and zero length value (omit?) and human-readable (convert to string).
|
||||||
;;; FIXME: Turn binary data into sequence or vector or what it should be.
|
;;; FIXME: Turn binary data into sequence or vector or what it should be.
|
||||||
;;; FIXME: Turn the whole thing into a hash?
|
;;; FIXME: Turn the whole thing into a hash?
|
||||||
(defun translate-gpgme-sig-notation-t-from-foreign (value)
|
(defmethod translate-from-foreign (value (type (eql 'gpgme-sig-notation-t)))
|
||||||
(cond
|
(cond
|
||||||
((null-pointer-p value) nil)
|
((null-pointer-p value) nil)
|
||||||
(t (with-foreign-slots
|
(t (with-foreign-slots
|
||||||
((next name value name-len value-len flags bitfield)
|
((next name value name-len value-len flags bitfield)
|
||||||
value (:struct gpgme-sig-notation))
|
value gpgme-sig-notation)
|
||||||
(append (list (list
|
(append (list (list
|
||||||
:name name
|
:name name
|
||||||
:value value
|
:value value
|
||||||
@ -2075,12 +1883,12 @@
|
|||||||
next)))))
|
next)))))
|
||||||
|
|
||||||
;;; FIXME: Deal nicer with timestamps. bitfield field name?
|
;;; FIXME: Deal nicer with timestamps. bitfield field name?
|
||||||
(defun translate-gpgme-subkey-t-from-foreign (value)
|
(defmethod translate-from-foreign (value (type (eql 'gpgme-subkey-t)))
|
||||||
(cond
|
(cond
|
||||||
((null-pointer-p value) nil)
|
((null-pointer-p value) nil)
|
||||||
(t (with-foreign-slots
|
(t (with-foreign-slots
|
||||||
((next bitfield pubkey-algo length keyid fpr timestamp expires)
|
((next bitfield pubkey-algo length keyid fpr timestamp expires)
|
||||||
value (:struct gpgme-subkey))
|
value gpgme-subkey)
|
||||||
(append (list (list
|
(append (list (list
|
||||||
:bitfield bitfield
|
:bitfield bitfield
|
||||||
:pubkey-algo pubkey-algo
|
:pubkey-algo pubkey-algo
|
||||||
@ -2091,13 +1899,13 @@
|
|||||||
:expires expires))
|
:expires expires))
|
||||||
next)))))
|
next)))))
|
||||||
|
|
||||||
(defun translate-gpgme-key-sig-t-from-foreign (value)
|
(defmethod translate-from-foreign (value (type (eql 'gpgme-key-sig-t)))
|
||||||
(cond
|
(cond
|
||||||
((null-pointer-p value) nil)
|
((null-pointer-p value) nil)
|
||||||
(t (with-foreign-slots
|
(t (with-foreign-slots
|
||||||
((next bitfield pubkey-algo keyid timestamp expires status
|
((next bitfield pubkey-algo keyid timestamp expires status
|
||||||
uid name email comment sig-class)
|
uid name email comment sig-class)
|
||||||
value (:struct gpgme-key-sig))
|
value gpgme-key-sig)
|
||||||
(append (list (list
|
(append (list (list
|
||||||
:bitfield bitfield
|
:bitfield bitfield
|
||||||
:pubkey-algo pubkey-algo
|
:pubkey-algo pubkey-algo
|
||||||
@ -2112,12 +1920,12 @@
|
|||||||
:sig-class sig-class))
|
:sig-class sig-class))
|
||||||
next)))))
|
next)))))
|
||||||
|
|
||||||
(defun translate-gpgme-user-id-t-from-foreign (value)
|
(defmethod translate-from-foreign (value (type (eql 'gpgme-user-id-t)))
|
||||||
(cond
|
(cond
|
||||||
((null-pointer-p value) nil)
|
((null-pointer-p value) nil)
|
||||||
(t (with-foreign-slots
|
(t (with-foreign-slots
|
||||||
((next bitfield validity uid name email comment signatures)
|
((next bitfield validity uid name email comment signatures)
|
||||||
value (:struct gpgme-user-id))
|
value gpgme-user-id)
|
||||||
(append (list (list
|
(append (list (list
|
||||||
:bitfield bitfield
|
:bitfield bitfield
|
||||||
:validity validity
|
:validity validity
|
||||||
@ -2133,7 +1941,7 @@
|
|||||||
(with-foreign-slots
|
(with-foreign-slots
|
||||||
((bitfield protocol issuer-serial issuer-name chain-id
|
((bitfield protocol issuer-serial issuer-name chain-id
|
||||||
owner-trust subkeys uids keylist-mode)
|
owner-trust subkeys uids keylist-mode)
|
||||||
c-key (:struct gpgme-key))
|
c-key gpgme-key)
|
||||||
(list
|
(list
|
||||||
:bitfield bitfield
|
:bitfield bitfield
|
||||||
:protocol protocol
|
:protocol protocol
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
# Makefile.am for GPGMEPP.
|
|
||||||
# Copyright (C) 2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
# Software engineering by Intevation GmbH
|
|
||||||
#
|
|
||||||
# This file is part of GPGMEPP.
|
|
||||||
#
|
|
||||||
# GPGME-CL 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 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# GPGME-CL 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 <https://gnu.org/licenses/>.
|
|
||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
||||||
|
|
||||||
if RUN_GPG_TESTS
|
|
||||||
tests = tests
|
|
||||||
else
|
|
||||||
tests =
|
|
||||||
endif
|
|
||||||
|
|
||||||
SUBDIRS = src ${tests}
|
|
||||||
|
|
||||||
EXTRA_DIST = README
|
|
101
lang/cpp/README
101
lang/cpp/README
@ -1,101 +0,0 @@
|
|||||||
GpgMEpp - C++ bindings/wrapper for GPGME
|
|
||||||
----------------------------------------
|
|
||||||
Based on KF5gpgmepp
|
|
||||||
|
|
||||||
Overview
|
|
||||||
--------
|
|
||||||
|
|
||||||
GpgMEpp is a C++ wrapper (or C++ bindings) for the GnuPG project's
|
|
||||||
gpgme (GnuPG Made Easy) library, version 0.4.4 and later.
|
|
||||||
|
|
||||||
It is fairly complete, with some minor things still missing (in
|
|
||||||
particular, the key edit interface).
|
|
||||||
|
|
||||||
The design principles of this library are as follows:
|
|
||||||
|
|
||||||
1. A value-based interface (most clases are implicitly shared)
|
|
||||||
2. Callbacks are replaced by C++ interfaces (classes with only
|
|
||||||
abstract methods).
|
|
||||||
3. No exceptions are thrown
|
|
||||||
4. There is (as yet) no explicit support for multi-threaded use
|
|
||||||
(other than what gpgme itself provides; most notably the
|
|
||||||
refcounting for implicit sharing is not thread-safe)
|
|
||||||
5. To avoid binary incompatible interface changes, we make
|
|
||||||
extensive use of the d-pointer pattern and avoid virtual
|
|
||||||
methods; any polymorphism present is already provided by gpgme
|
|
||||||
itself, anyway (see e.g. Data). A notable exception of the
|
|
||||||
no-virtuals rule is the use of abstract classes to cover
|
|
||||||
C-callbacks.
|
|
||||||
6. Use of STL containers for improved memory management and
|
|
||||||
dealing with lists.
|
|
||||||
7. Complete abstraction of the C-API so "gpgme.h" should not
|
|
||||||
be needed in your project using GpgME++.
|
|
||||||
8. Abstraction of GnuPG's edit-key interface by prepared
|
|
||||||
Editinteractor classes.
|
|
||||||
|
|
||||||
GpgMEpp was originally developed as part of the KDEPIM community.
|
|
||||||
|
|
||||||
Usage
|
|
||||||
-----
|
|
||||||
|
|
||||||
The usage pattern of GpgMEpp closely follows GPGMEs core usage
|
|
||||||
pattern so the documentation for GPGME itself provides a good
|
|
||||||
way to start.
|
|
||||||
|
|
||||||
The context structure in GPGME is mapped to a Context object in
|
|
||||||
GpgMEpp. Additional convenience code provides Data objects and
|
|
||||||
a Dataprovider interface that can be used to implement GPGME's
|
|
||||||
data with any subclass by implementing the right callbacks.
|
|
||||||
|
|
||||||
EditInteractor subclasses provide ready to use classes for
|
|
||||||
common --edit-key tasks. You can implement your own editinteractor
|
|
||||||
classes by implementing the EditInteractor interface and using
|
|
||||||
your subclass as an interactor in the edit function.
|
|
||||||
|
|
||||||
Example to set the ownertrust of a key:
|
|
||||||
|
|
||||||
/* Create an edit interactor */
|
|
||||||
EditInteractor *ei = new GpgSetOwnerTrustEditInteractor(Key::Ultimate);
|
|
||||||
/* Obtain a Context */
|
|
||||||
Context *ctx = Context::createForProtocol(Protocol::OpenPGP);
|
|
||||||
/* Create an in memory data object */
|
|
||||||
Data data;
|
|
||||||
/* Start the edit on some key previously obtained. */
|
|
||||||
Error e = ctx->edit(key, std::unique_ptr<EditInteractor>(ei), data);
|
|
||||||
/* Errors provide boolean comparison */
|
|
||||||
if (!e)
|
|
||||||
...
|
|
||||||
/* Delete the context */
|
|
||||||
delete ctx;
|
|
||||||
|
|
||||||
Examples / Tests
|
|
||||||
----------------
|
|
||||||
|
|
||||||
GpgMEpp is tested through the Qt API. You can refer to the
|
|
||||||
tests in qt/tests for examples of usage or refer to
|
|
||||||
the actual QGpgME*Job.cpp implementations which rely
|
|
||||||
on GpgMEpp and should cover most use cases.
|
|
||||||
|
|
||||||
Hacking
|
|
||||||
-------
|
|
||||||
|
|
||||||
GpgMEpp follows KDE Coding styles. See:
|
|
||||||
https://techbase.kde.org/Policies/Frameworks_Coding_Style
|
|
||||||
for more info.
|
|
||||||
|
|
||||||
License
|
|
||||||
-------
|
|
||||||
GPGMEpp is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
GPGMEpp 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
@ -1,99 +0,0 @@
|
|||||||
# CMake Config file for GPGMEPP.
|
|
||||||
# Copyright (C) 2016 Intevation GmbH
|
|
||||||
#
|
|
||||||
# This file is part of GPGMEPP.
|
|
||||||
#
|
|
||||||
# GPGME-CL 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 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# GPGME-CL 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 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
|
|
||||||
|
|
||||||
# based on a generated file from cmake.
|
|
||||||
# Generated by CMake 3.0.2
|
|
||||||
|
|
||||||
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5)
|
|
||||||
message(FATAL_ERROR "CMake >= 2.6.0 required")
|
|
||||||
endif()
|
|
||||||
cmake_policy(PUSH)
|
|
||||||
cmake_policy(VERSION 2.6)
|
|
||||||
#----------------------------------------------------------------
|
|
||||||
# Generated CMake target import file.
|
|
||||||
#----------------------------------------------------------------
|
|
||||||
|
|
||||||
# Commands may need to know the format version.
|
|
||||||
set(CMAKE_IMPORT_FILE_VERSION 1)
|
|
||||||
|
|
||||||
# Protect against multiple inclusion, which would fail when already imported targets are added once more.
|
|
||||||
set(_targetsDefined)
|
|
||||||
set(_targetsNotDefined)
|
|
||||||
set(_expectedTargets)
|
|
||||||
foreach(_expectedTarget Gpgmepp)
|
|
||||||
list(APPEND _expectedTargets ${_expectedTarget})
|
|
||||||
if(NOT TARGET ${_expectedTarget})
|
|
||||||
list(APPEND _targetsNotDefined ${_expectedTarget})
|
|
||||||
endif()
|
|
||||||
if(TARGET ${_expectedTarget})
|
|
||||||
list(APPEND _targetsDefined ${_expectedTarget})
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
if("${_targetsDefined}" STREQUAL "${_expectedTargets}")
|
|
||||||
set(CMAKE_IMPORT_FILE_VERSION)
|
|
||||||
cmake_policy(POP)
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
if(NOT "${_targetsDefined}" STREQUAL "")
|
|
||||||
message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n")
|
|
||||||
endif()
|
|
||||||
unset(_targetsDefined)
|
|
||||||
unset(_targetsNotDefined)
|
|
||||||
unset(_expectedTargets)
|
|
||||||
|
|
||||||
# Create imported target Gpgmepp
|
|
||||||
add_library(Gpgmepp SHARED IMPORTED)
|
|
||||||
|
|
||||||
set_target_properties(Gpgmepp PROPERTIES
|
|
||||||
IMPORTED_IMPLIB "@resolved_libdir@/libgpgmepp.dll.a"
|
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "@resolved_includedir@/gpgme++;@resolved_includedir@"
|
|
||||||
INTERFACE_LINK_LIBRARIES "pthread;@resolved_libdir@/libgpgme.dll.a;@LIBASSUAN_LIBS@"
|
|
||||||
IMPORTED_LOCATION "@resolved_bindir@/libgpgmepp-6.dll"
|
|
||||||
)
|
|
||||||
list(APPEND _IMPORT_CHECK_TARGETS Gpgmepp )
|
|
||||||
list(APPEND _IMPORT_CHECK_FILES_FOR_Gpgmepp "@resolved_libdir@/libgpgmepp.dll.a" "@resolved_bindir@/libgpgmepp-6.dll" )
|
|
||||||
|
|
||||||
|
|
||||||
if(CMAKE_VERSION VERSION_LESS 2.8.12)
|
|
||||||
message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Loop over all imported files and verify that they actually exist
|
|
||||||
foreach(target ${_IMPORT_CHECK_TARGETS} )
|
|
||||||
foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )
|
|
||||||
if(NOT EXISTS "${file}" )
|
|
||||||
message(FATAL_ERROR "The imported target \"${target}\" references the file
|
|
||||||
\"${file}\"
|
|
||||||
but this file does not exist. Possible reasons include:
|
|
||||||
* The file was deleted, renamed, or moved to another location.
|
|
||||||
* An install or uninstall procedure did not complete successfully.
|
|
||||||
* The installation package was faulty and contained
|
|
||||||
\"${CMAKE_CURRENT_LIST_FILE}\"
|
|
||||||
but not all the files it references.
|
|
||||||
")
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
unset(_IMPORT_CHECK_FILES_FOR_${target})
|
|
||||||
endforeach()
|
|
||||||
unset(_IMPORT_CHECK_TARGETS)
|
|
||||||
|
|
||||||
# Commands beyond this point should not need to know the version.
|
|
||||||
set(CMAKE_IMPORT_FILE_VERSION)
|
|
||||||
cmake_policy(POP)
|
|
@ -1,95 +0,0 @@
|
|||||||
# CMake Config file for GPGMEPP.
|
|
||||||
# Copyright (C) 2016 Intevation GmbH
|
|
||||||
#
|
|
||||||
# This file is part of GPGMEPP.
|
|
||||||
#
|
|
||||||
# GPGME-CL 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 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# GPGME-CL 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 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
|
|
||||||
|
|
||||||
# based on a generated file from cmake.
|
|
||||||
# Generated by CMake 3.0.2
|
|
||||||
|
|
||||||
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5)
|
|
||||||
message(FATAL_ERROR "CMake >= 2.6.0 required")
|
|
||||||
endif()
|
|
||||||
cmake_policy(PUSH)
|
|
||||||
cmake_policy(VERSION 2.6)
|
|
||||||
#----------------------------------------------------------------
|
|
||||||
# Generated CMake target import file.
|
|
||||||
#----------------------------------------------------------------
|
|
||||||
|
|
||||||
# Commands may need to know the format version.
|
|
||||||
set(CMAKE_IMPORT_FILE_VERSION 1)
|
|
||||||
|
|
||||||
# Protect against multiple inclusion, which would fail when already imported targets are added once more.
|
|
||||||
set(_targetsDefined)
|
|
||||||
set(_targetsNotDefined)
|
|
||||||
set(_expectedTargets)
|
|
||||||
foreach(_expectedTarget Gpgmepp)
|
|
||||||
list(APPEND _expectedTargets ${_expectedTarget})
|
|
||||||
if(NOT TARGET ${_expectedTarget})
|
|
||||||
list(APPEND _targetsNotDefined ${_expectedTarget})
|
|
||||||
endif()
|
|
||||||
if(TARGET ${_expectedTarget})
|
|
||||||
list(APPEND _targetsDefined ${_expectedTarget})
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
if("${_targetsDefined}" STREQUAL "${_expectedTargets}")
|
|
||||||
set(CMAKE_IMPORT_FILE_VERSION)
|
|
||||||
cmake_policy(POP)
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
if(NOT "${_targetsDefined}" STREQUAL "")
|
|
||||||
message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n")
|
|
||||||
endif()
|
|
||||||
unset(_targetsDefined)
|
|
||||||
unset(_targetsNotDefined)
|
|
||||||
unset(_expectedTargets)
|
|
||||||
|
|
||||||
# Create imported target Gpgmepp
|
|
||||||
add_library(Gpgmepp SHARED IMPORTED)
|
|
||||||
|
|
||||||
set_target_properties(Gpgmepp PROPERTIES
|
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "@resolved_includedir@/gpgme++;@resolved_includedir@"
|
|
||||||
INTERFACE_LINK_LIBRARIES "pthread;@resolved_libdir@/libgpgme@libsuffix@;@LIBASSUAN_LIBS@"
|
|
||||||
IMPORTED_LOCATION "@resolved_libdir@/libgpgmepp@libsuffix@"
|
|
||||||
)
|
|
||||||
|
|
||||||
if(CMAKE_VERSION VERSION_LESS 2.8.12)
|
|
||||||
message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Loop over all imported files and verify that they actually exist
|
|
||||||
foreach(target ${_IMPORT_CHECK_TARGETS} )
|
|
||||||
foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )
|
|
||||||
if(NOT EXISTS "${file}" )
|
|
||||||
message(FATAL_ERROR "The imported target \"${target}\" references the file
|
|
||||||
\"${file}\"
|
|
||||||
but this file does not exist. Possible reasons include:
|
|
||||||
* The file was deleted, renamed, or moved to another location.
|
|
||||||
* An install or uninstall procedure did not complete successfully.
|
|
||||||
* The installation package was faulty and contained
|
|
||||||
\"${CMAKE_CURRENT_LIST_FILE}\"
|
|
||||||
but not all the files it references.
|
|
||||||
")
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
unset(_IMPORT_CHECK_FILES_FOR_${target})
|
|
||||||
endforeach()
|
|
||||||
unset(_IMPORT_CHECK_TARGETS)
|
|
||||||
|
|
||||||
# Commands beyond this point should not need to know the version.
|
|
||||||
set(CMAKE_IMPORT_FILE_VERSION)
|
|
||||||
cmake_policy(POP)
|
|
@ -1,31 +0,0 @@
|
|||||||
# CMake Version file for GPGMEPP.
|
|
||||||
# Copyright (C) 2016 Intevation GmbH
|
|
||||||
#
|
|
||||||
# This file is part of GPGMEPP.
|
|
||||||
#
|
|
||||||
# GPGME-CL 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 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# GPGME-CL 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 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
|
|
||||||
|
|
||||||
# based on a generated file from cmake.
|
|
||||||
set(PACKAGE_VERSION "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_MICRO@")
|
|
||||||
|
|
||||||
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
|
|
||||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
|
||||||
else()
|
|
||||||
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
|
||||||
if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
|
|
||||||
set(PACKAGE_VERSION_EXACT TRUE)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
@ -1,130 +0,0 @@
|
|||||||
# Makefile.am for GPGMEPP.
|
|
||||||
# Copyright (C) 2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
# Software engineering by Intevation GmbH
|
|
||||||
#
|
|
||||||
# This file is part of GPGMEPP.
|
|
||||||
#
|
|
||||||
# GPGME-CL 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 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# GPGME-CL 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 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
|
|
||||||
|
|
||||||
EXTRA_DIST = GpgmeppConfig.cmake.in.in GpgmeppConfigVersion.cmake.in \
|
|
||||||
gpgmepp_version.h.in GpgmeppConfig-w32.cmake.in.in
|
|
||||||
|
|
||||||
lib_LTLIBRARIES = libgpgmepp.la
|
|
||||||
|
|
||||||
main_sources = \
|
|
||||||
exception.cpp context.cpp key.cpp trustitem.cpp data.cpp callbacks.cpp \
|
|
||||||
eventloopinteractor.cpp editinteractor.cpp \
|
|
||||||
keylistresult.cpp keygenerationresult.cpp importresult.cpp \
|
|
||||||
decryptionresult.cpp verificationresult.cpp \
|
|
||||||
signingresult.cpp encryptionresult.cpp \
|
|
||||||
engineinfo.cpp gpgsetexpirytimeeditinteractor.cpp \
|
|
||||||
gpgsetownertrusteditinteractor.cpp gpgsignkeyeditinteractor.cpp \
|
|
||||||
gpgadduserideditinteractor.cpp gpggencardkeyinteractor.cpp \
|
|
||||||
gpgaddexistingsubkeyeditinteractor.cpp \
|
|
||||||
gpgrevokekeyeditinteractor.cpp \
|
|
||||||
defaultassuantransaction.cpp \
|
|
||||||
scdgetinfoassuantransaction.cpp gpgagentgetinfoassuantransaction.cpp \
|
|
||||||
statusconsumerassuantransaction.cpp \
|
|
||||||
vfsmountresult.cpp configuration.cpp tofuinfo.cpp swdbresult.cpp \
|
|
||||||
util.cpp
|
|
||||||
|
|
||||||
gpgmepp_headers = \
|
|
||||||
configuration.h context.h data.h decryptionresult.h \
|
|
||||||
defaultassuantransaction.h editinteractor.h encryptionresult.h \
|
|
||||||
engineinfo.h error.h eventloopinteractor.h exception.h global.h \
|
|
||||||
gpgadduserideditinteractor.h gpgagentgetinfoassuantransaction.h \
|
|
||||||
gpgmefw.h gpgsetexpirytimeeditinteractor.h \
|
|
||||||
gpgsetownertrusteditinteractor.h gpgsignkeyeditinteractor.h \
|
|
||||||
gpggencardkeyinteractor.h \
|
|
||||||
gpgaddexistingsubkeyeditinteractor.h \
|
|
||||||
gpgrevokekeyeditinteractor.h \
|
|
||||||
importresult.h keygenerationresult.h key.h keylistresult.h \
|
|
||||||
notation.h result.h scdgetinfoassuantransaction.h signingresult.h \
|
|
||||||
statusconsumerassuantransaction.h \
|
|
||||||
trustitem.h verificationresult.h vfsmountresult.h gpgmepp_export.h \
|
|
||||||
tofuinfo.h swdbresult.h
|
|
||||||
|
|
||||||
private_gpgmepp_headers = \
|
|
||||||
result_p.h context_p.h util.h callbacks.h data_p.h
|
|
||||||
|
|
||||||
interface_headers= \
|
|
||||||
interfaces/assuantransaction.h interfaces/dataprovider.h \
|
|
||||||
interfaces/passphraseprovider.h interfaces/progressprovider.h \
|
|
||||||
interfaces/statusconsumer.h
|
|
||||||
|
|
||||||
gpgmeppincludedir = $(includedir)/gpgme++
|
|
||||||
gpgmeppinclude_HEADERS = $(gpgmepp_headers)
|
|
||||||
nobase_gpgmeppinclude_HEADERS = $(interface_headers)
|
|
||||||
nodist_gpgmeppinclude_HEADERS = gpgmepp_version.h
|
|
||||||
|
|
||||||
libgpgmepp_la_SOURCES = $(main_sources) $(gpgmepp_headers) context_vanilla.cpp \
|
|
||||||
$(interface_headers) $(private_gpgmepp_headers)
|
|
||||||
|
|
||||||
AM_CPPFLAGS = -I$(top_builddir)/src \
|
|
||||||
@GPGME_CPP_CFLAGS@ @GPG_ERROR_CFLAGS@ @LIBASSUAN_CFLAGS@ \
|
|
||||||
-DBUILDING_GPGMEPP -Wsuggest-override \
|
|
||||||
-Wzero-as-null-pointer-constant
|
|
||||||
|
|
||||||
libgpgmepp_la_LIBADD = ../../../src/libgpgme.la @LIBASSUAN_LIBS@
|
|
||||||
libgpgmepp_la_LDFLAGS = -no-undefined -version-info \
|
|
||||||
@LIBGPGMEPP_LT_CURRENT@:@LIBGPGMEPP_LT_REVISION@:@LIBGPGMEPP_LT_AGE@
|
|
||||||
|
|
||||||
if HAVE_MACOS_SYSTEM
|
|
||||||
libsuffix=.dylib
|
|
||||||
else
|
|
||||||
libsuffix=.so
|
|
||||||
endif
|
|
||||||
|
|
||||||
copied_headers = $(gpgmepp_headers:%=gpgme++/%) $(interface_headers:%=gpgme++/%)
|
|
||||||
|
|
||||||
$(copied_headers): Makefile.am
|
|
||||||
mkdir -p $(builddir)/gpgme++/interfaces
|
|
||||||
echo -n "#include \"$(abs_srcdir)" > "$@"
|
|
||||||
echo -n "$@" | sed "s/gpgme++//" >> "$@"
|
|
||||||
echo "\"" >> "$@"
|
|
||||||
|
|
||||||
if HAVE_W32_SYSTEM
|
|
||||||
GpgmeppConfig.cmake: GpgmeppConfig-w32.cmake.in
|
|
||||||
sed -e 's|[@]resolved_bindir@|$(bindir)|g' < "$<" | \
|
|
||||||
sed -e 's|[@]resolved_libdir@|$(libdir)|g' | \
|
|
||||||
sed -e 's|[@]resolved_includedir@|$(includedir)|g' > $@
|
|
||||||
else
|
|
||||||
GpgmeppConfig.cmake: GpgmeppConfig.cmake.in
|
|
||||||
sed -e 's|[@]resolved_libdir@|$(libdir)|g' < "$<" | \
|
|
||||||
sed -e 's|[@]libsuffix@|$(libsuffix)|g' | \
|
|
||||||
sed -e 's|[@]resolved_includedir@|$(includedir)|g' > $@
|
|
||||||
endif
|
|
||||||
install-cmake-files: GpgmeppConfig.cmake GpgmeppConfigVersion.cmake
|
|
||||||
-$(INSTALL) -d $(DESTDIR)$(libdir)/cmake/Gpgmepp
|
|
||||||
$(INSTALL) -m 644 GpgmeppConfig.cmake \
|
|
||||||
$(DESTDIR)$(libdir)/cmake/Gpgmepp/GpgmeppConfig.cmake
|
|
||||||
$(INSTALL) -m 644 GpgmeppConfigVersion.cmake \
|
|
||||||
$(DESTDIR)$(libdir)/cmake/Gpgmepp/GpgmeppConfigVersion.cmake
|
|
||||||
|
|
||||||
uninstall-cmake-files:
|
|
||||||
-rm $(DESTDIR)$(libdir)/cmake/Gpgmepp/GpgmeppConfigVersion.cmake
|
|
||||||
-rm $(DESTDIR)$(libdir)/cmake/Gpgmepp/GpgmeppConfig.cmake
|
|
||||||
-rmdir $(DESTDIR)$(libdir)/cmake/Gpgmepp/
|
|
||||||
|
|
||||||
install-data-local: install-cmake-files
|
|
||||||
|
|
||||||
uninstall-local: uninstall-cmake-files
|
|
||||||
|
|
||||||
BUILT_SOURCES = $(copied_headers)
|
|
||||||
|
|
||||||
CLEANFILES = GpgmeppConfig.cmake GpgmeppConfigVersion.cmake \
|
|
||||||
gpgmepp_version.h GpgmeppConfig.cmake.in \
|
|
||||||
$(copied_headers)
|
|
@ -1,155 +0,0 @@
|
|||||||
/*
|
|
||||||
callbacks.cpp - callback targets for internal use:
|
|
||||||
Copyright (C) 2003,2004 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "callbacks.h"
|
|
||||||
#include "util.h"
|
|
||||||
|
|
||||||
#include <interfaces/progressprovider.h>
|
|
||||||
#include <interfaces/passphraseprovider.h>
|
|
||||||
#include <interfaces/dataprovider.h>
|
|
||||||
#include <error.h>
|
|
||||||
|
|
||||||
#include <gpgme.h>
|
|
||||||
#include <gpg-error.h>
|
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
#include <cerrno>
|
|
||||||
#include <cstring>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
static inline gpgme_error_t make_err_from_syserror()
|
|
||||||
{
|
|
||||||
return gpgme_error_from_syserror();
|
|
||||||
}
|
|
||||||
|
|
||||||
using GpgME::ProgressProvider;
|
|
||||||
using GpgME::PassphraseProvider;
|
|
||||||
using GpgME::DataProvider;
|
|
||||||
|
|
||||||
void progress_callback(void *opaque, const char *what,
|
|
||||||
int type, int current, int total)
|
|
||||||
{
|
|
||||||
ProgressProvider *provider = static_cast<ProgressProvider *>(opaque);
|
|
||||||
if (provider) {
|
|
||||||
provider->showProgress(what, type, current, total);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* To avoid that a compiler optimizes certain memset calls away, these
|
|
||||||
macros may be used instead. */
|
|
||||||
#define wipememory2(_ptr,_set,_len) do { \
|
|
||||||
volatile char *_vptr=(volatile char *)(_ptr); \
|
|
||||||
size_t _vlen=(_len); \
|
|
||||||
while(_vlen) { *_vptr=(_set); _vptr++; _vlen--; } \
|
|
||||||
} while(0)
|
|
||||||
#define wipememory(_ptr,_len) wipememory2(_ptr,0,_len)
|
|
||||||
|
|
||||||
gpgme_error_t passphrase_callback(void *opaque, const char *uid_hint, const char *desc,
|
|
||||||
int prev_was_bad, int fd)
|
|
||||||
{
|
|
||||||
PassphraseProvider *provider = static_cast<PassphraseProvider *>(opaque);
|
|
||||||
bool canceled = false;
|
|
||||||
gpgme_error_t err = GPG_ERR_NO_ERROR;
|
|
||||||
char *passphrase = provider ? provider->getPassphrase(uid_hint, desc, prev_was_bad, canceled) : nullptr ;
|
|
||||||
if (canceled) {
|
|
||||||
err = make_error(GPG_ERR_CANCELED);
|
|
||||||
} else {
|
|
||||||
if (passphrase && *passphrase) {
|
|
||||||
size_t passphrase_length = std::strlen(passphrase);
|
|
||||||
size_t written = 0;
|
|
||||||
do {
|
|
||||||
ssize_t now_written = gpgme_io_write(fd, passphrase + written, passphrase_length - written);
|
|
||||||
if (now_written < 0) {
|
|
||||||
err = make_err_from_syserror();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
written += now_written;
|
|
||||||
} while (written < passphrase_length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (passphrase && *passphrase) {
|
|
||||||
wipememory(passphrase, std::strlen(passphrase));
|
|
||||||
}
|
|
||||||
free(passphrase);
|
|
||||||
gpgme_io_write(fd, "\n", 1);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gpgme_ssize_t
|
|
||||||
data_read_callback(void *opaque, void *buf, size_t buflen)
|
|
||||||
{
|
|
||||||
DataProvider *provider = static_cast<DataProvider *>(opaque);
|
|
||||||
if (!provider) {
|
|
||||||
gpgme_err_set_errno(gpgme_err_code_to_errno(GPG_ERR_EINVAL));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return (gpgme_ssize_t)provider->read(buf, buflen);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gpgme_ssize_t
|
|
||||||
data_write_callback(void *opaque, const void *buf, size_t buflen)
|
|
||||||
{
|
|
||||||
DataProvider *provider = static_cast<DataProvider *>(opaque);
|
|
||||||
if (!provider) {
|
|
||||||
gpgme_err_set_errno(gpgme_err_code_to_errno(GPG_ERR_EINVAL));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return (gpgme_ssize_t)provider->write(buf, buflen);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gpgme_off_t
|
|
||||||
data_seek_callback(void *opaque, gpgme_off_t offset, int whence)
|
|
||||||
{
|
|
||||||
DataProvider *provider = static_cast<DataProvider *>(opaque);
|
|
||||||
if (!provider) {
|
|
||||||
gpgme_err_set_errno(gpgme_err_code_to_errno(GPG_ERR_EINVAL));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (whence != SEEK_SET && whence != SEEK_CUR && whence != SEEK_END) {
|
|
||||||
gpgme_err_set_errno(gpgme_err_code_to_errno(GPG_ERR_EINVAL));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return provider->seek((off_t)offset, whence);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void data_release_callback(void *opaque)
|
|
||||||
{
|
|
||||||
DataProvider *provider = static_cast<DataProvider *>(opaque);
|
|
||||||
if (provider) {
|
|
||||||
provider->release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const gpgme_data_cbs GpgME::data_provider_callbacks = {
|
|
||||||
&data_read_callback,
|
|
||||||
&data_write_callback,
|
|
||||||
&data_seek_callback,
|
|
||||||
&data_release_callback
|
|
||||||
};
|
|
@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
callbacks.h - callback targets for internal use:
|
|
||||||
Copyright (C) 2003 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation GmbH
|
|
||||||
|
|
||||||
This file is part of GPGME++.
|
|
||||||
|
|
||||||
This is an internal header file, subject to change without
|
|
||||||
notice. DO NOT USE.
|
|
||||||
|
|
||||||
GPGME++ is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GPGMEPP_CALLBACKS_H__
|
|
||||||
#define __GPGMEPP_CALLBACKS_H__
|
|
||||||
|
|
||||||
#include <gpgme.h>
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
|
|
||||||
void progress_callback(void *opaque, const char *what,
|
|
||||||
int type, int current, int total);
|
|
||||||
gpgme_error_t passphrase_callback(void *opaque, const char *uid_hint,
|
|
||||||
const char *desc, int prev_was_bad, int fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace GpgME
|
|
||||||
{
|
|
||||||
extern const gpgme_data_cbs data_provider_callbacks;
|
|
||||||
extern const gpgme_edit_cb_t edit_interactor_callback;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // __GPGME_CALLBACKS_H__
|
|
@ -1,788 +0,0 @@
|
|||||||
/*
|
|
||||||
configuration.cpp - wraps gpgme configuration components
|
|
||||||
Copyright (C) 2010 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "configuration.h"
|
|
||||||
#include "error.h"
|
|
||||||
#include "util.h"
|
|
||||||
|
|
||||||
#include <gpgme.h>
|
|
||||||
|
|
||||||
#include <iterator>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <ostream>
|
|
||||||
#include <cstring>
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
using namespace GpgME;
|
|
||||||
using namespace GpgME::Configuration;
|
|
||||||
|
|
||||||
typedef std::shared_ptr< std::remove_pointer<gpgme_conf_opt_t>::type > shared_gpgme_conf_opt_t;
|
|
||||||
typedef std::weak_ptr< std::remove_pointer<gpgme_conf_opt_t>::type > weak_gpgme_conf_opt_t;
|
|
||||||
|
|
||||||
typedef std::shared_ptr< std::remove_pointer<gpgme_conf_arg_t>::type > shared_gpgme_conf_arg_t;
|
|
||||||
typedef std::weak_ptr< std::remove_pointer<gpgme_conf_arg_t>::type > weak_gpgme_conf_arg_t;
|
|
||||||
|
|
||||||
typedef std::shared_ptr< std::remove_pointer<gpgme_ctx_t>::type > shared_gpgme_ctx_t;
|
|
||||||
typedef std::weak_ptr< std::remove_pointer<gpgme_ctx_t>::type > weak_gpgme_ctx_t;
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
struct nodelete {
|
|
||||||
template <typename T> void operator()(T *) {}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// static
|
|
||||||
std::vector<Component> Component::load(Error &returnedError)
|
|
||||||
{
|
|
||||||
|
|
||||||
//
|
|
||||||
// 1. get a context:
|
|
||||||
//
|
|
||||||
gpgme_ctx_t ctx_native = nullptr;
|
|
||||||
if (const gpgme_error_t err = gpgme_new(&ctx_native)) {
|
|
||||||
returnedError = Error(err);
|
|
||||||
return std::vector<Component>();
|
|
||||||
}
|
|
||||||
const shared_gpgme_ctx_t ctx(ctx_native, &gpgme_release);
|
|
||||||
|
|
||||||
//
|
|
||||||
// 2. load the config:
|
|
||||||
//
|
|
||||||
gpgme_conf_comp_t conf_list_native = nullptr;
|
|
||||||
if (const gpgme_error_t err = gpgme_op_conf_load(ctx_native, &conf_list_native)) {
|
|
||||||
returnedError = Error(err);
|
|
||||||
return std::vector<Component>();
|
|
||||||
}
|
|
||||||
shared_gpgme_conf_comp_t head(conf_list_native, &gpgme_conf_release);
|
|
||||||
|
|
||||||
//
|
|
||||||
// 3. convert to vector<Component>:
|
|
||||||
//
|
|
||||||
std::vector<Component> result;
|
|
||||||
|
|
||||||
while (head) {
|
|
||||||
// secure 'head->next' (if any) against memleaks:
|
|
||||||
shared_gpgme_conf_comp_t next;
|
|
||||||
if (head->next) {
|
|
||||||
next.reset(head->next, &gpgme_conf_release);
|
|
||||||
}
|
|
||||||
|
|
||||||
// now prevent double-free of next.get() and following:
|
|
||||||
head->next = nullptr;
|
|
||||||
|
|
||||||
// now add a new Component to 'result' (may throw):
|
|
||||||
result.resize(result.size() + 1);
|
|
||||||
result.back().comp.swap(head); // .comp = std::move( head );
|
|
||||||
head.swap(next); // head = std::move( next );
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
Error Component::save() const
|
|
||||||
{
|
|
||||||
|
|
||||||
if (isNull()) {
|
|
||||||
return Error(make_error(GPG_ERR_INV_ARG));
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// 1. get a context:
|
|
||||||
//
|
|
||||||
gpgme_ctx_t ctx_native = nullptr;
|
|
||||||
if (const gpgme_error_t err = gpgme_new(&ctx_native)) {
|
|
||||||
return Error(err);
|
|
||||||
}
|
|
||||||
const shared_gpgme_ctx_t ctx(ctx_native, &gpgme_release);
|
|
||||||
|
|
||||||
//
|
|
||||||
// 2. save the config:
|
|
||||||
//
|
|
||||||
return Error(gpgme_op_conf_save(ctx.get(), comp.get()));
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *Component::name() const
|
|
||||||
{
|
|
||||||
return comp ? comp->name : nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *Component::description() const
|
|
||||||
{
|
|
||||||
return comp ? comp->description : nullptr ;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *Component::programName() const
|
|
||||||
{
|
|
||||||
return comp ? comp->program_name : nullptr ;
|
|
||||||
}
|
|
||||||
|
|
||||||
Option Component::option(unsigned int idx) const
|
|
||||||
{
|
|
||||||
gpgme_conf_opt_t opt = nullptr;
|
|
||||||
if (comp) {
|
|
||||||
opt = comp->options;
|
|
||||||
}
|
|
||||||
while (opt && idx) {
|
|
||||||
opt = opt->next;
|
|
||||||
--idx;
|
|
||||||
}
|
|
||||||
if (opt) {
|
|
||||||
return Option(comp, opt);
|
|
||||||
}
|
|
||||||
return Option();
|
|
||||||
}
|
|
||||||
|
|
||||||
Option Component::option(const char *name) const
|
|
||||||
{
|
|
||||||
gpgme_conf_opt_t opt = nullptr;
|
|
||||||
if (comp) {
|
|
||||||
opt = comp->options;
|
|
||||||
}
|
|
||||||
using namespace std; // for strcmp
|
|
||||||
while (opt && strcmp(name, opt->name) != 0) {
|
|
||||||
opt = opt->next;
|
|
||||||
}
|
|
||||||
if (opt) {
|
|
||||||
return Option(comp, opt);
|
|
||||||
}
|
|
||||||
return Option();
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int Component::numOptions() const
|
|
||||||
{
|
|
||||||
unsigned int result = 0;
|
|
||||||
for (gpgme_conf_opt_t opt = comp ? comp->options : nullptr ; opt ; opt = opt->next) {
|
|
||||||
++result;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<Option> Component::options() const
|
|
||||||
{
|
|
||||||
std::vector<Option> result;
|
|
||||||
for (gpgme_conf_opt_t opt = comp ? comp->options : nullptr ; opt ; opt = opt->next) {
|
|
||||||
result.push_back(Option(comp, opt));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gpgme_conf_arg_t mygpgme_conf_arg_copy(gpgme_conf_arg_t other, gpgme_conf_type_t type)
|
|
||||||
{
|
|
||||||
gpgme_conf_arg_t result = nullptr, last = nullptr;
|
|
||||||
for (gpgme_conf_arg_t a = other ; a ; a = a->next) {
|
|
||||||
gpgme_conf_arg_t arg = nullptr;
|
|
||||||
const gpgme_error_t err
|
|
||||||
= gpgme_conf_arg_new(&arg, type,
|
|
||||||
a->no_arg ? nullptr :
|
|
||||||
type == GPGME_CONF_STRING ? a->value.string :
|
|
||||||
/* else */ static_cast<void *>(&a->value));
|
|
||||||
if (err) {
|
|
||||||
gpgme_conf_arg_release(result, type);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
assert(arg);
|
|
||||||
if (result) {
|
|
||||||
last->next = arg;
|
|
||||||
} else {
|
|
||||||
result = arg;
|
|
||||||
}
|
|
||||||
last = arg;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
Component Option::parent() const
|
|
||||||
{
|
|
||||||
return Component(comp.lock());
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int Option::flags() const
|
|
||||||
{
|
|
||||||
return isNull() ? 0 : opt->flags;
|
|
||||||
}
|
|
||||||
|
|
||||||
Level Option::level() const
|
|
||||||
{
|
|
||||||
return isNull() ? Internal : static_cast<Level>(opt->level) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *Option::name() const
|
|
||||||
{
|
|
||||||
return isNull() ? nullptr : opt->name ;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *Option::description() const
|
|
||||||
{
|
|
||||||
return isNull() ? nullptr : opt->description ;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *Option::argumentName() const
|
|
||||||
{
|
|
||||||
return isNull() ? nullptr : opt->argname ;
|
|
||||||
}
|
|
||||||
|
|
||||||
Type Option::type() const
|
|
||||||
{
|
|
||||||
return isNull() ? NoType : static_cast<Type>(opt->type) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
Type Option::alternateType() const
|
|
||||||
{
|
|
||||||
return isNull() ? NoType : static_cast<Type>(opt->alt_type) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
Argument Option::defaultValue() const
|
|
||||||
{
|
|
||||||
if (isNull()) {
|
|
||||||
return Argument();
|
|
||||||
} else {
|
|
||||||
return Argument(comp.lock(), opt, opt->default_value, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *Option::defaultDescription() const
|
|
||||||
{
|
|
||||||
return isNull() ? nullptr : opt->default_description ;
|
|
||||||
}
|
|
||||||
|
|
||||||
Argument Option::noArgumentValue() const
|
|
||||||
{
|
|
||||||
if (isNull()) {
|
|
||||||
return Argument();
|
|
||||||
} else {
|
|
||||||
return Argument(comp.lock(), opt, opt->no_arg_value, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *Option::noArgumentDescription() const
|
|
||||||
{
|
|
||||||
return isNull() ? nullptr : opt->no_arg_description ;
|
|
||||||
}
|
|
||||||
|
|
||||||
Argument Option::activeValue() const
|
|
||||||
{
|
|
||||||
if (isNull()) {
|
|
||||||
return Argument();
|
|
||||||
} else {
|
|
||||||
return Argument(comp.lock(), opt, opt->value, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Argument Option::currentValue() const
|
|
||||||
{
|
|
||||||
if (isNull()) {
|
|
||||||
return Argument();
|
|
||||||
}
|
|
||||||
const gpgme_conf_arg_t arg =
|
|
||||||
opt->change_value ? opt->new_value ? opt->new_value : opt->default_value :
|
|
||||||
opt->value ? opt->value :
|
|
||||||
/* else */ opt->default_value ;
|
|
||||||
return Argument(comp.lock(), opt, arg, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
Argument Option::newValue() const
|
|
||||||
{
|
|
||||||
if (isNull()) {
|
|
||||||
return Argument();
|
|
||||||
} else {
|
|
||||||
return Argument(comp.lock(), opt, opt->new_value, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Option::set() const
|
|
||||||
{
|
|
||||||
if (isNull()) {
|
|
||||||
return false;
|
|
||||||
} else if (opt->change_value) {
|
|
||||||
return opt->new_value;
|
|
||||||
} else {
|
|
||||||
return opt->value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Option::dirty() const
|
|
||||||
{
|
|
||||||
return !isNull() && opt->change_value ;
|
|
||||||
}
|
|
||||||
|
|
||||||
Error Option::setNewValue(const Argument &argument)
|
|
||||||
{
|
|
||||||
if (isNull()) {
|
|
||||||
return Error(make_error(GPG_ERR_INV_ARG));
|
|
||||||
} else if (argument.isNull()) {
|
|
||||||
return resetToDefaultValue();
|
|
||||||
} else if (const gpgme_conf_arg_t arg = mygpgme_conf_arg_copy(argument.arg, opt->alt_type)) {
|
|
||||||
return Error(gpgme_conf_opt_change(opt, 0, arg));
|
|
||||||
} else {
|
|
||||||
return Error(make_error(GPG_ERR_ENOMEM));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Error Option::resetToActiveValue()
|
|
||||||
{
|
|
||||||
if (isNull()) {
|
|
||||||
return Error(make_error(GPG_ERR_INV_ARG));
|
|
||||||
} else {
|
|
||||||
return Error(gpgme_conf_opt_change(opt, 1, nullptr));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Error Option::resetToDefaultValue()
|
|
||||||
{
|
|
||||||
if (isNull()) {
|
|
||||||
return Error(make_error(GPG_ERR_INV_ARG));
|
|
||||||
} else {
|
|
||||||
return Error(gpgme_conf_opt_change(opt, 0, nullptr));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static gpgme_conf_arg_t make_argument(gpgme_conf_type_t type, const void *value)
|
|
||||||
{
|
|
||||||
gpgme_conf_arg_t arg = nullptr;
|
|
||||||
if (const gpgme_error_t err = gpgme_conf_arg_new(&arg, type, value)) {
|
|
||||||
return nullptr;
|
|
||||||
} else {
|
|
||||||
return arg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Argument Option::createNoneArgument(bool set) const
|
|
||||||
{
|
|
||||||
if (isNull() || alternateType() != NoType) {
|
|
||||||
return Argument();
|
|
||||||
} else {
|
|
||||||
if (set) {
|
|
||||||
return createNoneListArgument(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Argument();
|
|
||||||
}
|
|
||||||
|
|
||||||
Argument Option::createStringArgument(const char *value) const
|
|
||||||
{
|
|
||||||
if (isNull() || alternateType() != StringType) {
|
|
||||||
return Argument();
|
|
||||||
} else {
|
|
||||||
return Argument(comp.lock(), opt, make_argument(GPGME_CONF_STRING, value), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Argument Option::createStringArgument(const std::string &value) const
|
|
||||||
{
|
|
||||||
if (isNull() || alternateType() != StringType) {
|
|
||||||
return Argument();
|
|
||||||
} else {
|
|
||||||
return Argument(comp.lock(), opt, make_argument(GPGME_CONF_STRING, value.c_str()), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Argument Option::createIntArgument(int value) const
|
|
||||||
{
|
|
||||||
if (isNull() || alternateType() != IntegerType) {
|
|
||||||
return Argument();
|
|
||||||
} else {
|
|
||||||
return Argument(comp.lock(), opt, make_argument(GPGME_CONF_INT32, &value), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Argument Option::createUIntArgument(unsigned int value) const
|
|
||||||
{
|
|
||||||
if (isNull() || alternateType() != UnsignedIntegerType) {
|
|
||||||
return Argument();
|
|
||||||
} else {
|
|
||||||
return Argument(comp.lock(), opt, make_argument(GPGME_CONF_UINT32, &value), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
const void *to_void_star(const char *s)
|
|
||||||
{
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
const void *to_void_star(const std::string &s)
|
|
||||||
{
|
|
||||||
return s.c_str();
|
|
||||||
}
|
|
||||||
const void *to_void_star(const int &i)
|
|
||||||
{
|
|
||||||
return &i; // const-&: sic!
|
|
||||||
}
|
|
||||||
const void *to_void_star(const unsigned int &i)
|
|
||||||
{
|
|
||||||
return &i; // const-&: sic!
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
gpgme_conf_arg_t make_argument(gpgme_conf_type_t type, const std::vector<T> &value)
|
|
||||||
{
|
|
||||||
gpgme_conf_arg_t result = nullptr;
|
|
||||||
gpgme_conf_arg_t last = nullptr;
|
|
||||||
for (typename std::vector<T>::const_iterator it = value.begin(), end = value.end() ; it != end ; ++it) {
|
|
||||||
if (gpgme_conf_arg_t arg = make_argument(type, to_void_star(*it))) {
|
|
||||||
if (last) {
|
|
||||||
last = last->next = arg;
|
|
||||||
} else {
|
|
||||||
result = last = arg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Argument Option::createNoneListArgument(unsigned int value) const
|
|
||||||
{
|
|
||||||
if (value) {
|
|
||||||
return Argument(comp.lock(), opt, make_argument(GPGME_CONF_NONE, &value), true);
|
|
||||||
}
|
|
||||||
return Argument();
|
|
||||||
}
|
|
||||||
|
|
||||||
Argument Option::createStringListArgument(const std::vector<const char *> &value) const
|
|
||||||
{
|
|
||||||
return Argument(comp.lock(), opt, make_argument(GPGME_CONF_STRING, value), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
Argument Option::createStringListArgument(const std::vector<std::string> &value) const
|
|
||||||
{
|
|
||||||
return Argument(comp.lock(), opt, make_argument(GPGME_CONF_STRING, value), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
Argument Option::createIntListArgument(const std::vector<int> &value) const
|
|
||||||
{
|
|
||||||
return Argument(comp.lock(), opt, make_argument(GPGME_CONF_INT32, value), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
Argument Option::createUIntListArgument(const std::vector<unsigned int> &value) const
|
|
||||||
{
|
|
||||||
return Argument(comp.lock(), opt, make_argument(GPGME_CONF_UINT32, value), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
Argument::Argument(const shared_gpgme_conf_comp_t &comp, gpgme_conf_opt_t opt, gpgme_conf_arg_t arg, bool owns)
|
|
||||||
: comp(comp),
|
|
||||||
opt(opt),
|
|
||||||
arg(owns ? arg : mygpgme_conf_arg_copy(arg, opt ? opt->alt_type : GPGME_CONF_NONE))
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
Argument::Argument(const shared_gpgme_conf_comp_t &comp, gpgme_conf_opt_t opt, gpgme_conf_arg_t arg)
|
|
||||||
: comp(comp),
|
|
||||||
opt(opt),
|
|
||||||
arg(mygpgme_conf_arg_copy(arg, opt ? opt->alt_type : GPGME_CONF_NONE))
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Argument::Argument(const Argument &other)
|
|
||||||
: comp(other.comp),
|
|
||||||
opt(other.opt),
|
|
||||||
arg(mygpgme_conf_arg_copy(other.arg, opt ? opt->alt_type : GPGME_CONF_NONE))
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Argument::~Argument()
|
|
||||||
{
|
|
||||||
gpgme_conf_arg_release(arg, opt ? opt->alt_type : GPGME_CONF_NONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
Option Argument::parent() const
|
|
||||||
{
|
|
||||||
return Option(comp.lock(), opt);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Argument::boolValue() const
|
|
||||||
{
|
|
||||||
return numberOfTimesSet();
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int Argument::numElements() const
|
|
||||||
{
|
|
||||||
if (isNull()) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
unsigned int result = 0;
|
|
||||||
for (gpgme_conf_arg_t a = arg ; a ; a = a->next) {
|
|
||||||
++result;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *Argument::stringValue(unsigned int idx) const
|
|
||||||
{
|
|
||||||
if (isNull() || opt->alt_type != GPGME_CONF_STRING) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
gpgme_conf_arg_t a = arg;
|
|
||||||
while (a && idx) {
|
|
||||||
a = a->next;
|
|
||||||
--idx;
|
|
||||||
}
|
|
||||||
return a ? a->value.string : nullptr ;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Argument::intValue(unsigned int idx) const
|
|
||||||
{
|
|
||||||
if (isNull() || opt->alt_type != GPGME_CONF_INT32) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
gpgme_conf_arg_t a = arg;
|
|
||||||
while (a && idx) {
|
|
||||||
a = a->next;
|
|
||||||
--idx;
|
|
||||||
}
|
|
||||||
return a ? a->value.int32 : 0 ;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int Argument::uintValue(unsigned int idx) const
|
|
||||||
{
|
|
||||||
if (isNull() || opt->alt_type != GPGME_CONF_UINT32) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
gpgme_conf_arg_t a = arg;
|
|
||||||
while (a && idx) {
|
|
||||||
a = a->next;
|
|
||||||
--idx;
|
|
||||||
}
|
|
||||||
return a ? a->value.uint32 : 0 ;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int Argument::numberOfTimesSet() const
|
|
||||||
{
|
|
||||||
if (isNull() || opt->alt_type != GPGME_CONF_NONE) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return arg->value.count;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<const char *> Argument::stringValues() const
|
|
||||||
{
|
|
||||||
if (isNull() || opt->alt_type != GPGME_CONF_STRING) {
|
|
||||||
return std::vector<const char *>();
|
|
||||||
}
|
|
||||||
std::vector<const char *> result;
|
|
||||||
for (gpgme_conf_arg_t a = arg ; a ; a = a->next) {
|
|
||||||
result.push_back(a->value.string);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<int> Argument::intValues() const
|
|
||||||
{
|
|
||||||
if (isNull() || opt->alt_type != GPGME_CONF_INT32) {
|
|
||||||
return std::vector<int>();
|
|
||||||
}
|
|
||||||
std::vector<int> result;
|
|
||||||
for (gpgme_conf_arg_t a = arg ; a ; a = a->next) {
|
|
||||||
result.push_back(a->value.int32);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<unsigned int> Argument::uintValues() const
|
|
||||||
{
|
|
||||||
if (isNull() || opt->alt_type != GPGME_CONF_UINT32) {
|
|
||||||
return std::vector<unsigned int>();
|
|
||||||
}
|
|
||||||
std::vector<unsigned int> result;
|
|
||||||
for (gpgme_conf_arg_t a = arg ; a ; a = a->next) {
|
|
||||||
result.push_back(a->value.uint32);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostream &Configuration::operator<<(std::ostream &os, Level level)
|
|
||||||
{
|
|
||||||
switch (level) {
|
|
||||||
case Basic: return os << "Basic";
|
|
||||||
case Advanced: return os << "Advanced";
|
|
||||||
case Expert: return os << "Expert";
|
|
||||||
case Invisible: return os << "Invisible";
|
|
||||||
case Internal: return os << "Internal";
|
|
||||||
case NumLevels: ;
|
|
||||||
}
|
|
||||||
return os << "<unknown>";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostream &Configuration::operator<<(std::ostream &os, Type type)
|
|
||||||
{
|
|
||||||
switch (type) {
|
|
||||||
case NoType: return os << "None";
|
|
||||||
case StringType: return os << "String";
|
|
||||||
case IntegerType: return os << "Integer";
|
|
||||||
case UnsignedIntegerType: return os << "UnsignedInteger";
|
|
||||||
case FilenameType: return os << "Filename";
|
|
||||||
case LdapServerType: return os << "LdapServer";
|
|
||||||
case KeyFingerprintType: return os << "KeyFingerprint";
|
|
||||||
case PublicKeyType: return os << "PublicKey";
|
|
||||||
case SecretKeyType: return os << "SecretKey";
|
|
||||||
case AliasListType: return os << "AliasList";
|
|
||||||
case MaxType: ;
|
|
||||||
}
|
|
||||||
return os << "<unknown>";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostream &Configuration::operator<<(std::ostream &os, Flag f)
|
|
||||||
{
|
|
||||||
unsigned int flags = f;
|
|
||||||
std::vector<const char *> s;
|
|
||||||
if (flags & Group) {
|
|
||||||
s.push_back("Group");
|
|
||||||
}
|
|
||||||
if (flags & Optional) {
|
|
||||||
s.push_back("Optional");
|
|
||||||
}
|
|
||||||
if (flags & List) {
|
|
||||||
s.push_back("List");
|
|
||||||
}
|
|
||||||
if (flags & Runtime) {
|
|
||||||
s.push_back("Runtime");
|
|
||||||
}
|
|
||||||
if (flags & Default) {
|
|
||||||
s.push_back("Default");
|
|
||||||
}
|
|
||||||
if (flags & DefaultDescription) {
|
|
||||||
s.push_back("DefaultDescription");
|
|
||||||
}
|
|
||||||
if (flags & NoArgumentDescription) {
|
|
||||||
s.push_back("NoArgumentDescription");
|
|
||||||
}
|
|
||||||
if (flags & NoChange) {
|
|
||||||
s.push_back("NoChange");
|
|
||||||
}
|
|
||||||
flags &= ~(Group | Optional | List | Runtime | Default | DefaultDescription | NoArgumentDescription | NoChange);
|
|
||||||
if (flags) {
|
|
||||||
s.push_back("other flags(");
|
|
||||||
}
|
|
||||||
std::copy(s.begin(), s.end(),
|
|
||||||
std::ostream_iterator<const char *>(os, "|"));
|
|
||||||
if (flags) {
|
|
||||||
os << flags << ')';
|
|
||||||
}
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostream &Configuration::operator<<(std::ostream &os, const Component &c)
|
|
||||||
{
|
|
||||||
os << "Component["
|
|
||||||
<< "\n name : " << protect(c.name())
|
|
||||||
<< "\n description: " << protect(c.description())
|
|
||||||
<< "\n programName: " << protect(c.programName())
|
|
||||||
<< "\n options : \n";
|
|
||||||
const std::vector<Option> options = c.options();
|
|
||||||
std::copy(options.begin(), options.end(),
|
|
||||||
std::ostream_iterator<Option>(os, "\n"));
|
|
||||||
os << "\n]";
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostream &Configuration::operator<<(std::ostream &os, const Option &o)
|
|
||||||
{
|
|
||||||
return os << "Option["
|
|
||||||
<< "\n name: : " << protect(o.name())
|
|
||||||
<< "\n description : " << protect(o.description())
|
|
||||||
<< "\n argName : " << protect(o.argumentName())
|
|
||||||
<< "\n flags : " << static_cast<Flag>(o.flags())
|
|
||||||
<< "\n level : " << o.level()
|
|
||||||
<< "\n type : " << o.type()
|
|
||||||
<< "\n alt_type : " << o.alternateType()
|
|
||||||
<< "\n default_val : " << o.defaultValue()
|
|
||||||
<< "\n default_desc: " << protect(o.defaultDescription())
|
|
||||||
<< "\n no_arg_value: " << o.noArgumentValue()
|
|
||||||
<< "\n no_arg_desc : " << protect(o.noArgumentDescription())
|
|
||||||
<< "\n active_value: " << o.activeValue()
|
|
||||||
<< "\n new_value : " << o.newValue()
|
|
||||||
<< "\n --> cur_val : " << o.currentValue()
|
|
||||||
<< "\n set : " << o.set()
|
|
||||||
<< "\n dirty : " << o.dirty()
|
|
||||||
<< "\n]"
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostream &Configuration::operator<<(std::ostream &os, const Argument &a)
|
|
||||||
{
|
|
||||||
const Option o = a.parent();
|
|
||||||
const bool list = o.flags() & List;
|
|
||||||
os << "Argument[";
|
|
||||||
if (a) {
|
|
||||||
switch (o.alternateType()) {
|
|
||||||
case NoType:
|
|
||||||
if (list) {
|
|
||||||
os << a.numberOfTimesSet() << 'x';
|
|
||||||
} else {
|
|
||||||
os << a.boolValue();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
case StringType:
|
|
||||||
if (list) {
|
|
||||||
const std::vector<const char *> v = a.stringValues();
|
|
||||||
os << v.size() << ':';
|
|
||||||
// can't use std::copy + ostream_iterator here, since we need the protect() call
|
|
||||||
bool first = true;
|
|
||||||
std::for_each(v.begin(), v.end(), [&first, &os](const char *s) {
|
|
||||||
if (first) {
|
|
||||||
first = false;
|
|
||||||
} else {
|
|
||||||
os << ',';
|
|
||||||
}
|
|
||||||
os << protect(s);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
os << protect(a.stringValue());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case IntegerType:
|
|
||||||
if (list) {
|
|
||||||
const std::vector<int> v = a.intValues();
|
|
||||||
os << v.size() << ':';
|
|
||||||
std::copy(v.begin(), v.end(),
|
|
||||||
std::ostream_iterator<int>(os, ","));
|
|
||||||
} else {
|
|
||||||
os << a.intValue();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case UnsignedIntegerType:
|
|
||||||
if (list) {
|
|
||||||
const std::vector<unsigned int> v = a.uintValues();
|
|
||||||
os << v.size() << ':';
|
|
||||||
std::copy(v.begin(), v.end(),
|
|
||||||
std::ostream_iterator<unsigned int>(os, ","));
|
|
||||||
} else {
|
|
||||||
os << a.intValue();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return os << ']';
|
|
||||||
}
|
|
@ -1,292 +0,0 @@
|
|||||||
/*
|
|
||||||
configuration.h - wraps gpgme configuration components
|
|
||||||
Copyright (C) 2010 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// -*- c++ -*-
|
|
||||||
#ifndef __GPGMEPP_CONFIGURATION_H__
|
|
||||||
#define __GPGMEPP_CONFIGURATION_H__
|
|
||||||
|
|
||||||
#include "global.h"
|
|
||||||
|
|
||||||
#include "gpgmefw.h"
|
|
||||||
|
|
||||||
#include <iosfwd>
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace GpgME
|
|
||||||
{
|
|
||||||
namespace Configuration
|
|
||||||
{
|
|
||||||
|
|
||||||
typedef std::shared_ptr< std::remove_pointer<gpgme_conf_comp_t>::type > shared_gpgme_conf_comp_t;
|
|
||||||
typedef std::weak_ptr< std::remove_pointer<gpgme_conf_comp_t>::type > weak_gpgme_conf_comp_t;
|
|
||||||
|
|
||||||
class Argument;
|
|
||||||
class Option;
|
|
||||||
class Component;
|
|
||||||
|
|
||||||
enum Level {
|
|
||||||
Basic,
|
|
||||||
Advanced,
|
|
||||||
Expert,
|
|
||||||
Invisible,
|
|
||||||
Internal,
|
|
||||||
|
|
||||||
NumLevels
|
|
||||||
};
|
|
||||||
|
|
||||||
enum Type {
|
|
||||||
NoType,
|
|
||||||
StringType,
|
|
||||||
IntegerType,
|
|
||||||
UnsignedIntegerType,
|
|
||||||
|
|
||||||
FilenameType = 32,
|
|
||||||
LdapServerType,
|
|
||||||
KeyFingerprintType,
|
|
||||||
PublicKeyType,
|
|
||||||
SecretKeyType,
|
|
||||||
AliasListType,
|
|
||||||
|
|
||||||
MaxType
|
|
||||||
};
|
|
||||||
|
|
||||||
enum Flag {
|
|
||||||
Group = (1 << 0),
|
|
||||||
Optional = (1 << 1),
|
|
||||||
List = (1 << 2),
|
|
||||||
Runtime = (1 << 3),
|
|
||||||
Default = (1 << 4),
|
|
||||||
DefaultDescription = (1 << 5),
|
|
||||||
NoArgumentDescription = (1 << 6),
|
|
||||||
NoChange = (1 << 7),
|
|
||||||
|
|
||||||
LastFlag = NoChange
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// class Component
|
|
||||||
//
|
|
||||||
|
|
||||||
class GPGMEPP_EXPORT Component
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Component() : comp() {}
|
|
||||||
explicit Component(const shared_gpgme_conf_comp_t &gpgme_comp)
|
|
||||||
: comp(gpgme_comp) {}
|
|
||||||
|
|
||||||
Component(const Component &other) = default;
|
|
||||||
const Component &operator=(const Component &other)
|
|
||||||
{
|
|
||||||
if (this != &other) {
|
|
||||||
Component(other).swap(*this);
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void swap(Component &other)
|
|
||||||
{
|
|
||||||
using std::swap;
|
|
||||||
swap(this->comp, other.comp);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isNull() const
|
|
||||||
{
|
|
||||||
return !comp;
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::vector<Component> load(Error &err);
|
|
||||||
Error save() const;
|
|
||||||
|
|
||||||
const char *name() const;
|
|
||||||
const char *description() const;
|
|
||||||
const char *programName() const;
|
|
||||||
|
|
||||||
Option option(unsigned int index) const;
|
|
||||||
Option option(const char *name) const;
|
|
||||||
|
|
||||||
unsigned int numOptions() const;
|
|
||||||
|
|
||||||
std::vector<Option> options() const;
|
|
||||||
|
|
||||||
GPGMEPP_MAKE_SAFE_BOOL_OPERATOR(!isNull())
|
|
||||||
private:
|
|
||||||
shared_gpgme_conf_comp_t comp;
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// class Option
|
|
||||||
//
|
|
||||||
|
|
||||||
class GPGMEPP_EXPORT Option
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Option() : comp(), opt(nullptr) {}
|
|
||||||
Option(const shared_gpgme_conf_comp_t &gpgme_comp, gpgme_conf_opt_t gpgme_opt)
|
|
||||||
: comp(gpgme_comp), opt(gpgme_opt) {}
|
|
||||||
|
|
||||||
Option(const Option &other) = default;
|
|
||||||
const Option &operator=(const Option &other)
|
|
||||||
{
|
|
||||||
if (this != &other) {
|
|
||||||
Option(other).swap(*this);
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void swap(Option &other)
|
|
||||||
{
|
|
||||||
using std::swap;
|
|
||||||
swap(this->comp, other.comp);
|
|
||||||
swap(this->opt, other.opt);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isNull() const
|
|
||||||
{
|
|
||||||
return comp.expired() || !opt;
|
|
||||||
}
|
|
||||||
|
|
||||||
Component parent() const;
|
|
||||||
|
|
||||||
unsigned int flags() const;
|
|
||||||
|
|
||||||
Level level() const;
|
|
||||||
|
|
||||||
const char *name() const;
|
|
||||||
const char *description() const;
|
|
||||||
const char *argumentName() const;
|
|
||||||
|
|
||||||
Type type() const;
|
|
||||||
Type alternateType() const;
|
|
||||||
|
|
||||||
Argument defaultValue() const;
|
|
||||||
const char *defaultDescription() const;
|
|
||||||
|
|
||||||
Argument noArgumentValue() const;
|
|
||||||
const char *noArgumentDescription() const;
|
|
||||||
|
|
||||||
/*! The value that is in the config file (or null, if it's not set). */
|
|
||||||
Argument activeValue() const;
|
|
||||||
/*! The value that is in this object, i.e. either activeValue(), newValue(), or defaultValue() */
|
|
||||||
Argument currentValue() const;
|
|
||||||
|
|
||||||
Argument newValue() const;
|
|
||||||
bool set() const;
|
|
||||||
bool dirty() const;
|
|
||||||
|
|
||||||
Error setNewValue(const Argument &argument);
|
|
||||||
Error resetToDefaultValue();
|
|
||||||
Error resetToActiveValue();
|
|
||||||
|
|
||||||
Argument createNoneArgument(bool set) const;
|
|
||||||
Argument createStringArgument(const char *value) const;
|
|
||||||
Argument createStringArgument(const std::string &value) const;
|
|
||||||
Argument createIntArgument(int value) const;
|
|
||||||
Argument createUIntArgument(unsigned int value) const;
|
|
||||||
|
|
||||||
Argument createNoneListArgument(unsigned int count) const;
|
|
||||||
Argument createStringListArgument(const std::vector<const char *> &value) const;
|
|
||||||
Argument createStringListArgument(const std::vector<std::string> &value) const;
|
|
||||||
Argument createIntListArgument(const std::vector<int> &values) const;
|
|
||||||
Argument createUIntListArgument(const std::vector<unsigned int> &values) const;
|
|
||||||
|
|
||||||
GPGMEPP_MAKE_SAFE_BOOL_OPERATOR(!isNull())
|
|
||||||
private:
|
|
||||||
weak_gpgme_conf_comp_t comp;
|
|
||||||
gpgme_conf_opt_t opt;
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// class Argument
|
|
||||||
//
|
|
||||||
|
|
||||||
class GPGMEPP_EXPORT Argument
|
|
||||||
{
|
|
||||||
friend class ::GpgME::Configuration::Option;
|
|
||||||
Argument(const shared_gpgme_conf_comp_t &comp, gpgme_conf_opt_t opt, gpgme_conf_arg_t arg, bool owns);
|
|
||||||
public:
|
|
||||||
Argument() : comp(), opt(nullptr), arg(nullptr) {}
|
|
||||||
//Argument( const shared_gpgme_conf_comp_t & comp, gpgme_conf_opt_t opt, gpgme_conf_arg_t arg );
|
|
||||||
Argument(const Argument &other);
|
|
||||||
~Argument();
|
|
||||||
|
|
||||||
const Argument &operator=(const Argument &other)
|
|
||||||
{
|
|
||||||
if (this != &other) {
|
|
||||||
Argument(other).swap(*this);
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void swap(Argument &other)
|
|
||||||
{
|
|
||||||
using std::swap;
|
|
||||||
swap(this->comp, other.comp);
|
|
||||||
swap(this->opt, other.opt);
|
|
||||||
swap(this->arg, other.arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isNull() const
|
|
||||||
{
|
|
||||||
return comp.expired() || !opt || !arg;
|
|
||||||
}
|
|
||||||
|
|
||||||
Option parent() const;
|
|
||||||
|
|
||||||
unsigned int numElements() const;
|
|
||||||
|
|
||||||
bool boolValue() const;
|
|
||||||
const char *stringValue(unsigned int index = 0) const;
|
|
||||||
int intValue(unsigned int index = 0) const;
|
|
||||||
unsigned int uintValue(unsigned int index = 0) const;
|
|
||||||
|
|
||||||
unsigned int numberOfTimesSet() const;
|
|
||||||
std::vector<const char *> stringValues() const;
|
|
||||||
std::vector<int> intValues() const;
|
|
||||||
std::vector<unsigned int> uintValues() const;
|
|
||||||
|
|
||||||
GPGMEPP_MAKE_SAFE_BOOL_OPERATOR(!isNull())
|
|
||||||
private:
|
|
||||||
weak_gpgme_conf_comp_t comp;
|
|
||||||
gpgme_conf_opt_t opt;
|
|
||||||
gpgme_conf_arg_t arg;
|
|
||||||
};
|
|
||||||
|
|
||||||
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, Level level);
|
|
||||||
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, Type type);
|
|
||||||
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, Flag flag);
|
|
||||||
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const Component &component);
|
|
||||||
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const Option &option);
|
|
||||||
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const Argument &argument);
|
|
||||||
|
|
||||||
} // namespace Configuration
|
|
||||||
} // namespace GpgME
|
|
||||||
|
|
||||||
GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(Configuration::Component)
|
|
||||||
GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(Configuration::Option)
|
|
||||||
GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(Configuration::Argument)
|
|
||||||
|
|
||||||
#endif // __GPGMEPP_CONFIGURATION_H__
|
|
File diff suppressed because it is too large
Load Diff
@ -1,564 +0,0 @@
|
|||||||
/*
|
|
||||||
context.h - wraps a gpgme key context
|
|
||||||
Copyright (C) 2003, 2007 Klarälvdalens Datakonsult AB
|
|
||||||
|
|
||||||
This file is part of GPGME++.
|
|
||||||
|
|
||||||
GPGME++ is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// -*- c++ -*-
|
|
||||||
#ifndef __GPGMEPP_CONTEXT_H__
|
|
||||||
#define __GPGMEPP_CONTEXT_H__
|
|
||||||
|
|
||||||
#include "global.h"
|
|
||||||
|
|
||||||
#include "error.h"
|
|
||||||
#include "key.h"
|
|
||||||
#include "verificationresult.h" // for Signature::Notation
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include <utility>
|
|
||||||
#include <iosfwd>
|
|
||||||
|
|
||||||
namespace GpgME
|
|
||||||
{
|
|
||||||
|
|
||||||
class Data;
|
|
||||||
class TrustItem;
|
|
||||||
class ProgressProvider;
|
|
||||||
class PassphraseProvider;
|
|
||||||
class EventLoopInteractor;
|
|
||||||
class EditInteractor;
|
|
||||||
class AssuanTransaction;
|
|
||||||
|
|
||||||
class KeyListResult;
|
|
||||||
class KeyGenerationResult;
|
|
||||||
class ImportResult;
|
|
||||||
class DecryptionResult;
|
|
||||||
class VerificationResult;
|
|
||||||
class SigningResult;
|
|
||||||
class EncryptionResult;
|
|
||||||
class VfsMountResult;
|
|
||||||
|
|
||||||
class EngineInfo;
|
|
||||||
|
|
||||||
class GPGMEPP_EXPORT Context
|
|
||||||
{
|
|
||||||
explicit Context(gpgme_ctx_t);
|
|
||||||
public:
|
|
||||||
//using GpgME::Protocol;
|
|
||||||
|
|
||||||
/// RAII-style class for saving/restoring the key list mode.
|
|
||||||
class GPGMEPP_EXPORT KeyListModeSaver
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit KeyListModeSaver(Context *ctx);
|
|
||||||
~KeyListModeSaver();
|
|
||||||
private:
|
|
||||||
Context *mCtx;
|
|
||||||
unsigned int mKeyListMode;
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// Creation and destruction:
|
|
||||||
//
|
|
||||||
|
|
||||||
static Context *createForProtocol(Protocol proto);
|
|
||||||
/** Same as above but returning a unique ptr. */
|
|
||||||
static std::unique_ptr<Context> create(Protocol proto);
|
|
||||||
static std::unique_ptr<Context> createForEngine(Engine engine, Error *err = nullptr);
|
|
||||||
virtual ~Context();
|
|
||||||
|
|
||||||
//
|
|
||||||
// Context Attributes
|
|
||||||
//
|
|
||||||
|
|
||||||
Protocol protocol() const;
|
|
||||||
|
|
||||||
void setArmor(bool useArmor);
|
|
||||||
bool armor() const;
|
|
||||||
|
|
||||||
void setTextMode(bool useTextMode);
|
|
||||||
bool textMode() const;
|
|
||||||
|
|
||||||
void setOffline(bool useOfflineMode);
|
|
||||||
bool offline() const;
|
|
||||||
|
|
||||||
const char *getFlag(const char *name) const;
|
|
||||||
Error setFlag(const char *name, const char *value);
|
|
||||||
|
|
||||||
enum CertificateInclusion {
|
|
||||||
DefaultCertificates = -256,
|
|
||||||
AllCertificatesExceptRoot = -2,
|
|
||||||
AllCertificates = -1,
|
|
||||||
NoCertificates = 0,
|
|
||||||
OnlySenderCertificate = 1
|
|
||||||
};
|
|
||||||
void setIncludeCertificates(int which);
|
|
||||||
int includeCertificates() const;
|
|
||||||
|
|
||||||
//using GpgME::KeyListMode;
|
|
||||||
void setKeyListMode(unsigned int keyListMode);
|
|
||||||
void addKeyListMode(unsigned int keyListMode);
|
|
||||||
unsigned int keyListMode() const;
|
|
||||||
|
|
||||||
/** Set the passphrase provider
|
|
||||||
*
|
|
||||||
* To avoid problems where a class using a context registers
|
|
||||||
* itself as the provider the Context does not take ownership
|
|
||||||
* of the provider and the caller must ensure that the provider
|
|
||||||
* is deleted if it is no longer needed.
|
|
||||||
*/
|
|
||||||
void setPassphraseProvider(PassphraseProvider *provider);
|
|
||||||
PassphraseProvider *passphraseProvider() const;
|
|
||||||
|
|
||||||
/** Set the progress provider
|
|
||||||
*
|
|
||||||
* To avoid problems where a class using a context registers
|
|
||||||
* itself as the provider the Context does not take ownership
|
|
||||||
* of the provider and the caller must ensure that the provider
|
|
||||||
* is deleted if it is no longer needed.
|
|
||||||
*/
|
|
||||||
void setProgressProvider(ProgressProvider *provider);
|
|
||||||
ProgressProvider *progressProvider() const;
|
|
||||||
|
|
||||||
void setManagedByEventLoopInteractor(bool managed);
|
|
||||||
bool managedByEventLoopInteractor() const;
|
|
||||||
|
|
||||||
GpgME::Error setLocale(int category, const char *value);
|
|
||||||
|
|
||||||
EngineInfo engineInfo() const;
|
|
||||||
GpgME::Error setEngineFileName(const char *filename);
|
|
||||||
GpgME::Error setEngineHomeDirectory(const char *filename);
|
|
||||||
|
|
||||||
enum PinentryMode{
|
|
||||||
PinentryDefault = 0,
|
|
||||||
PinentryAsk = 1,
|
|
||||||
PinentryCancel = 2,
|
|
||||||
PinentryError = 3,
|
|
||||||
PinentryLoopback = 4
|
|
||||||
};
|
|
||||||
GpgME::Error setPinentryMode(PinentryMode which);
|
|
||||||
PinentryMode pinentryMode() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend class ::GpgME::EventLoopInteractor;
|
|
||||||
void installIOCallbacks(gpgme_io_cbs *iocbs);
|
|
||||||
void uninstallIOCallbacks();
|
|
||||||
|
|
||||||
public:
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Key Management
|
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// Key Listing
|
|
||||||
//
|
|
||||||
|
|
||||||
GpgME::Error startKeyListing(const char *pattern = nullptr, bool secretOnly = false);
|
|
||||||
GpgME::Error startKeyListing(const char *patterns[], bool secretOnly = false);
|
|
||||||
|
|
||||||
Key nextKey(GpgME::Error &e);
|
|
||||||
|
|
||||||
KeyListResult endKeyListing();
|
|
||||||
KeyListResult keyListResult() const;
|
|
||||||
|
|
||||||
Key key(const char *fingerprint, GpgME::Error &e, bool secret = false);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Key Generation
|
|
||||||
//
|
|
||||||
|
|
||||||
KeyGenerationResult generateKey(const char *parameters, Data &pubKey);
|
|
||||||
GpgME::Error startKeyGeneration(const char *parameters, Data &pubkey);
|
|
||||||
KeyGenerationResult keyGenerationResult() const;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Key Export
|
|
||||||
//
|
|
||||||
enum ExportMode {
|
|
||||||
ExportDefault = 0,
|
|
||||||
ExportExtern = 2,
|
|
||||||
ExportMinimal = 4,
|
|
||||||
ExportSecret = 16,
|
|
||||||
ExportRaw = 32,
|
|
||||||
ExportPKCS12 = 64,
|
|
||||||
ExportNoUID = 128, // obsolete; has no effect
|
|
||||||
ExportSSH = 256,
|
|
||||||
ExportSecretSubkey = 512,
|
|
||||||
};
|
|
||||||
|
|
||||||
GpgME::Error exportPublicKeys(const char *pattern, Data &keyData);
|
|
||||||
GpgME::Error exportPublicKeys(const char *pattern, Data &keyData, unsigned int mode);
|
|
||||||
GpgME::Error exportPublicKeys(const char *pattern[], Data &keyData);
|
|
||||||
GpgME::Error exportPublicKeys(const char *pattern[], Data &keyData, unsigned int mode);
|
|
||||||
GpgME::Error startPublicKeyExport(const char *pattern, Data &keyData);
|
|
||||||
GpgME::Error startPublicKeyExport(const char *pattern, Data &keyData, unsigned int mode);
|
|
||||||
GpgME::Error startPublicKeyExport(const char *pattern[], Data &keyData);
|
|
||||||
GpgME::Error startPublicKeyExport(const char *pattern[], Data &keyData, unsigned int mode);
|
|
||||||
|
|
||||||
GpgME::Error exportSecretKeys(const char *pattern, Data &keyData, unsigned int mode = ExportSecret);
|
|
||||||
GpgME::Error exportSecretKeys(const char *pattern[], Data &keyData, unsigned int mode = ExportSecret);
|
|
||||||
GpgME::Error startSecretKeyExport(const char *pattern, Data &keyData, unsigned int mode = ExportSecret);
|
|
||||||
GpgME::Error startSecretKeyExport(const char *pattern[], Data &keyData, unsigned int mode = ExportSecret);
|
|
||||||
|
|
||||||
GpgME::Error exportSecretSubkeys(const char *pattern, Data &keyData, unsigned int mode = ExportSecretSubkey);
|
|
||||||
GpgME::Error exportSecretSubkeys(const char *pattern[], Data &keyData, unsigned int mode = ExportSecretSubkey);
|
|
||||||
GpgME::Error startSecretSubkeyExport(const char *pattern, Data &keyData, unsigned int mode = ExportSecretSubkey);
|
|
||||||
GpgME::Error startSecretSubkeyExport(const char *pattern[], Data &keyData, unsigned int mode = ExportSecretSubkey);
|
|
||||||
|
|
||||||
// generic export functions; prefer using the specific public/secret key export functions
|
|
||||||
GpgME::Error exportKeys(const char *pattern, Data &keyData, unsigned int mode = ExportDefault);
|
|
||||||
GpgME::Error exportKeys(const char *pattern[], Data &keyData, unsigned int mode = ExportDefault);
|
|
||||||
GpgME::Error startKeyExport(const char *pattern, Data &keyData, unsigned int mode = ExportDefault);
|
|
||||||
GpgME::Error startKeyExport(const char *pattern[], Data &keyData, unsigned int mode = ExportDefault);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Key Import
|
|
||||||
//
|
|
||||||
|
|
||||||
ImportResult importKeys(const Data &data);
|
|
||||||
ImportResult importKeys(const std::vector<Key> &keys);
|
|
||||||
ImportResult importKeys(const std::vector<std::string> &keyIds);
|
|
||||||
GpgME::Error startKeyImport(const Data &data);
|
|
||||||
GpgME::Error startKeyImport(const std::vector<Key> &keys);
|
|
||||||
GpgME::Error startKeyImport(const std::vector<std::string> &keyIds);
|
|
||||||
ImportResult importResult() const;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Key Deletion
|
|
||||||
//
|
|
||||||
|
|
||||||
GpgME::Error deleteKey(const Key &key, bool allowSecretKeyDeletion = false);
|
|
||||||
GpgME::Error startKeyDeletion(const Key &key, bool allowSecretKeyDeletion = false);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Passphrase changing
|
|
||||||
//
|
|
||||||
|
|
||||||
GpgME::Error passwd(const Key &key);
|
|
||||||
GpgME::Error startPasswd(const Key &key);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Key Editing
|
|
||||||
//
|
|
||||||
|
|
||||||
GpgME::Error edit(const Key &key, std::unique_ptr<EditInteractor> function, Data &out);
|
|
||||||
GpgME::Error startEditing(const Key &key, std::unique_ptr<EditInteractor> function, Data &out);
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Modern Interface actions. Require 2.1.x
|
|
||||||
//
|
|
||||||
Error startCreateKey (const char *userid,
|
|
||||||
const char *algo,
|
|
||||||
unsigned long reserved,
|
|
||||||
unsigned long expires,
|
|
||||||
const Key &certkey,
|
|
||||||
unsigned int flags);
|
|
||||||
Error createKey (const char *userid,
|
|
||||||
const char *algo,
|
|
||||||
unsigned long reserved,
|
|
||||||
unsigned long expires,
|
|
||||||
const Key &certkey,
|
|
||||||
unsigned int flags);
|
|
||||||
|
|
||||||
// Same as create key but returning a result
|
|
||||||
GpgME::KeyGenerationResult createKeyEx (const char *userid,
|
|
||||||
const char *algo,
|
|
||||||
unsigned long reserved,
|
|
||||||
unsigned long expires,
|
|
||||||
const Key &certkey,
|
|
||||||
unsigned int flags);
|
|
||||||
|
|
||||||
Error addUid(const Key &key, const char *userid);
|
|
||||||
Error startAddUid(const Key &key, const char *userid);
|
|
||||||
|
|
||||||
Error revUid(const Key &key, const char *userid);
|
|
||||||
Error startRevUid(const Key &key, const char *userid);
|
|
||||||
|
|
||||||
Error setPrimaryUid(const Key &key, const char *userid);
|
|
||||||
Error startSetPrimaryUid(const Key &key, const char *userid);
|
|
||||||
|
|
||||||
Error createSubkey(const Key &key, const char *algo,
|
|
||||||
unsigned long reserved = 0,
|
|
||||||
unsigned long expires = 0,
|
|
||||||
unsigned int flags = 0);
|
|
||||||
Error startCreateSubkey(const Key &key, const char *algo,
|
|
||||||
unsigned long reserved = 0,
|
|
||||||
unsigned long expires = 0,
|
|
||||||
unsigned int flags = 0);
|
|
||||||
|
|
||||||
enum SetExpireFlags {
|
|
||||||
SetExpireDefault = 0,
|
|
||||||
SetExpireAllSubkeys = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
Error setExpire(const Key &k, unsigned long expires,
|
|
||||||
const std::vector<Subkey> &subkeys = std::vector<Subkey>(),
|
|
||||||
const SetExpireFlags flags = SetExpireDefault);
|
|
||||||
Error startSetExpire(const Key &k, unsigned long expires,
|
|
||||||
const std::vector<Subkey> &subkeys = std::vector<Subkey>(),
|
|
||||||
const SetExpireFlags flags = SetExpireDefault);
|
|
||||||
|
|
||||||
Error revokeSignature(const Key &key, const Key &signingKey,
|
|
||||||
const std::vector<UserID> &userIds = std::vector<UserID>());
|
|
||||||
Error startRevokeSignature(const Key &key, const Key &signingKey,
|
|
||||||
const std::vector<UserID> &userIds = std::vector<UserID>());
|
|
||||||
|
|
||||||
Error addAdsk(const Key &k, const char *adsk);
|
|
||||||
Error startAddAdsk(const Key &k, const char *adsk);
|
|
||||||
|
|
||||||
// using TofuInfo::Policy
|
|
||||||
Error setTofuPolicy(const Key &k, unsigned int policy);
|
|
||||||
Error setTofuPolicyStart(const Key &k, unsigned int policy);
|
|
||||||
|
|
||||||
EditInteractor *lastEditInteractor() const;
|
|
||||||
std::unique_ptr<EditInteractor> takeLastEditInteractor();
|
|
||||||
|
|
||||||
//
|
|
||||||
// SmartCard Editing
|
|
||||||
//
|
|
||||||
|
|
||||||
GpgME::Error cardEdit(const Key &key, std::unique_ptr<EditInteractor> function, Data &out);
|
|
||||||
GpgME::Error startCardEditing(const Key &key, std::unique_ptr<EditInteractor> function, Data &out);
|
|
||||||
|
|
||||||
EditInteractor *lastCardEditInteractor() const;
|
|
||||||
std::unique_ptr<EditInteractor> takeLastCardEditInteractor();
|
|
||||||
|
|
||||||
//
|
|
||||||
// Trust Item Management
|
|
||||||
//
|
|
||||||
|
|
||||||
GpgME::Error startTrustItemListing(const char *pattern, int maxLevel);
|
|
||||||
TrustItem nextTrustItem(GpgME::Error &e);
|
|
||||||
GpgME::Error endTrustItemListing();
|
|
||||||
|
|
||||||
//
|
|
||||||
// Assuan Transactions
|
|
||||||
//
|
|
||||||
|
|
||||||
GpgME::Error assuanTransact(const char *command, std::unique_ptr<AssuanTransaction> transaction);
|
|
||||||
GpgME::Error assuanTransact(const char *command);
|
|
||||||
GpgME::Error startAssuanTransaction(const char *command, std::unique_ptr<AssuanTransaction> transaction);
|
|
||||||
GpgME::Error startAssuanTransaction(const char *command);
|
|
||||||
|
|
||||||
AssuanTransaction *lastAssuanTransaction() const;
|
|
||||||
std::unique_ptr<AssuanTransaction> takeLastAssuanTransaction();
|
|
||||||
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Crypto Operations
|
|
||||||
//
|
|
||||||
|
|
||||||
enum DecryptionFlags {
|
|
||||||
// Keep in line with core's flags
|
|
||||||
DecryptNone = 0,
|
|
||||||
DecryptVerify = 1,
|
|
||||||
DecryptArchive = 2,
|
|
||||||
DecryptUnwrap = 128,
|
|
||||||
DecryptMaxValue = 0x80000000
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// Decryption
|
|
||||||
//
|
|
||||||
|
|
||||||
// Alternative way to set decryption flags as they were added only in
|
|
||||||
// 1.9.0 and so other API can still be used but with 1.9.0 additionally
|
|
||||||
// flags can be set.
|
|
||||||
void setDecryptionFlags (const DecryptionFlags flags);
|
|
||||||
|
|
||||||
DecryptionResult decrypt(const Data &cipherText, Data &plainText);
|
|
||||||
GpgME::Error startDecryption(const Data &cipherText, Data &plainText);
|
|
||||||
DecryptionResult decrypt(const Data &cipherText, Data &plainText, const DecryptionFlags flags);
|
|
||||||
GpgME::Error startDecryption(const Data &cipherText, Data &plainText, const DecryptionFlags flags);
|
|
||||||
DecryptionResult decryptionResult() const;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Signature Verification
|
|
||||||
//
|
|
||||||
|
|
||||||
VerificationResult verifyDetachedSignature(const Data &signature, const Data &signedText);
|
|
||||||
VerificationResult verifyOpaqueSignature(const Data &signedData, Data &plainText);
|
|
||||||
GpgME::Error startDetachedSignatureVerification(const Data &signature, const Data &signedText);
|
|
||||||
GpgME::Error startOpaqueSignatureVerification(const Data &signedData, Data &plainText);
|
|
||||||
VerificationResult verificationResult() const;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Combined Decryption and Signature Verification
|
|
||||||
//
|
|
||||||
|
|
||||||
std::pair<DecryptionResult, VerificationResult> decryptAndVerify(const Data &cipherText, Data &plainText);
|
|
||||||
std::pair<DecryptionResult, VerificationResult> decryptAndVerify(const Data &cipherText, Data &plainText, const DecryptionFlags flags);
|
|
||||||
GpgME::Error startCombinedDecryptionAndVerification(const Data &cipherText, Data &plainText);
|
|
||||||
GpgME::Error startCombinedDecryptionAndVerification(const Data &cipherText, Data &plainText, const DecryptionFlags flags);
|
|
||||||
// use verificationResult() and decryptionResult() to retrieve the result objects...
|
|
||||||
|
|
||||||
//
|
|
||||||
// Signing
|
|
||||||
//
|
|
||||||
|
|
||||||
void clearSigningKeys();
|
|
||||||
GpgME::Error addSigningKey(const Key &signer);
|
|
||||||
Key signingKey(unsigned int index) const;
|
|
||||||
std::vector<Key> signingKeys() const;
|
|
||||||
|
|
||||||
void clearSignatureNotations();
|
|
||||||
GpgME::Error addSignatureNotation(const char *name, const char *value, unsigned int flags = 0);
|
|
||||||
GpgME::Error addSignaturePolicyURL(const char *url, bool critical = false);
|
|
||||||
const char *signaturePolicyURL() const;
|
|
||||||
Notation signatureNotation(unsigned int index) const;
|
|
||||||
std::vector<Notation> signatureNotations() const;
|
|
||||||
|
|
||||||
//using GpgME::SignatureMode;
|
|
||||||
SigningResult sign(const Data &plainText, Data &signature, SignatureMode mode);
|
|
||||||
GpgME::Error startSigning(const Data &plainText, Data &signature, SignatureMode mode);
|
|
||||||
SigningResult signingResult() const;
|
|
||||||
|
|
||||||
// wrapper for gpgme_set_sender
|
|
||||||
const char *getSender();
|
|
||||||
GpgME::Error setSender(const char *sender);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Encryption
|
|
||||||
//
|
|
||||||
|
|
||||||
enum EncryptionFlags {
|
|
||||||
None = 0,
|
|
||||||
AlwaysTrust = 1,
|
|
||||||
NoEncryptTo = 2,
|
|
||||||
Prepare = 4,
|
|
||||||
ExpectSign = 8,
|
|
||||||
NoCompress = 16,
|
|
||||||
Symmetric = 32,
|
|
||||||
ThrowKeyIds = 64,
|
|
||||||
EncryptWrap = 128,
|
|
||||||
WantAddress = 256,
|
|
||||||
EncryptArchive = 512,
|
|
||||||
EncryptFile = 1024
|
|
||||||
};
|
|
||||||
EncryptionResult encrypt(const std::vector<Key> &recipients, const Data &plainText, Data &cipherText, EncryptionFlags flags);
|
|
||||||
GpgME::Error encryptSymmetrically(const Data &plainText, Data &cipherText);
|
|
||||||
GpgME::Error startEncryption(const std::vector<Key> &recipients, const Data &plainText, Data &cipherText, EncryptionFlags flags);
|
|
||||||
EncryptionResult encryptionResult() const;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Combined Signing and Encryption
|
|
||||||
//
|
|
||||||
|
|
||||||
std::pair<SigningResult, EncryptionResult> signAndEncrypt(const std::vector<Key> &recipients, const Data &plainText, Data &cipherText, EncryptionFlags flags);
|
|
||||||
GpgME::Error startCombinedSigningAndEncryption(const std::vector<Key> &recipients, const Data &plainText, Data &cipherText, EncryptionFlags flags);
|
|
||||||
// use encryptionResult() and signingResult() to retrieve the result objects...
|
|
||||||
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Audit Log
|
|
||||||
//
|
|
||||||
//
|
|
||||||
enum AuditLogFlags {
|
|
||||||
DefaultAuditLog = 0,
|
|
||||||
HtmlAuditLog = 1,
|
|
||||||
DiagnosticAuditLog = 2,
|
|
||||||
AuditLogWithHelp = 128
|
|
||||||
};
|
|
||||||
GpgME::Error startGetAuditLog(Data &output, unsigned int flags = 0);
|
|
||||||
GpgME::Error getAuditLog(Data &output, unsigned int flags = 0);
|
|
||||||
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// G13 crypto container operations
|
|
||||||
//
|
|
||||||
//
|
|
||||||
GpgME::Error createVFS(const char *containerFile, const std::vector<Key> &recipients);
|
|
||||||
VfsMountResult mountVFS(const char *containerFile, const char *mountDir);
|
|
||||||
|
|
||||||
// Spawn Engine
|
|
||||||
enum SpawnFlags {
|
|
||||||
SpawnNone = 0,
|
|
||||||
SpawnDetached = 1,
|
|
||||||
SpawnAllowSetFg = 2,
|
|
||||||
SpawnShowWindow = 4
|
|
||||||
};
|
|
||||||
/** Spwan the process \a file with arguments \a argv.
|
|
||||||
*
|
|
||||||
* If a data parameter is null the /dev/null will be
|
|
||||||
* used. (Or other platform stuff).
|
|
||||||
*
|
|
||||||
* @param file The executable to start.
|
|
||||||
* @param argv list of arguments file should be argv[0].
|
|
||||||
* @param input The data to be sent through stdin.
|
|
||||||
* @param output The data to be receive the stdout.
|
|
||||||
* @param err The data to receive stderr.
|
|
||||||
* @param flags Additional flags.
|
|
||||||
*
|
|
||||||
* @returns An error or empty error.
|
|
||||||
*/
|
|
||||||
GpgME::Error spawn(const char *file, const char *argv[],
|
|
||||||
Data &input, Data &output, Data &err,
|
|
||||||
SpawnFlags flags);
|
|
||||||
/** Async variant of spawn. Immediately returns after starting the
|
|
||||||
* process. */
|
|
||||||
GpgME::Error spawnAsync(const char *file, const char *argv[],
|
|
||||||
Data &input, Data &output,
|
|
||||||
Data &err, SpawnFlags flags);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Run Control
|
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
bool poll();
|
|
||||||
GpgME::Error wait();
|
|
||||||
GpgME::Error lastError() const;
|
|
||||||
GpgME::Error cancelPendingOperation();
|
|
||||||
GpgME::Error cancelPendingOperationImmediately();
|
|
||||||
|
|
||||||
class Private;
|
|
||||||
const Private *impl() const
|
|
||||||
{
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
Private *impl()
|
|
||||||
{
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Helper functions that need to be context because they rely
|
|
||||||
// on the "Friendlyness" of context to access the gpgme types.
|
|
||||||
gpgme_key_t *getKeysFromRecipients(const std::vector<Key> &recipients);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Private *const d;
|
|
||||||
|
|
||||||
private: // disable...
|
|
||||||
Context(const Context &);
|
|
||||||
const Context &operator=(const Context &);
|
|
||||||
};
|
|
||||||
|
|
||||||
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, Context::CertificateInclusion incl);
|
|
||||||
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, Context::EncryptionFlags flags);
|
|
||||||
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, Context::AuditLogFlags flags);
|
|
||||||
|
|
||||||
} // namespace GpgME
|
|
||||||
|
|
||||||
#endif // __GPGMEPP_CONTEXT_H__
|
|
@ -1,88 +0,0 @@
|
|||||||
/*
|
|
||||||
context_p.h - wraps a gpgme context (private part)
|
|
||||||
Copyright (C) 2003, 2007 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// -*- c++ -*-
|
|
||||||
#ifndef __GPGMEPP_CONTEXT_P_H__
|
|
||||||
#define __GPGMEPP_CONTEXT_P_H__
|
|
||||||
|
|
||||||
#include <context.h>
|
|
||||||
#include <data.h>
|
|
||||||
|
|
||||||
#include <gpgme.h>
|
|
||||||
|
|
||||||
namespace GpgME
|
|
||||||
{
|
|
||||||
|
|
||||||
class Context::Private
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum Operation {
|
|
||||||
None = 0,
|
|
||||||
|
|
||||||
Encrypt = 0x001,
|
|
||||||
Decrypt = 0x002,
|
|
||||||
Sign = 0x004,
|
|
||||||
Verify = 0x008,
|
|
||||||
DecryptAndVerify = Decrypt | Verify,
|
|
||||||
SignAndEncrypt = Sign | Encrypt,
|
|
||||||
|
|
||||||
Import = 0x010,
|
|
||||||
Export = 0x020, // no gpgme_export_result_t, but nevertheless...
|
|
||||||
Delete = 0x040, // no gpgme_delete_result_t, but nevertheless...
|
|
||||||
|
|
||||||
KeyGen = 0x080,
|
|
||||||
KeyList = 0x100,
|
|
||||||
KeyListWithImport = KeyList | Import, // gpgme_keylist_result_t and gpgme_import_result_t
|
|
||||||
TrustList = 0x200, // no gpgme_trustlist_result_t, but nevertheless...
|
|
||||||
|
|
||||||
Edit = 0x400, // no gpgme_edit_result_t, but nevertheless...
|
|
||||||
CardEdit = 0x800, // no gpgme_card_edit_result_t, but nevertheless...
|
|
||||||
|
|
||||||
GetAuditLog = 0x1000, // no gpgme_getauditlog_result_t, but nevertheless...
|
|
||||||
|
|
||||||
AssuanTransact = 0x2000,
|
|
||||||
Passwd = 0x4000, // no gpgme_passwd_result_t, but nevertheless...
|
|
||||||
|
|
||||||
CreateVFS = 0x4000,
|
|
||||||
MountVFS = 0x8000,
|
|
||||||
|
|
||||||
EndMarker
|
|
||||||
};
|
|
||||||
|
|
||||||
Private(gpgme_ctx_t c = nullptr);
|
|
||||||
~Private();
|
|
||||||
|
|
||||||
gpgme_ctx_t ctx;
|
|
||||||
gpgme_io_cbs *iocbs;
|
|
||||||
Operation lastop;
|
|
||||||
gpgme_error_t lasterr;
|
|
||||||
Data lastAssuanInquireData;
|
|
||||||
std::unique_ptr<AssuanTransaction> lastAssuanTransaction;
|
|
||||||
std::unique_ptr<EditInteractor> lastEditInteractor, lastCardEditInteractor;
|
|
||||||
DecryptionFlags decryptFlags;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace GpgME
|
|
||||||
|
|
||||||
#endif // __GPGMEPP_CONTEXT_P_H__
|
|
@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
context_vanilla.cpp - wraps a gpgme key context, gpgme (vanilla)-specific functions
|
|
||||||
Copyright (C) 2007 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <global.h>
|
|
||||||
|
|
||||||
GIOChannel *GpgME::getGIOChannel(int)
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
QIODevice *GpgME::getQIODevice(int)
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
@ -1,293 +0,0 @@
|
|||||||
/*
|
|
||||||
data.cpp - wraps a gpgme data object
|
|
||||||
Copyright (C) 2003 Klarälvdalens Datakonsult AB
|
|
||||||
|
|
||||||
This file is part of GPGME++.
|
|
||||||
|
|
||||||
GPGME++ is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "data_p.h"
|
|
||||||
#include "context_p.h"
|
|
||||||
#include <error.h>
|
|
||||||
#include <interfaces/dataprovider.h>
|
|
||||||
|
|
||||||
#include <gpgme.h>
|
|
||||||
|
|
||||||
#ifndef NDEBUG
|
|
||||||
#include <iostream>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
GpgME::Data::Private::~Private()
|
|
||||||
{
|
|
||||||
if (data) {
|
|
||||||
gpgme_data_release(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const GpgME::Data::Null GpgME::Data::null;
|
|
||||||
|
|
||||||
GpgME::Data::Data()
|
|
||||||
{
|
|
||||||
gpgme_data_t data;
|
|
||||||
const gpgme_error_t e = gpgme_data_new(&data);
|
|
||||||
d.reset(new Private(e ? nullptr : data));
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgME::Data::Data(const Null &)
|
|
||||||
: d(new Private(nullptr))
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgME::Data::Data(gpgme_data_t data)
|
|
||||||
: d(new Private(data))
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgME::Data::Data(const char *buffer, size_t size, bool copy)
|
|
||||||
{
|
|
||||||
gpgme_data_t data;
|
|
||||||
const gpgme_error_t e = gpgme_data_new_from_mem(&data, buffer, size, int(copy));
|
|
||||||
std::string sizestr = std::to_string(size);
|
|
||||||
// Ignore errors as this is optional
|
|
||||||
gpgme_data_set_flag(data, "size-hint", sizestr.c_str());
|
|
||||||
d.reset(new Private(e ? nullptr : data));
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgME::Data::Data(const char *filename)
|
|
||||||
{
|
|
||||||
gpgme_data_t data;
|
|
||||||
const gpgme_error_t e = gpgme_data_new(&data);
|
|
||||||
d.reset(new Private(e ? nullptr : data));
|
|
||||||
if (!e) {
|
|
||||||
setFileName(filename);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgME::Data::Data(const char *filename, off_t offset, size_t length)
|
|
||||||
{
|
|
||||||
gpgme_data_t data;
|
|
||||||
const gpgme_error_t e = gpgme_data_new_from_filepart(&data, filename, nullptr, offset, length);
|
|
||||||
d.reset(new Private(e ? nullptr : data));
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgME::Data::Data(FILE *fp)
|
|
||||||
{
|
|
||||||
gpgme_data_t data;
|
|
||||||
const gpgme_error_t e = gpgme_data_new_from_stream(&data, fp);
|
|
||||||
d.reset(new Private(e ? nullptr : data));
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgME::Data::Data(FILE *fp, off_t offset, size_t length)
|
|
||||||
{
|
|
||||||
gpgme_data_t data;
|
|
||||||
const gpgme_error_t e = gpgme_data_new_from_filepart(&data, nullptr, fp, offset, length);
|
|
||||||
d.reset(new Private(e ? nullptr : data));
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgME::Data::Data(int fd)
|
|
||||||
{
|
|
||||||
gpgme_data_t data;
|
|
||||||
const gpgme_error_t e = gpgme_data_new_from_fd(&data, fd);
|
|
||||||
d.reset(new Private(e ? nullptr : data));
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgME::Data::Data(DataProvider *dp)
|
|
||||||
{
|
|
||||||
d.reset(new Private);
|
|
||||||
if (!dp) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!dp->isSupported(DataProvider::Read)) {
|
|
||||||
d->cbs.read = nullptr;
|
|
||||||
}
|
|
||||||
if (!dp->isSupported(DataProvider::Write)) {
|
|
||||||
d->cbs.write = nullptr;
|
|
||||||
}
|
|
||||||
if (!dp->isSupported(DataProvider::Seek)) {
|
|
||||||
d->cbs.seek = nullptr;
|
|
||||||
}
|
|
||||||
if (!dp->isSupported(DataProvider::Release)) {
|
|
||||||
d->cbs.release = nullptr;
|
|
||||||
}
|
|
||||||
const gpgme_error_t e = gpgme_data_new_from_cbs(&d->data, &d->cbs, dp);
|
|
||||||
if (e) {
|
|
||||||
d->data = nullptr;
|
|
||||||
}
|
|
||||||
if (dp->isSupported(DataProvider::Seek)) {
|
|
||||||
off_t size = seek(0, SEEK_END);
|
|
||||||
seek(0, SEEK_SET);
|
|
||||||
std::string sizestr = std::to_string(size);
|
|
||||||
// Ignore errors as this is optional
|
|
||||||
gpgme_data_set_flag(d->data, "size-hint", sizestr.c_str());
|
|
||||||
}
|
|
||||||
#ifndef NDEBUG
|
|
||||||
//std::cerr << "GpgME::Data(): DataProvider supports: "
|
|
||||||
// << ( d->cbs.read ? "read" : "no read" ) << ", "
|
|
||||||
// << ( d->cbs.write ? "write" : "no write" ) << ", "
|
|
||||||
// << ( d->cbs.seek ? "seek" : "no seek" ) << ", "
|
|
||||||
// << ( d->cbs.release ? "release" : "no release" ) << std::endl;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GpgME::Data::isNull() const
|
|
||||||
{
|
|
||||||
return !d || !d->data;
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgME::Data::Encoding GpgME::Data::encoding() const
|
|
||||||
{
|
|
||||||
switch (gpgme_data_get_encoding(d->data)) {
|
|
||||||
case GPGME_DATA_ENCODING_NONE: return AutoEncoding;
|
|
||||||
case GPGME_DATA_ENCODING_BINARY: return BinaryEncoding;
|
|
||||||
case GPGME_DATA_ENCODING_BASE64: return Base64Encoding;
|
|
||||||
case GPGME_DATA_ENCODING_ARMOR: return ArmorEncoding;
|
|
||||||
case GPGME_DATA_ENCODING_MIME: return MimeEncoding;
|
|
||||||
case GPGME_DATA_ENCODING_URL: return UrlEncoding;
|
|
||||||
case GPGME_DATA_ENCODING_URLESC: return UrlEscEncoding;
|
|
||||||
case GPGME_DATA_ENCODING_URL0: return Url0Encoding;
|
|
||||||
}
|
|
||||||
return AutoEncoding;
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgME::Error GpgME::Data::setEncoding(Encoding enc)
|
|
||||||
{
|
|
||||||
gpgme_data_encoding_t ge = GPGME_DATA_ENCODING_NONE;
|
|
||||||
switch (enc) {
|
|
||||||
case AutoEncoding: ge = GPGME_DATA_ENCODING_NONE; break;
|
|
||||||
case BinaryEncoding: ge = GPGME_DATA_ENCODING_BINARY; break;
|
|
||||||
case Base64Encoding: ge = GPGME_DATA_ENCODING_BASE64; break;
|
|
||||||
case ArmorEncoding: ge = GPGME_DATA_ENCODING_ARMOR; break;
|
|
||||||
case MimeEncoding: ge = GPGME_DATA_ENCODING_MIME; break;
|
|
||||||
case UrlEncoding: ge = GPGME_DATA_ENCODING_URL; break;
|
|
||||||
case UrlEscEncoding: ge = GPGME_DATA_ENCODING_URLESC; break;
|
|
||||||
case Url0Encoding: ge = GPGME_DATA_ENCODING_URL0; break;
|
|
||||||
}
|
|
||||||
return Error(gpgme_data_set_encoding(d->data, ge));
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgME::Data::Type GpgME::Data::type() const
|
|
||||||
{
|
|
||||||
if (isNull()) {
|
|
||||||
return Invalid;
|
|
||||||
}
|
|
||||||
switch (gpgme_data_identify(d->data, 0)) {
|
|
||||||
case GPGME_DATA_TYPE_INVALID: return Invalid;
|
|
||||||
case GPGME_DATA_TYPE_UNKNOWN: return Unknown;
|
|
||||||
case GPGME_DATA_TYPE_PGP_SIGNED: return PGPSigned;
|
|
||||||
case GPGME_DATA_TYPE_PGP_OTHER: return PGPOther;
|
|
||||||
case GPGME_DATA_TYPE_PGP_KEY: return PGPKey;
|
|
||||||
case GPGME_DATA_TYPE_CMS_SIGNED: return CMSSigned;
|
|
||||||
case GPGME_DATA_TYPE_CMS_ENCRYPTED: return CMSEncrypted;
|
|
||||||
case GPGME_DATA_TYPE_CMS_OTHER: return CMSOther;
|
|
||||||
case GPGME_DATA_TYPE_X509_CERT: return X509Cert;
|
|
||||||
case GPGME_DATA_TYPE_PKCS12: return PKCS12;
|
|
||||||
case GPGME_DATA_TYPE_PGP_ENCRYPTED: return PGPEncrypted;
|
|
||||||
case GPGME_DATA_TYPE_PGP_SIGNATURE: return PGPSignature;
|
|
||||||
}
|
|
||||||
return Invalid;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *GpgME::Data::fileName() const
|
|
||||||
{
|
|
||||||
return gpgme_data_get_file_name(d->data);
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgME::Error GpgME::Data::setFileName(const char *name)
|
|
||||||
{
|
|
||||||
return Error(gpgme_data_set_file_name(d->data, name));
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgME::Error GpgME::Data::setFileName(const std::string &name)
|
|
||||||
{
|
|
||||||
return Error(gpgme_data_set_file_name(d->data, name.c_str()));
|
|
||||||
}
|
|
||||||
|
|
||||||
ssize_t GpgME::Data::read(void *buffer, size_t length)
|
|
||||||
{
|
|
||||||
return gpgme_data_read(d->data, buffer, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
ssize_t GpgME::Data::write(const void *buffer, size_t length)
|
|
||||||
{
|
|
||||||
return gpgme_data_write(d->data, buffer, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
off_t GpgME::Data::seek(off_t offset, int whence)
|
|
||||||
{
|
|
||||||
return gpgme_data_seek(d->data, offset, whence);
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgME::Error GpgME::Data::rewind()
|
|
||||||
{
|
|
||||||
return Error(gpgme_data_rewind(d->data));
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<GpgME::Key> GpgME::Data::toKeys(Protocol proto) const
|
|
||||||
{
|
|
||||||
std::vector<GpgME::Key> ret;
|
|
||||||
if (isNull()) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
auto ctx = GpgME::Context::createForProtocol(proto);
|
|
||||||
if (!ctx) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gpgme_op_keylist_from_data_start (ctx->impl()->ctx, d->data, 0)) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
gpgme_key_t key;
|
|
||||||
while (!gpgme_op_keylist_next (ctx->impl()->ctx, &key)) {
|
|
||||||
ret.push_back(GpgME::Key(key, false));
|
|
||||||
}
|
|
||||||
gpgme_data_seek (d->data, 0, SEEK_SET);
|
|
||||||
|
|
||||||
delete ctx;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string GpgME::Data::toString()
|
|
||||||
{
|
|
||||||
std::string ret;
|
|
||||||
char buf[4096];
|
|
||||||
size_t nread;
|
|
||||||
seek (0, SEEK_SET);
|
|
||||||
while ((nread = read (buf, 4096)) > 0)
|
|
||||||
{
|
|
||||||
ret += std::string (buf, nread);
|
|
||||||
}
|
|
||||||
seek (0, SEEK_SET);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgME::Error GpgME::Data::setFlag(const char *name, const char *value)
|
|
||||||
{
|
|
||||||
return Error(gpgme_data_set_flag(d->data, name, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgME::Error GpgME::Data::setSizeHint(uint64_t size)
|
|
||||||
{
|
|
||||||
const std::string val = std::to_string(size);
|
|
||||||
return Error(gpgme_data_set_flag(d->data, "size-hint", val.c_str()));
|
|
||||||
}
|
|
@ -1,149 +0,0 @@
|
|||||||
/*
|
|
||||||
data.h - wraps a gpgme data object
|
|
||||||
Copyright (C) 2003,2004 Klarälvdalens Datakonsult AB
|
|
||||||
|
|
||||||
This file is part of GPGME++.
|
|
||||||
|
|
||||||
GPGME++ is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GPGMEPP_DATA_H__
|
|
||||||
#define __GPGMEPP_DATA_H__
|
|
||||||
|
|
||||||
#include "global.h"
|
|
||||||
#include "key.h"
|
|
||||||
|
|
||||||
#include <sys/types.h> // for size_t, off_t
|
|
||||||
#include <cstdint> // unit64_t
|
|
||||||
#include <cstdio> // FILE
|
|
||||||
#include <algorithm>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace GpgME
|
|
||||||
{
|
|
||||||
|
|
||||||
class DataProvider;
|
|
||||||
class Error;
|
|
||||||
|
|
||||||
class GPGMEPP_EXPORT Data
|
|
||||||
{
|
|
||||||
struct Null {
|
|
||||||
Null() {}
|
|
||||||
};
|
|
||||||
public:
|
|
||||||
/* implicit */ Data(const Null &);
|
|
||||||
Data();
|
|
||||||
explicit Data(gpgme_data_t data);
|
|
||||||
|
|
||||||
// Memory-Based Data Buffers:
|
|
||||||
Data(const char *buffer, size_t size, bool copy = true);
|
|
||||||
explicit Data(const char *filename);
|
|
||||||
Data(const char *filename, off_t offset, size_t length);
|
|
||||||
Data(std::FILE *fp, off_t offset, size_t length);
|
|
||||||
// File-Based Data Buffers:
|
|
||||||
explicit Data(std::FILE *fp);
|
|
||||||
explicit Data(int fd);
|
|
||||||
// Callback-Based Data Buffers:
|
|
||||||
explicit Data(DataProvider *provider);
|
|
||||||
|
|
||||||
static const Null null;
|
|
||||||
|
|
||||||
Data(const Data &other) = default;
|
|
||||||
const Data &operator=(Data other)
|
|
||||||
{
|
|
||||||
swap(other);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void swap(Data &other)
|
|
||||||
{
|
|
||||||
using std::swap;
|
|
||||||
swap(this->d, other.d);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isNull() const;
|
|
||||||
|
|
||||||
enum Encoding {
|
|
||||||
AutoEncoding,
|
|
||||||
BinaryEncoding,
|
|
||||||
Base64Encoding,
|
|
||||||
ArmorEncoding,
|
|
||||||
MimeEncoding,
|
|
||||||
UrlEncoding,
|
|
||||||
UrlEscEncoding,
|
|
||||||
Url0Encoding,
|
|
||||||
};
|
|
||||||
Encoding encoding() const;
|
|
||||||
Error setEncoding(Encoding encoding);
|
|
||||||
|
|
||||||
enum Type {
|
|
||||||
Invalid,
|
|
||||||
Unknown,
|
|
||||||
PGPSigned,
|
|
||||||
PGPOther,
|
|
||||||
PGPKey,
|
|
||||||
CMSSigned,
|
|
||||||
CMSEncrypted,
|
|
||||||
CMSOther,
|
|
||||||
X509Cert,
|
|
||||||
PKCS12,
|
|
||||||
PGPEncrypted,
|
|
||||||
PGPSignature,
|
|
||||||
};
|
|
||||||
Type type() const;
|
|
||||||
|
|
||||||
char *fileName() const;
|
|
||||||
Error setFileName(const char *name);
|
|
||||||
Error setFileName(const std::string &name);
|
|
||||||
|
|
||||||
ssize_t read(void *buffer, size_t length);
|
|
||||||
ssize_t write(const void *buffer, size_t length);
|
|
||||||
off_t seek(off_t offset, int whence);
|
|
||||||
|
|
||||||
/* Convenience function to do a seek (0, SEEK_SET). */
|
|
||||||
Error rewind();
|
|
||||||
|
|
||||||
/** Try to parse the data to a key object using the
|
|
||||||
* Protocol proto. Returns an empty list on error.*/
|
|
||||||
std::vector<Key> toKeys(const Protocol proto = Protocol::OpenPGP) const;
|
|
||||||
|
|
||||||
/** Return a copy of the data as std::string. Sets seek pos to 0 */
|
|
||||||
std::string toString();
|
|
||||||
|
|
||||||
/** See gpgme_data_set_flag */
|
|
||||||
Error setFlag(const char *name, const char *value);
|
|
||||||
|
|
||||||
/** Set a size hint for this data e.g. for progress calculations. */
|
|
||||||
Error setSizeHint(uint64_t size);
|
|
||||||
|
|
||||||
class Private;
|
|
||||||
Private *impl()
|
|
||||||
{
|
|
||||||
return d.get();
|
|
||||||
}
|
|
||||||
const Private *impl() const
|
|
||||||
{
|
|
||||||
return d.get();
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
std::shared_ptr<Private> d;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(Data)
|
|
||||||
|
|
||||||
#endif // __GPGMEPP_DATA_H__
|
|
@ -1,42 +0,0 @@
|
|||||||
/*
|
|
||||||
data_p.h - wraps a gpgme data object, private part -*- c++ -*-
|
|
||||||
Copyright (C) 2003,2004 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GPGMEPP_DATA_P_H__
|
|
||||||
#define __GPGMEPP_DATA_P_H__
|
|
||||||
|
|
||||||
#include <data.h>
|
|
||||||
#include "callbacks.h"
|
|
||||||
|
|
||||||
class GpgME::Data::Private
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit Private(gpgme_data_t d = nullptr)
|
|
||||||
: data(d), cbs(data_provider_callbacks) {}
|
|
||||||
~Private();
|
|
||||||
|
|
||||||
gpgme_data_t data;
|
|
||||||
gpgme_data_cbs cbs;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // __GPGMEPP_DATA_P_H__
|
|
@ -1,281 +0,0 @@
|
|||||||
/*
|
|
||||||
decryptionresult.cpp - wraps a gpgme keygen result
|
|
||||||
Copyright (C) 2004 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <decryptionresult.h>
|
|
||||||
#include "result_p.h"
|
|
||||||
#include "util.h"
|
|
||||||
|
|
||||||
#include <gpgme.h>
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iterator>
|
|
||||||
#include <cstring>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <istream>
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
class GpgME::DecryptionResult::Private
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit Private(const _gpgme_op_decrypt_result &r) : res(r)
|
|
||||||
{
|
|
||||||
if (res.unsupported_algorithm) {
|
|
||||||
res.unsupported_algorithm = strdup(res.unsupported_algorithm);
|
|
||||||
}
|
|
||||||
if (res.file_name) {
|
|
||||||
res.file_name = strdup(res.file_name);
|
|
||||||
}
|
|
||||||
if (res.symkey_algo) {
|
|
||||||
res.symkey_algo = strdup(res.symkey_algo);
|
|
||||||
}
|
|
||||||
//FIXME: copying gpgme_recipient_t objects invalidates the keyid member,
|
|
||||||
//thus we use _keyid for now (internal API)
|
|
||||||
for (gpgme_recipient_t r = res.recipients ; r ; r = r->next) {
|
|
||||||
recipients.push_back(*r);
|
|
||||||
}
|
|
||||||
res.recipients = nullptr;
|
|
||||||
}
|
|
||||||
~Private()
|
|
||||||
{
|
|
||||||
if (res.unsupported_algorithm) {
|
|
||||||
std::free(res.unsupported_algorithm);
|
|
||||||
}
|
|
||||||
res.unsupported_algorithm = nullptr;
|
|
||||||
if (res.file_name) {
|
|
||||||
std::free(res.file_name);
|
|
||||||
}
|
|
||||||
res.file_name = nullptr;
|
|
||||||
if (res.symkey_algo) {
|
|
||||||
std::free(res.symkey_algo);
|
|
||||||
}
|
|
||||||
res.symkey_algo = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
_gpgme_op_decrypt_result res;
|
|
||||||
std::vector<_gpgme_recipient> recipients;
|
|
||||||
};
|
|
||||||
|
|
||||||
GpgME::DecryptionResult::DecryptionResult(gpgme_ctx_t ctx, int error)
|
|
||||||
: GpgME::Result(error), d()
|
|
||||||
{
|
|
||||||
init(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgME::DecryptionResult::DecryptionResult(gpgme_ctx_t ctx, const Error &error)
|
|
||||||
: GpgME::Result(error), d()
|
|
||||||
{
|
|
||||||
init(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GpgME::DecryptionResult::init(gpgme_ctx_t ctx)
|
|
||||||
{
|
|
||||||
if (!ctx) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
gpgme_decrypt_result_t res = gpgme_op_decrypt_result(ctx);
|
|
||||||
if (!res) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
d.reset(new Private(*res));
|
|
||||||
}
|
|
||||||
|
|
||||||
make_standard_stuff(DecryptionResult)
|
|
||||||
|
|
||||||
const char *GpgME::DecryptionResult::unsupportedAlgorithm() const
|
|
||||||
{
|
|
||||||
return d ? d->res.unsupported_algorithm : nullptr ;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GpgME::DecryptionResult::isWrongKeyUsage() const
|
|
||||||
{
|
|
||||||
return d && d->res.wrong_key_usage;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GpgME::DecryptionResult::isDeVs() const
|
|
||||||
{
|
|
||||||
return d && d->res.is_de_vs;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GpgME::DecryptionResult::isMime() const
|
|
||||||
{
|
|
||||||
return d && d->res.is_mime;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *GpgME::DecryptionResult::fileName() const
|
|
||||||
{
|
|
||||||
return d ? d->res.file_name : nullptr ;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int GpgME::DecryptionResult::numRecipients() const
|
|
||||||
{
|
|
||||||
return d ? d->recipients.size() : 0 ;
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgME::DecryptionResult::Recipient GpgME::DecryptionResult::recipient(unsigned int idx) const
|
|
||||||
{
|
|
||||||
if (d && idx < d->recipients.size()) {
|
|
||||||
return Recipient(&d->recipients[idx]);
|
|
||||||
}
|
|
||||||
return Recipient();
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
struct make_recipient {
|
|
||||||
GpgME::DecryptionResult::Recipient operator()(_gpgme_recipient &t)
|
|
||||||
{
|
|
||||||
return GpgME::DecryptionResult::Recipient(&t);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<GpgME::DecryptionResult::Recipient> GpgME::DecryptionResult::recipients() const
|
|
||||||
{
|
|
||||||
std::vector<Recipient> result;
|
|
||||||
if (d) {
|
|
||||||
result.reserve(d->recipients.size());
|
|
||||||
std::transform(d->recipients.begin(), d->recipients.end(),
|
|
||||||
std::back_inserter(result),
|
|
||||||
make_recipient());
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *GpgME::DecryptionResult::sessionKey() const
|
|
||||||
{
|
|
||||||
return d ? d->res.session_key : nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *GpgME::DecryptionResult::symkeyAlgo() const
|
|
||||||
{
|
|
||||||
return d ? d->res.symkey_algo : nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GpgME::DecryptionResult::isLegacyCipherNoMDC() const
|
|
||||||
{
|
|
||||||
return d && d->res.legacy_cipher_nomdc;
|
|
||||||
}
|
|
||||||
|
|
||||||
class GpgME::DecryptionResult::Recipient::Private : public _gpgme_recipient
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Private(gpgme_recipient_t reci) : _gpgme_recipient(*reci) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
GpgME::DecryptionResult::Recipient::Recipient()
|
|
||||||
: d()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgME::DecryptionResult::Recipient::Recipient(gpgme_recipient_t r)
|
|
||||||
: d()
|
|
||||||
{
|
|
||||||
if (r) {
|
|
||||||
d.reset(new Private(r));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GpgME::DecryptionResult::Recipient::isNull() const
|
|
||||||
{
|
|
||||||
return !d;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *GpgME::DecryptionResult::Recipient::keyID() const
|
|
||||||
{
|
|
||||||
//_keyid is internal API, but the public keyid is invalid after copying (see above)
|
|
||||||
if (d) {
|
|
||||||
return d->_keyid;
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *GpgME::DecryptionResult::Recipient::shortKeyID() const
|
|
||||||
{
|
|
||||||
//_keyid is internal API, but the public keyid is invalid after copying (see above)
|
|
||||||
if (d) {
|
|
||||||
return d->_keyid + 8;
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int GpgME::DecryptionResult::Recipient::publicKeyAlgorithm() const
|
|
||||||
{
|
|
||||||
if (d) {
|
|
||||||
return d->pubkey_algo;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *GpgME::DecryptionResult::Recipient::publicKeyAlgorithmAsString() const
|
|
||||||
{
|
|
||||||
if (d) {
|
|
||||||
return gpgme_pubkey_algo_name(d->pubkey_algo);
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgME::Error GpgME::DecryptionResult::Recipient::status() const
|
|
||||||
{
|
|
||||||
if (d) {
|
|
||||||
return Error(d->status);
|
|
||||||
}
|
|
||||||
return Error();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostream &GpgME::operator<<(std::ostream &os, const DecryptionResult &result)
|
|
||||||
{
|
|
||||||
os << "GpgME::DecryptionResult(";
|
|
||||||
if (!result.isNull()) {
|
|
||||||
os << "\n error: " << result.error()
|
|
||||||
<< "\n fileName: " << protect(result.fileName())
|
|
||||||
<< "\n unsupportedAlgorithm: " << protect(result.unsupportedAlgorithm())
|
|
||||||
<< "\n isWrongKeyUsage: " << result.isWrongKeyUsage()
|
|
||||||
<< "\n isDeVs " << result.isDeVs()
|
|
||||||
<< "\n legacyCipherNoMDC " << result.isLegacyCipherNoMDC()
|
|
||||||
<< "\n symkeyAlgo: " << protect(result.symkeyAlgo())
|
|
||||||
<< "\n recipients:\n";
|
|
||||||
const std::vector<DecryptionResult::Recipient> recipients = result.recipients();
|
|
||||||
std::copy(recipients.begin(), recipients.end(),
|
|
||||||
std::ostream_iterator<DecryptionResult::Recipient>(os, "\n"));
|
|
||||||
}
|
|
||||||
return os << ')';
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostream &GpgME::operator<<(std::ostream &os, const DecryptionResult::Recipient &reci)
|
|
||||||
{
|
|
||||||
os << "GpgME::DecryptionResult::Recipient(";
|
|
||||||
if (!reci.isNull()) {
|
|
||||||
os << "\n keyID: " << protect(reci.keyID())
|
|
||||||
<< "\n shortKeyID: " << protect(reci.shortKeyID())
|
|
||||||
<< "\n publicKeyAlgorithm: " << protect(reci.publicKeyAlgorithmAsString())
|
|
||||||
<< "\n status: " << reci.status();
|
|
||||||
}
|
|
||||||
return os << ')';
|
|
||||||
}
|
|
@ -1,142 +0,0 @@
|
|||||||
/*
|
|
||||||
decryptionresult.h - wraps a gpgme keygen result
|
|
||||||
Copyright (C) 2004 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GPGMEPP_DECRYPTIONRESULT_H__
|
|
||||||
#define __GPGMEPP_DECRYPTIONRESULT_H__
|
|
||||||
|
|
||||||
#include "gpgmefw.h"
|
|
||||||
#include "result.h"
|
|
||||||
#include "gpgmepp_export.h"
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iosfwd>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace GpgME
|
|
||||||
{
|
|
||||||
|
|
||||||
class Error;
|
|
||||||
|
|
||||||
class GPGMEPP_EXPORT DecryptionResult : public Result
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DecryptionResult();
|
|
||||||
DecryptionResult(gpgme_ctx_t ctx, int error);
|
|
||||||
DecryptionResult(gpgme_ctx_t ctx, const Error &err);
|
|
||||||
explicit DecryptionResult(const Error &err);
|
|
||||||
|
|
||||||
DecryptionResult(const DecryptionResult &other) = default;
|
|
||||||
const DecryptionResult &operator=(DecryptionResult other)
|
|
||||||
{
|
|
||||||
swap(other);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void swap(DecryptionResult &other)
|
|
||||||
{
|
|
||||||
Result::swap(other);
|
|
||||||
using std::swap;
|
|
||||||
swap(this->d, other.d);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isNull() const;
|
|
||||||
|
|
||||||
GPGMEPP_DEPRECATED const char *unsupportedAlgortihm() const
|
|
||||||
{
|
|
||||||
return unsupportedAlgorithm();
|
|
||||||
}
|
|
||||||
const char *unsupportedAlgorithm() const;
|
|
||||||
|
|
||||||
GPGMEPP_DEPRECATED bool wrongKeyUsage() const
|
|
||||||
{
|
|
||||||
return isWrongKeyUsage();
|
|
||||||
}
|
|
||||||
bool isWrongKeyUsage() const;
|
|
||||||
bool isDeVs() const;
|
|
||||||
bool isMime() const;
|
|
||||||
|
|
||||||
const char *fileName() const;
|
|
||||||
|
|
||||||
const char *sessionKey() const;
|
|
||||||
|
|
||||||
const char *symkeyAlgo() const;
|
|
||||||
|
|
||||||
class Recipient;
|
|
||||||
|
|
||||||
unsigned int numRecipients() const;
|
|
||||||
Recipient recipient(unsigned int idx) const;
|
|
||||||
std::vector<Recipient> recipients() const;
|
|
||||||
|
|
||||||
bool isLegacyCipherNoMDC() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
class Private;
|
|
||||||
void init(gpgme_ctx_t ctx);
|
|
||||||
std::shared_ptr<Private> d;
|
|
||||||
};
|
|
||||||
|
|
||||||
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const DecryptionResult &result);
|
|
||||||
|
|
||||||
class GPGMEPP_EXPORT DecryptionResult::Recipient
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Recipient();
|
|
||||||
explicit Recipient(gpgme_recipient_t reci);
|
|
||||||
|
|
||||||
Recipient(const Recipient &other) = default;
|
|
||||||
const Recipient &operator=(Recipient other)
|
|
||||||
{
|
|
||||||
swap(other);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void swap(Recipient &other)
|
|
||||||
{
|
|
||||||
using std::swap;
|
|
||||||
swap(this->d, other.d);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isNull() const;
|
|
||||||
|
|
||||||
const char *keyID() const;
|
|
||||||
const char *shortKeyID() const;
|
|
||||||
|
|
||||||
unsigned int publicKeyAlgorithm() const;
|
|
||||||
const char *publicKeyAlgorithmAsString() const;
|
|
||||||
|
|
||||||
Error status() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
class Private;
|
|
||||||
std::shared_ptr<Private> d;
|
|
||||||
};
|
|
||||||
|
|
||||||
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const DecryptionResult::Recipient &reci);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(DecryptionResult)
|
|
||||||
|
|
||||||
#endif // __GPGMEPP_DECRYPTIONRESULT_H__
|
|
@ -1,82 +0,0 @@
|
|||||||
/*
|
|
||||||
defaultassuantransaction.cpp - default Assuan Transaction that just stores data and status lines
|
|
||||||
Copyright (C) 2009 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "defaultassuantransaction.h"
|
|
||||||
#include "error.h"
|
|
||||||
#include "data.h"
|
|
||||||
|
|
||||||
using namespace GpgME;
|
|
||||||
|
|
||||||
DefaultAssuanTransaction::DefaultAssuanTransaction()
|
|
||||||
: AssuanTransaction(),
|
|
||||||
m_status(),
|
|
||||||
m_data()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
DefaultAssuanTransaction::~DefaultAssuanTransaction() {}
|
|
||||||
|
|
||||||
Error DefaultAssuanTransaction::data(const char *data, size_t len)
|
|
||||||
{
|
|
||||||
m_data.append(data, len);
|
|
||||||
return Error();
|
|
||||||
}
|
|
||||||
|
|
||||||
Data DefaultAssuanTransaction::inquire(const char *name, const char *args, Error &err)
|
|
||||||
{
|
|
||||||
(void)name; (void)args; (void)err;
|
|
||||||
return Data::null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Error DefaultAssuanTransaction::status(const char *status, const char *args)
|
|
||||||
{
|
|
||||||
m_status.push_back(std::pair<std::string, std::string>(status, args));
|
|
||||||
return Error();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<std::string> DefaultAssuanTransaction::statusLine(const char *tag) const
|
|
||||||
{
|
|
||||||
std::vector<std::string> result;
|
|
||||||
for (std::vector< std::pair<std::string, std::string> >::const_iterator it = m_status.begin(), end = m_status.end() ; it != end ; ++it) {
|
|
||||||
if (it->first == tag) {
|
|
||||||
result.push_back(it->second);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string DefaultAssuanTransaction::firstStatusLine(const char *tag) const
|
|
||||||
{
|
|
||||||
for (std::vector< std::pair<std::string, std::string> >::const_iterator it = m_status.begin(), end = m_status.end() ; it != end ; ++it) {
|
|
||||||
if (it->first == tag) {
|
|
||||||
return it->second;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return std::string();
|
|
||||||
}
|
|
@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
defaultassuantransaction.h - default Assuan Transaction that just stores data and status lines
|
|
||||||
Copyright (C) 2009 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GPGMEPP_DEFAULTASSUANTRANSACTION_H__
|
|
||||||
#define __GPGMEPP_DEFAULTASSUANTRANSACTION_H__
|
|
||||||
|
|
||||||
#include "interfaces/assuantransaction.h"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
namespace GpgME
|
|
||||||
{
|
|
||||||
|
|
||||||
class GPGMEPP_EXPORT DefaultAssuanTransaction : public AssuanTransaction
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit DefaultAssuanTransaction();
|
|
||||||
~DefaultAssuanTransaction();
|
|
||||||
|
|
||||||
const std::vector< std::pair<std::string, std::string> > &statusLines() const
|
|
||||||
{
|
|
||||||
return m_status;
|
|
||||||
}
|
|
||||||
std::vector<std::string> statusLine(const char *tag) const;
|
|
||||||
std::string firstStatusLine(const char *tag) const;
|
|
||||||
|
|
||||||
const std::string &data() const
|
|
||||||
{
|
|
||||||
return m_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Error data(const char *data, size_t datalen) override;
|
|
||||||
Data inquire(const char *name, const char *args, Error &err) override;
|
|
||||||
Error status(const char *status, const char *args) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::vector< std::pair<std::string, std::string> > m_status;
|
|
||||||
std::string m_data;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace GpgME
|
|
||||||
|
|
||||||
#endif // __GPGMEPP_DEFAULTASSUANTRANSACTION_H__
|
|
@ -1,422 +0,0 @@
|
|||||||
/*
|
|
||||||
editinteractor.cpp - Interface for edit interactors
|
|
||||||
Copyright (C) 2007 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "editinteractor.h"
|
|
||||||
#include "callbacks.h"
|
|
||||||
#include "error.h"
|
|
||||||
#include "util.h"
|
|
||||||
|
|
||||||
#include <gpgme.h>
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
# include <io.h>
|
|
||||||
#include <windows.h>
|
|
||||||
#else
|
|
||||||
# include <unistd.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <cerrno>
|
|
||||||
#include <cstring>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
#ifndef GPG_ERR_ALREADY_SIGNED
|
|
||||||
# define GPG_ERR_ALREADY_SIGNED GPG_ERR_USER_1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace GpgME;
|
|
||||||
|
|
||||||
static const char *status_to_string(unsigned int status);
|
|
||||||
static Error status_to_error(unsigned int status);
|
|
||||||
static Error parse_sc_op_failure(const char *args);
|
|
||||||
|
|
||||||
class EditInteractor::Private
|
|
||||||
{
|
|
||||||
friend class ::GpgME::EditInteractor;
|
|
||||||
friend class ::GpgME::CallbackHelper;
|
|
||||||
EditInteractor *const q;
|
|
||||||
public:
|
|
||||||
explicit Private(EditInteractor *qq);
|
|
||||||
~Private();
|
|
||||||
|
|
||||||
private:
|
|
||||||
unsigned int state = StartState;
|
|
||||||
Error error;
|
|
||||||
std::FILE *debug = nullptr;
|
|
||||||
bool debugNeedsClosing = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
class GpgME::CallbackHelper
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
static int writeAll(int fd, const void *buf, size_t count)
|
|
||||||
{
|
|
||||||
size_t toWrite = count;
|
|
||||||
while (toWrite > 0) {
|
|
||||||
const int n = gpgme_io_write(fd, buf, toWrite);
|
|
||||||
if (n < 0) {
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
toWrite -= n;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
static int edit_interactor_callback_impl(void *opaque, gpgme_status_code_t status, const char *args, int fd)
|
|
||||||
{
|
|
||||||
EditInteractor::Private *ei = (EditInteractor::Private *)opaque;
|
|
||||||
|
|
||||||
Error err = status_to_error(status);
|
|
||||||
|
|
||||||
if (!err) {
|
|
||||||
|
|
||||||
// advance to next state based on input:
|
|
||||||
const unsigned int oldState = ei->state;
|
|
||||||
|
|
||||||
if (ei->q->needsNoResponse(status)) {
|
|
||||||
// keep state
|
|
||||||
} else if (status == GPGME_STATUS_ERROR) {
|
|
||||||
err = ei->q->parseStatusError(args);
|
|
||||||
ei->state = EditInteractor::ErrorState;
|
|
||||||
} else if (status == GPGME_STATUS_SC_OP_FAILURE) {
|
|
||||||
err = parse_sc_op_failure(args);
|
|
||||||
ei->state = EditInteractor::ErrorState;
|
|
||||||
} else {
|
|
||||||
ei->state = ei->q->nextState(status, args, err);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ei->debug) {
|
|
||||||
std::fprintf(ei->debug, "EditInteractor: %u -> nextState( %s, %s ) -> %u\n",
|
|
||||||
oldState, status_to_string(status), args ? args : "<null>", ei->state);
|
|
||||||
}
|
|
||||||
if (err || err.isCanceled()) {
|
|
||||||
ei->state = oldState;
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ei->state != oldState &&
|
|
||||||
// if there was an error from before, we stop here (### this looks weird, can this happen at all?)
|
|
||||||
ei->error.code() == GPG_ERR_NO_ERROR) {
|
|
||||||
|
|
||||||
// successful state change -> call action
|
|
||||||
if (const char *const result = ei->q->action(err)) {
|
|
||||||
if (err) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
if (ei->debug) {
|
|
||||||
std::fprintf(ei->debug, "EditInteractor: action result \"%s\"\n", result);
|
|
||||||
}
|
|
||||||
// if there's a result, write it:
|
|
||||||
if (*result) {
|
|
||||||
gpgme_err_set_errno(0);
|
|
||||||
const ssize_t len = std::strlen(result);
|
|
||||||
if (writeAll(fd, result, len) != len) {
|
|
||||||
err = Error::fromSystemError();
|
|
||||||
if (ei->debug) {
|
|
||||||
std::fprintf(ei->debug, "EditInteractor: Could not write to fd %d (%s)\n", fd, err.asStdString().c_str());
|
|
||||||
}
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
gpgme_err_set_errno(0);
|
|
||||||
if (writeAll(fd, "\n", 1) != 1) {
|
|
||||||
err = Error::fromSystemError();
|
|
||||||
if (ei->debug) {
|
|
||||||
std::fprintf(ei->debug, "EditInteractor: Could not write to fd %d (%s)\n", fd, err.asStdString().c_str());
|
|
||||||
}
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (err) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
if (ei->debug) {
|
|
||||||
std::fprintf(ei->debug, "EditInteractor: no action result\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (ei->debug) {
|
|
||||||
std::fprintf(ei->debug, "EditInteractor: no action executed\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
error:
|
|
||||||
if (err || err.isCanceled()) {
|
|
||||||
ei->error = err;
|
|
||||||
ei->state = EditInteractor::ErrorState;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ei->debug) {
|
|
||||||
std::fprintf(ei->debug, "EditInteractor: error now %u (%s)\n",
|
|
||||||
ei->error.encodedError(), gpgme_strerror(ei->error.encodedError()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return ei->error.encodedError();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static gpgme_error_t edit_interactor_callback(void *opaque, gpgme_status_code_t status, const char *args, int fd)
|
|
||||||
{
|
|
||||||
return CallbackHelper::edit_interactor_callback_impl(opaque, status, args, fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
const gpgme_edit_cb_t GpgME::edit_interactor_callback = ::edit_interactor_callback;
|
|
||||||
|
|
||||||
EditInteractor::Private::Private(EditInteractor *qq)
|
|
||||||
: q(qq)
|
|
||||||
{
|
|
||||||
const char *debug_env = std::getenv("GPGMEPP_INTERACTOR_DEBUG");
|
|
||||||
if (!debug_env) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!strcmp(debug_env, "stdout")) {
|
|
||||||
debug = stdout;
|
|
||||||
} else if (!strcmp(debug_env, "stderr")) {
|
|
||||||
debug = stderr;
|
|
||||||
} else if (debug_env) {
|
|
||||||
debug = std::fopen(debug_env, "a+");
|
|
||||||
debugNeedsClosing = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EditInteractor::Private::~Private()
|
|
||||||
{
|
|
||||||
if (debug && debugNeedsClosing) {
|
|
||||||
std::fclose(debug);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EditInteractor::EditInteractor()
|
|
||||||
: d(new Private(this))
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
EditInteractor::~EditInteractor()
|
|
||||||
{
|
|
||||||
delete d;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int EditInteractor::state() const
|
|
||||||
{
|
|
||||||
return d->state;
|
|
||||||
}
|
|
||||||
|
|
||||||
Error EditInteractor::lastError() const
|
|
||||||
{
|
|
||||||
return d->error;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool EditInteractor::needsNoResponse(unsigned int status) const
|
|
||||||
{
|
|
||||||
switch (status) {
|
|
||||||
case GPGME_STATUS_ALREADY_SIGNED:
|
|
||||||
case GPGME_STATUS_ERROR:
|
|
||||||
case GPGME_STATUS_GET_BOOL:
|
|
||||||
case GPGME_STATUS_GET_LINE:
|
|
||||||
case GPGME_STATUS_KEY_CREATED:
|
|
||||||
case GPGME_STATUS_NEED_PASSPHRASE_SYM:
|
|
||||||
case GPGME_STATUS_SC_OP_FAILURE:
|
|
||||||
case GPGME_STATUS_CARDCTRL:
|
|
||||||
case GPGME_STATUS_BACKUP_KEY_CREATED:
|
|
||||||
return false;
|
|
||||||
default:
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// static
|
|
||||||
Error status_to_error(unsigned int status)
|
|
||||||
{
|
|
||||||
switch (status) {
|
|
||||||
case GPGME_STATUS_MISSING_PASSPHRASE:
|
|
||||||
return Error::fromCode(GPG_ERR_NO_PASSPHRASE);
|
|
||||||
case GPGME_STATUS_ALREADY_SIGNED:
|
|
||||||
return Error::fromCode(GPG_ERR_ALREADY_SIGNED);
|
|
||||||
case GPGME_STATUS_SIGEXPIRED:
|
|
||||||
return Error::fromCode(GPG_ERR_SIG_EXPIRED);
|
|
||||||
}
|
|
||||||
return Error();
|
|
||||||
}
|
|
||||||
|
|
||||||
void EditInteractor::setDebugChannel(std::FILE *debug)
|
|
||||||
{
|
|
||||||
d->debug = debug;
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgME::Error EditInteractor::parseStatusError(const char *args)
|
|
||||||
{
|
|
||||||
Error err;
|
|
||||||
|
|
||||||
const auto fields = split(args, ' ');
|
|
||||||
if (fields.size() >= 2) {
|
|
||||||
err = Error{static_cast<unsigned int>(std::stoul(fields[1]))};
|
|
||||||
} else {
|
|
||||||
err = Error::fromCode(GPG_ERR_GENERAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Error sc_op_failure_to_error(unsigned int status)
|
|
||||||
{
|
|
||||||
switch (status) {
|
|
||||||
case 1:
|
|
||||||
// GPG_ERR_CANCELED or GPG_ERR_FULLY_CANCELED
|
|
||||||
return Error::fromCode(GPG_ERR_CANCELED);
|
|
||||||
case 2:
|
|
||||||
// GPG_ERR_BAD_PIN or GPG_ERR_BAD_RESET_CODE [sic]
|
|
||||||
return Error::fromCode(GPG_ERR_BAD_PIN);
|
|
||||||
case 3:
|
|
||||||
return Error::fromCode(GPG_ERR_PIN_BLOCKED);
|
|
||||||
case 4:
|
|
||||||
return Error::fromCode(GPG_ERR_NO_RESET_CODE);
|
|
||||||
}
|
|
||||||
return Error::fromCode(GPG_ERR_CARD);
|
|
||||||
}
|
|
||||||
|
|
||||||
// static
|
|
||||||
Error parse_sc_op_failure(const char *args)
|
|
||||||
{
|
|
||||||
Error err;
|
|
||||||
|
|
||||||
const auto fields = split(args, ' ');
|
|
||||||
if (fields.size() >= 1) {
|
|
||||||
err = sc_op_failure_to_error(static_cast<unsigned int>(std::stoul(fields[0])));
|
|
||||||
} else {
|
|
||||||
err = Error::fromCode(GPG_ERR_CARD);
|
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *const status_strings[] = {
|
|
||||||
"EOF",
|
|
||||||
/* mkstatus processing starts here */
|
|
||||||
"ENTER",
|
|
||||||
"LEAVE",
|
|
||||||
"ABORT",
|
|
||||||
|
|
||||||
"GOODSIG",
|
|
||||||
"BADSIG",
|
|
||||||
"ERRSIG",
|
|
||||||
|
|
||||||
"BADARMOR",
|
|
||||||
|
|
||||||
"RSA_OR_IDEA",
|
|
||||||
"KEYEXPIRED",
|
|
||||||
"KEYREVOKED",
|
|
||||||
|
|
||||||
"TRUST_UNDEFINED",
|
|
||||||
"TRUST_NEVER",
|
|
||||||
"TRUST_MARGINAL",
|
|
||||||
"TRUST_FULLY",
|
|
||||||
"TRUST_ULTIMATE",
|
|
||||||
|
|
||||||
"SHM_INFO",
|
|
||||||
"SHM_GET",
|
|
||||||
"SHM_GET_BOOL",
|
|
||||||
"SHM_GET_HIDDEN",
|
|
||||||
|
|
||||||
"NEED_PASSPHRASE",
|
|
||||||
"VALIDSIG",
|
|
||||||
"SIG_ID",
|
|
||||||
"ENC_TO",
|
|
||||||
"NODATA",
|
|
||||||
"BAD_PASSPHRASE",
|
|
||||||
"NO_PUBKEY",
|
|
||||||
"NO_SECKEY",
|
|
||||||
"NEED_PASSPHRASE_SYM",
|
|
||||||
"DECRYPTION_FAILED",
|
|
||||||
"DECRYPTION_OKAY",
|
|
||||||
"MISSING_PASSPHRASE",
|
|
||||||
"GOOD_PASSPHRASE",
|
|
||||||
"GOODMDC",
|
|
||||||
"BADMDC",
|
|
||||||
"ERRMDC",
|
|
||||||
"IMPORTED",
|
|
||||||
"IMPORT_OK",
|
|
||||||
"IMPORT_PROBLEM",
|
|
||||||
"IMPORT_RES",
|
|
||||||
"FILE_START",
|
|
||||||
"FILE_DONE",
|
|
||||||
"FILE_ERROR",
|
|
||||||
|
|
||||||
"BEGIN_DECRYPTION",
|
|
||||||
"END_DECRYPTION",
|
|
||||||
"BEGIN_ENCRYPTION",
|
|
||||||
"END_ENCRYPTION",
|
|
||||||
|
|
||||||
"DELETE_PROBLEM",
|
|
||||||
"GET_BOOL",
|
|
||||||
"GET_LINE",
|
|
||||||
"GET_HIDDEN",
|
|
||||||
"GOT_IT",
|
|
||||||
"PROGRESS",
|
|
||||||
"SIG_CREATED",
|
|
||||||
"SESSION_KEY",
|
|
||||||
"NOTATION_NAME",
|
|
||||||
"NOTATION_DATA",
|
|
||||||
"POLICY_URL",
|
|
||||||
"BEGIN_STREAM",
|
|
||||||
"END_STREAM",
|
|
||||||
"KEY_CREATED",
|
|
||||||
"USERID_HINT",
|
|
||||||
"UNEXPECTED",
|
|
||||||
"INV_RECP",
|
|
||||||
"NO_RECP",
|
|
||||||
"ALREADY_SIGNED",
|
|
||||||
"SIGEXPIRED",
|
|
||||||
"EXPSIG",
|
|
||||||
"EXPKEYSIG",
|
|
||||||
"TRUNCATED",
|
|
||||||
"ERROR",
|
|
||||||
"NEWSIG",
|
|
||||||
"REVKEYSIG",
|
|
||||||
"SIG_SUBPACKET",
|
|
||||||
"NEED_PASSPHRASE_PIN",
|
|
||||||
"SC_OP_FAILURE",
|
|
||||||
"SC_OP_SUCCESS",
|
|
||||||
"CARDCTRL",
|
|
||||||
"BACKUP_KEY_CREATED",
|
|
||||||
"PKA_TRUST_BAD",
|
|
||||||
"PKA_TRUST_GOOD",
|
|
||||||
|
|
||||||
"PLAINTEXT",
|
|
||||||
};
|
|
||||||
static const unsigned int num_status_strings = sizeof status_strings / sizeof * status_strings ;
|
|
||||||
|
|
||||||
const char *status_to_string(unsigned int idx)
|
|
||||||
{
|
|
||||||
if (idx < num_status_strings) {
|
|
||||||
return status_strings[idx];
|
|
||||||
} else {
|
|
||||||
return "(unknown)";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,73 +0,0 @@
|
|||||||
/*
|
|
||||||
editinteractor.h - Interface for edit interactors
|
|
||||||
Copyright (C) 2007 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GPGMEPP_EDITINTERACTOR_H__
|
|
||||||
#define __GPGMEPP_EDITINTERACTOR_H__
|
|
||||||
|
|
||||||
#include "gpgmepp_export.h"
|
|
||||||
|
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
namespace GpgME
|
|
||||||
{
|
|
||||||
|
|
||||||
class Error;
|
|
||||||
class Context;
|
|
||||||
class CallbackHelper;
|
|
||||||
|
|
||||||
class GPGMEPP_EXPORT EditInteractor
|
|
||||||
{
|
|
||||||
friend class ::GpgME::Context;
|
|
||||||
friend class ::GpgME::CallbackHelper;
|
|
||||||
EditInteractor(const EditInteractor &);
|
|
||||||
EditInteractor &operator=(const EditInteractor &);
|
|
||||||
public:
|
|
||||||
EditInteractor();
|
|
||||||
virtual ~EditInteractor();
|
|
||||||
|
|
||||||
enum {
|
|
||||||
StartState = 0,
|
|
||||||
ErrorState = 0xFFFFFFFF
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual const char *action(Error &err) const = 0;
|
|
||||||
virtual unsigned int nextState(unsigned int statusCode, const char *args, Error &err) const = 0;
|
|
||||||
|
|
||||||
unsigned int state() const;
|
|
||||||
Error lastError() const;
|
|
||||||
bool needsNoResponse(unsigned int statusCode) const;
|
|
||||||
|
|
||||||
void setDebugChannel(std::FILE *file);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
Error parseStatusError(const char *args);
|
|
||||||
|
|
||||||
private:
|
|
||||||
class Private;
|
|
||||||
Private *const d;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace GpgME
|
|
||||||
|
|
||||||
#endif // __GPGMEPP_EDITINTERACTOR_H__
|
|
@ -1,165 +0,0 @@
|
|||||||
/*
|
|
||||||
encryptionresult.cpp - wraps a gpgme verify result
|
|
||||||
Copyright (C) 2004 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <encryptionresult.h>
|
|
||||||
#include "result_p.h"
|
|
||||||
#include "util.h"
|
|
||||||
|
|
||||||
#include <gpgme.h>
|
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <istream>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <iterator>
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
class GpgME::EncryptionResult::Private
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit Private(const gpgme_encrypt_result_t r)
|
|
||||||
{
|
|
||||||
if (!r) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (gpgme_invalid_key_t ik = r->invalid_recipients ; ik ; ik = ik->next) {
|
|
||||||
gpgme_invalid_key_t copy = new _gpgme_invalid_key(*ik);
|
|
||||||
if (ik->fpr) {
|
|
||||||
copy->fpr = strdup(ik->fpr);
|
|
||||||
}
|
|
||||||
copy->next = nullptr;
|
|
||||||
invalid.push_back(copy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
~Private()
|
|
||||||
{
|
|
||||||
for (std::vector<gpgme_invalid_key_t>::iterator it = invalid.begin() ; it != invalid.end() ; ++it) {
|
|
||||||
std::free((*it)->fpr);
|
|
||||||
delete *it; *it = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<gpgme_invalid_key_t> invalid;
|
|
||||||
};
|
|
||||||
|
|
||||||
GpgME::EncryptionResult::EncryptionResult(gpgme_ctx_t ctx, int error)
|
|
||||||
: GpgME::Result(error), d()
|
|
||||||
{
|
|
||||||
init(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgME::EncryptionResult::EncryptionResult(gpgme_ctx_t ctx, const Error &error)
|
|
||||||
: GpgME::Result(error), d()
|
|
||||||
{
|
|
||||||
init(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GpgME::EncryptionResult::init(gpgme_ctx_t ctx)
|
|
||||||
{
|
|
||||||
if (!ctx) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
gpgme_encrypt_result_t res = gpgme_op_encrypt_result(ctx);
|
|
||||||
if (!res) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
d.reset(new Private(res));
|
|
||||||
}
|
|
||||||
|
|
||||||
make_standard_stuff(EncryptionResult)
|
|
||||||
|
|
||||||
unsigned int GpgME::EncryptionResult::numInvalidRecipients() const
|
|
||||||
{
|
|
||||||
return d ? d->invalid.size() : 0 ;
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgME::InvalidRecipient GpgME::EncryptionResult::invalidEncryptionKey(unsigned int idx) const
|
|
||||||
{
|
|
||||||
return InvalidRecipient(d, idx);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<GpgME::InvalidRecipient> GpgME::EncryptionResult::invalidEncryptionKeys() const
|
|
||||||
{
|
|
||||||
if (!d) {
|
|
||||||
return std::vector<GpgME::InvalidRecipient>();
|
|
||||||
}
|
|
||||||
std::vector<GpgME::InvalidRecipient> result;
|
|
||||||
result.reserve(d->invalid.size());
|
|
||||||
for (unsigned int i = 0 ; i < d->invalid.size() ; ++i) {
|
|
||||||
result.push_back(InvalidRecipient(d, i));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgME::InvalidRecipient::InvalidRecipient(const std::shared_ptr<EncryptionResult::Private> &parent, unsigned int i)
|
|
||||||
: d(parent), idx(i)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgME::InvalidRecipient::InvalidRecipient() : d(), idx(0) {}
|
|
||||||
|
|
||||||
bool GpgME::InvalidRecipient::isNull() const
|
|
||||||
{
|
|
||||||
return !d || idx >= d->invalid.size() ;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *GpgME::InvalidRecipient::fingerprint() const
|
|
||||||
{
|
|
||||||
return isNull() ? nullptr : d->invalid[idx]->fpr ;
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgME::Error GpgME::InvalidRecipient::reason() const
|
|
||||||
{
|
|
||||||
return Error(isNull() ? 0 : d->invalid[idx]->reason);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostream &GpgME::operator<<(std::ostream &os, const EncryptionResult &result)
|
|
||||||
{
|
|
||||||
os << "GpgME::EncryptionResult(";
|
|
||||||
if (!result.isNull()) {
|
|
||||||
os << "\n error: " << result.error()
|
|
||||||
<< "\n invalid recipients:\n";
|
|
||||||
const std::vector<InvalidRecipient> ir = result.invalidEncryptionKeys();
|
|
||||||
std::copy(ir.begin(), ir.end(),
|
|
||||||
std::ostream_iterator<InvalidRecipient>(os, "\n"));
|
|
||||||
}
|
|
||||||
return os << ')';
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostream &GpgME::operator<<(std::ostream &os, const InvalidRecipient &ir)
|
|
||||||
{
|
|
||||||
os << "GpgME::InvalidRecipient(";
|
|
||||||
if (!ir.isNull()) {
|
|
||||||
os << "\n fingerprint: " << protect(ir.fingerprint())
|
|
||||||
<< "\n reason: " << ir.reason()
|
|
||||||
<< '\n';
|
|
||||||
}
|
|
||||||
return os << ')';
|
|
||||||
}
|
|
@ -1,117 +0,0 @@
|
|||||||
/*
|
|
||||||
encryptionresult.h - wraps a gpgme sign result
|
|
||||||
Copyright (C) 2004 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GPGMEPP_ENCRYPTIONRESULT_H__
|
|
||||||
#define __GPGMEPP_ENCRYPTIONRESULT_H__
|
|
||||||
|
|
||||||
#include "gpgmefw.h"
|
|
||||||
#include "result.h"
|
|
||||||
#include "gpgmepp_export.h"
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <iosfwd>
|
|
||||||
|
|
||||||
namespace GpgME
|
|
||||||
{
|
|
||||||
|
|
||||||
class Error;
|
|
||||||
class InvalidRecipient;
|
|
||||||
|
|
||||||
class GPGMEPP_EXPORT EncryptionResult : public Result
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
EncryptionResult();
|
|
||||||
EncryptionResult(gpgme_ctx_t ctx, int error);
|
|
||||||
EncryptionResult(gpgme_ctx_t ctx, const Error &error);
|
|
||||||
EncryptionResult(const Error &err);
|
|
||||||
|
|
||||||
EncryptionResult(const EncryptionResult &other) = default;
|
|
||||||
const EncryptionResult &operator=(EncryptionResult other)
|
|
||||||
{
|
|
||||||
swap(other);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void swap(EncryptionResult &other)
|
|
||||||
{
|
|
||||||
Result::swap(other);
|
|
||||||
using std::swap;
|
|
||||||
swap(this->d, other.d);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isNull() const;
|
|
||||||
|
|
||||||
unsigned int numInvalidRecipients() const;
|
|
||||||
|
|
||||||
InvalidRecipient invalidEncryptionKey(unsigned int index) const;
|
|
||||||
std::vector<InvalidRecipient> invalidEncryptionKeys() const;
|
|
||||||
|
|
||||||
class Private;
|
|
||||||
private:
|
|
||||||
void init(gpgme_ctx_t ctx);
|
|
||||||
std::shared_ptr<Private> d;
|
|
||||||
};
|
|
||||||
|
|
||||||
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const EncryptionResult &result);
|
|
||||||
|
|
||||||
class GPGMEPP_EXPORT InvalidRecipient
|
|
||||||
{
|
|
||||||
friend class ::GpgME::EncryptionResult;
|
|
||||||
InvalidRecipient(const std::shared_ptr<EncryptionResult::Private> &parent, unsigned int index);
|
|
||||||
public:
|
|
||||||
InvalidRecipient();
|
|
||||||
|
|
||||||
InvalidRecipient(const InvalidRecipient &other) = default;
|
|
||||||
const InvalidRecipient &operator=(InvalidRecipient other)
|
|
||||||
{
|
|
||||||
swap(other);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void swap(InvalidRecipient &other)
|
|
||||||
{
|
|
||||||
using std::swap;
|
|
||||||
swap(this->d, other.d);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isNull() const;
|
|
||||||
|
|
||||||
const char *fingerprint() const;
|
|
||||||
Error reason() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::shared_ptr<EncryptionResult::Private> d;
|
|
||||||
unsigned int idx;
|
|
||||||
};
|
|
||||||
|
|
||||||
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const InvalidRecipient &recipient);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(EncryptionResult)
|
|
||||||
GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(InvalidRecipient)
|
|
||||||
|
|
||||||
#endif // __GPGMEPP_ENCRYPTIONRESULT_H__
|
|
@ -1,94 +0,0 @@
|
|||||||
/*
|
|
||||||
engineinfo.h
|
|
||||||
Copyright (C) 2004 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "engineinfo.h"
|
|
||||||
|
|
||||||
#include <gpgme.h>
|
|
||||||
|
|
||||||
class GpgME::EngineInfo::Private
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Private(gpgme_engine_info_t engine = nullptr) : info(engine) {}
|
|
||||||
~Private()
|
|
||||||
{
|
|
||||||
info = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
gpgme_engine_info_t info;
|
|
||||||
};
|
|
||||||
|
|
||||||
GpgME::EngineInfo::EngineInfo() : d() {}
|
|
||||||
|
|
||||||
GpgME::EngineInfo::EngineInfo(gpgme_engine_info_t engine)
|
|
||||||
: d(new Private(engine))
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GpgME::EngineInfo::isNull() const
|
|
||||||
{
|
|
||||||
return !d || !d->info;
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgME::Protocol GpgME::EngineInfo::protocol() const
|
|
||||||
{
|
|
||||||
if (isNull()) {
|
|
||||||
return UnknownProtocol;
|
|
||||||
}
|
|
||||||
switch (d->info->protocol) {
|
|
||||||
case GPGME_PROTOCOL_OpenPGP: return OpenPGP;
|
|
||||||
case GPGME_PROTOCOL_CMS: return CMS;
|
|
||||||
default:
|
|
||||||
return UnknownProtocol;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *GpgME::EngineInfo::fileName() const
|
|
||||||
{
|
|
||||||
return isNull() ? nullptr : d->info->file_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *GpgME::EngineInfo::version() const
|
|
||||||
{
|
|
||||||
return isNull() ? nullptr : d->info->version;
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgME::EngineInfo::Version GpgME::EngineInfo::engineVersion() const
|
|
||||||
{
|
|
||||||
return Version(version());
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *GpgME::EngineInfo::requiredVersion() const
|
|
||||||
{
|
|
||||||
return isNull() ? nullptr : d->info->req_version;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *GpgME::EngineInfo::homeDirectory() const
|
|
||||||
{
|
|
||||||
return isNull() ? nullptr : d->info->home_dir;
|
|
||||||
}
|
|
@ -1,255 +0,0 @@
|
|||||||
/*
|
|
||||||
engineinfo.h
|
|
||||||
Copyright (C) 2004 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GPGMEPP_ENGINEINFO_H__
|
|
||||||
#define __GPGMEPP_ENGINEINFO_H__
|
|
||||||
|
|
||||||
#include "global.h"
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <string>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
namespace GpgME
|
|
||||||
{
|
|
||||||
|
|
||||||
class GPGMEPP_EXPORT EngineInfo
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
struct Version
|
|
||||||
{
|
|
||||||
int major, minor, patch;
|
|
||||||
Version()
|
|
||||||
{
|
|
||||||
major = 0;
|
|
||||||
minor = 0;
|
|
||||||
patch = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Version(const std::string& version)
|
|
||||||
{
|
|
||||||
if (version.empty() ||
|
|
||||||
std::sscanf(version.c_str(), "%d.%d.%d", &major, &minor, &patch) != 3) {
|
|
||||||
major = 0;
|
|
||||||
minor = 0;
|
|
||||||
patch = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Version(const char *version)
|
|
||||||
{
|
|
||||||
if (!version ||
|
|
||||||
std::sscanf(version, "%d.%d.%d", &major, &minor, &patch) != 3) {
|
|
||||||
major = 0;
|
|
||||||
minor = 0;
|
|
||||||
patch = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator < (const Version& other) const
|
|
||||||
{
|
|
||||||
if (major > other.major ||
|
|
||||||
(major == other.major && minor > other.minor) ||
|
|
||||||
(major == other.major && minor == other.minor && patch > other.patch) ||
|
|
||||||
(major >= other.major && minor >= other.minor && patch >= other.patch)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator < (const char* other) const
|
|
||||||
{
|
|
||||||
return operator<(Version(other));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator <= (const Version &other) const
|
|
||||||
{
|
|
||||||
return !operator>(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator <= (const char *other) const
|
|
||||||
{
|
|
||||||
return operator<=(Version(other));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator > (const char* other) const
|
|
||||||
{
|
|
||||||
return operator>(Version(other));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator > (const Version & other) const
|
|
||||||
{
|
|
||||||
return !operator<(other) && !operator==(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator >= (const Version &other) const
|
|
||||||
{
|
|
||||||
return !operator<(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator >= (const char *other) const
|
|
||||||
{
|
|
||||||
return operator>=(Version(other));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator == (const Version& other) const
|
|
||||||
{
|
|
||||||
return major == other.major
|
|
||||||
&& minor == other.minor
|
|
||||||
&& patch == other.patch;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator == (const char* other) const
|
|
||||||
{
|
|
||||||
return operator==(Version(other));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator != (const Version &other) const
|
|
||||||
{
|
|
||||||
return !operator==(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator != (const char *other) const
|
|
||||||
{
|
|
||||||
return operator!=(Version(other));
|
|
||||||
}
|
|
||||||
|
|
||||||
// the non-const overloads of the comparison operators are kept for
|
|
||||||
// binary compatibility
|
|
||||||
bool operator < (const Version& other)
|
|
||||||
{
|
|
||||||
if (major > other.major ||
|
|
||||||
(major == other.major && minor > other.minor) ||
|
|
||||||
(major == other.major && minor == other.minor && patch > other.patch) ||
|
|
||||||
(major >= other.major && minor >= other.minor && patch >= other.patch)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator < (const char* other)
|
|
||||||
{
|
|
||||||
return operator<(Version(other));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator <= (const Version &other)
|
|
||||||
{
|
|
||||||
return !operator>(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator <= (const char *other)
|
|
||||||
{
|
|
||||||
return operator<=(Version(other));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator > (const char* other)
|
|
||||||
{
|
|
||||||
return operator>(Version(other));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator > (const Version & other)
|
|
||||||
{
|
|
||||||
return !operator<(other) && !operator==(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator >= (const Version &other)
|
|
||||||
{
|
|
||||||
return !operator<(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator >= (const char *other)
|
|
||||||
{
|
|
||||||
return operator>=(Version(other));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator == (const Version& other)
|
|
||||||
{
|
|
||||||
return major == other.major
|
|
||||||
&& minor == other.minor
|
|
||||||
&& patch == other.patch;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator == (const char* other)
|
|
||||||
{
|
|
||||||
return operator==(Version(other));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator != (const Version &other)
|
|
||||||
{
|
|
||||||
return !operator==(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator != (const char *other)
|
|
||||||
{
|
|
||||||
return operator!=(Version(other));
|
|
||||||
}
|
|
||||||
|
|
||||||
friend std::ostream& operator << (std::ostream& stream, const Version& ver)
|
|
||||||
{
|
|
||||||
stream << ver.major;
|
|
||||||
stream << '.';
|
|
||||||
stream << ver.minor;
|
|
||||||
stream << '.';
|
|
||||||
stream << ver.patch;
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
EngineInfo();
|
|
||||||
explicit EngineInfo(gpgme_engine_info_t engine);
|
|
||||||
|
|
||||||
EngineInfo(const EngineInfo &other) = default;
|
|
||||||
const EngineInfo &operator=(EngineInfo other)
|
|
||||||
{
|
|
||||||
swap(other);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
void swap(EngineInfo &other)
|
|
||||||
{
|
|
||||||
using std::swap;
|
|
||||||
swap(this->d, other.d);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isNull() const;
|
|
||||||
|
|
||||||
Protocol protocol() const;
|
|
||||||
const char *fileName() const;
|
|
||||||
const char *version() const;
|
|
||||||
Version engineVersion() const;
|
|
||||||
const char *requiredVersion() const;
|
|
||||||
const char *homeDirectory() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
class Private;
|
|
||||||
std::shared_ptr<Private> d;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION(EngineInfo)
|
|
||||||
|
|
||||||
#endif // __GPGMEPP_ENGINEINFO_H__
|
|
@ -1,84 +0,0 @@
|
|||||||
/*
|
|
||||||
error.h - wraps a gpgme error
|
|
||||||
Copyright (C) 2003, 2007 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// -*- c++ -*-
|
|
||||||
#ifndef __GPGMEPP_ERROR_H__
|
|
||||||
#define __GPGMEPP_ERROR_H__
|
|
||||||
|
|
||||||
#include "global.h"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <iosfwd>
|
|
||||||
|
|
||||||
#include <gpg-error.h>
|
|
||||||
|
|
||||||
#ifndef GPGMEPP_ERR_SOURCE_DEFAULT
|
|
||||||
# define GPGMEPP_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_USER_1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace GpgME
|
|
||||||
{
|
|
||||||
|
|
||||||
class GPGMEPP_EXPORT Error
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Error() : mErr(0), mMessage() {}
|
|
||||||
explicit Error(unsigned int e) : mErr(e), mMessage() {}
|
|
||||||
|
|
||||||
const char *source() const;
|
|
||||||
/* This function is deprecated. Use asStdString() instead. asString() may
|
|
||||||
* return wrongly encoded (i.e. not UTF-8) results on Windows for the main
|
|
||||||
* thread if the function was first called from a secondary thread. */
|
|
||||||
GPGMEPP_DEPRECATED const char *asString() const;
|
|
||||||
std::string asStdString() const;
|
|
||||||
|
|
||||||
int code() const;
|
|
||||||
int sourceID() const;
|
|
||||||
|
|
||||||
bool isCanceled() const;
|
|
||||||
|
|
||||||
unsigned int encodedError() const
|
|
||||||
{
|
|
||||||
return mErr;
|
|
||||||
}
|
|
||||||
int toErrno() const;
|
|
||||||
|
|
||||||
static bool hasSystemError();
|
|
||||||
static Error fromSystemError(unsigned int src = GPGMEPP_ERR_SOURCE_DEFAULT);
|
|
||||||
static void setSystemError(gpg_err_code_t err);
|
|
||||||
static void setErrno(int err);
|
|
||||||
static Error fromErrno(int err, unsigned int src = GPGMEPP_ERR_SOURCE_DEFAULT);
|
|
||||||
static Error fromCode(unsigned int err, unsigned int src = GPGMEPP_ERR_SOURCE_DEFAULT);
|
|
||||||
|
|
||||||
GPGMEPP_MAKE_SAFE_BOOL_OPERATOR(mErr &&!isCanceled())
|
|
||||||
private:
|
|
||||||
unsigned int mErr;
|
|
||||||
mutable std::string mMessage;
|
|
||||||
};
|
|
||||||
|
|
||||||
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, const Error &err);
|
|
||||||
|
|
||||||
} // namespace GpgME
|
|
||||||
|
|
||||||
#endif /* __GPGMEPP_ERROR_H__ */
|
|
@ -1,205 +0,0 @@
|
|||||||
/*
|
|
||||||
eventloopinteractor.cpp
|
|
||||||
Copyright (C) 2003,2004 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <eventloopinteractor.h>
|
|
||||||
|
|
||||||
#include <context.h>
|
|
||||||
#include "context_p.h"
|
|
||||||
#include <key.h>
|
|
||||||
#include <trustitem.h>
|
|
||||||
|
|
||||||
#include <gpgme.h>
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
using std::vector;
|
|
||||||
#ifndef NDEBUG
|
|
||||||
# include <iostream>
|
|
||||||
#endif
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
namespace GpgME
|
|
||||||
{
|
|
||||||
|
|
||||||
//
|
|
||||||
// EventLoopInteractor::Private Declaration
|
|
||||||
//
|
|
||||||
|
|
||||||
class EventLoopInteractor::Private
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
struct OneFD {
|
|
||||||
OneFD(int aFd, int aDir, gpgme_io_cb_t aFnc,
|
|
||||||
void *aFncData, void *aExternalTag)
|
|
||||||
: fd(aFd), dir(aDir), fnc(aFnc),
|
|
||||||
fncData(aFncData), externalTag(aExternalTag) {}
|
|
||||||
int fd;
|
|
||||||
int dir;
|
|
||||||
gpgme_io_cb_t fnc;
|
|
||||||
void *fncData;
|
|
||||||
void *externalTag;
|
|
||||||
};
|
|
||||||
|
|
||||||
vector<OneFD *> mCallbacks;
|
|
||||||
|
|
||||||
static void removeIOCb(void *tag);
|
|
||||||
static gpgme_error_t registerIOCb(void *data, int fd, int dir,
|
|
||||||
gpgme_io_cb_t fnc, void *fnc_data,
|
|
||||||
void **r_tag);
|
|
||||||
static void eventIOCb(void *, gpgme_event_io_t type, void *type_data);
|
|
||||||
|
|
||||||
static const gpgme_io_cbs iocbs;
|
|
||||||
};
|
|
||||||
|
|
||||||
const gpgme_io_cbs EventLoopInteractor::Private::iocbs = {
|
|
||||||
&EventLoopInteractor::Private::registerIOCb,
|
|
||||||
nullptr,
|
|
||||||
&EventLoopInteractor::Private::removeIOCb,
|
|
||||||
&EventLoopInteractor::Private::eventIOCb,
|
|
||||||
nullptr
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// EventLoopInteractor::Private IO Callback Implementations
|
|
||||||
//
|
|
||||||
|
|
||||||
gpgme_error_t EventLoopInteractor::Private::registerIOCb(void *, int fd, int dir,
|
|
||||||
gpgme_io_cb_t fnc, void *fnc_data,
|
|
||||||
void **r_tag)
|
|
||||||
{
|
|
||||||
assert(instance()); assert(instance()->d);
|
|
||||||
bool ok = false;
|
|
||||||
void *etag = instance()->registerWatcher(fd, dir ? Read : Write, ok);
|
|
||||||
if (!ok) {
|
|
||||||
return gpgme_error(GPG_ERR_GENERAL);
|
|
||||||
}
|
|
||||||
instance()->d->mCallbacks.push_back(new OneFD(fd, dir, fnc, fnc_data, etag));
|
|
||||||
if (r_tag) {
|
|
||||||
*r_tag = instance()->d->mCallbacks.back();
|
|
||||||
}
|
|
||||||
return GPG_ERR_NO_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EventLoopInteractor::Private::removeIOCb(void *tag)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (!instance() || !instance()->d) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (vector<OneFD *>::iterator it = instance()->d->mCallbacks.begin();
|
|
||||||
it != instance()->d->mCallbacks.end() ; ++it) {
|
|
||||||
if (*it == tag) {
|
|
||||||
instance()->unregisterWatcher((*it)->externalTag);
|
|
||||||
delete *it; *it = nullptr;
|
|
||||||
instance()->d->mCallbacks.erase(it);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void EventLoopInteractor::Private::eventIOCb(void *data, gpgme_event_io_t type, void *type_data)
|
|
||||||
{
|
|
||||||
assert(instance());
|
|
||||||
Context *ctx = static_cast<Context *>(data);
|
|
||||||
switch (type) {
|
|
||||||
case GPGME_EVENT_START: {
|
|
||||||
instance()->operationStartEvent(ctx);
|
|
||||||
// TODO: what's in type_data?
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GPGME_EVENT_DONE: {
|
|
||||||
gpgme_error_t e = *static_cast<gpgme_error_t *>(type_data);
|
|
||||||
if (ctx && ctx->impl()) {
|
|
||||||
ctx->impl()->lasterr = e;
|
|
||||||
}
|
|
||||||
instance()->operationDoneEvent(ctx, Error(e));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GPGME_EVENT_NEXT_KEY: {
|
|
||||||
gpgme_key_t key = static_cast<gpgme_key_t>(type_data);
|
|
||||||
instance()->nextKeyEvent(ctx, Key(key, false));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GPGME_EVENT_NEXT_TRUSTITEM: {
|
|
||||||
gpgme_trust_item_t item = static_cast<gpgme_trust_item_t>(type_data);
|
|
||||||
instance()->nextTrustItemEvent(ctx, TrustItem(item));
|
|
||||||
gpgme_trust_item_unref(item);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default: // warn
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// EventLoopInteractor Implementation
|
|
||||||
//
|
|
||||||
|
|
||||||
EventLoopInteractor *EventLoopInteractor::mSelf = nullptr;
|
|
||||||
|
|
||||||
EventLoopInteractor::EventLoopInteractor() : d(new Private)
|
|
||||||
{
|
|
||||||
assert(!mSelf);
|
|
||||||
mSelf = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
EventLoopInteractor::~EventLoopInteractor()
|
|
||||||
{
|
|
||||||
// warn if there are still callbacks registered
|
|
||||||
mSelf = nullptr;
|
|
||||||
delete d;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EventLoopInteractor::manage(Context *context)
|
|
||||||
{
|
|
||||||
if (!context || context->managedByEventLoopInteractor()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
gpgme_io_cbs *iocbs = new gpgme_io_cbs(Private::iocbs);
|
|
||||||
iocbs->event_priv = context;
|
|
||||||
context->installIOCallbacks(iocbs);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EventLoopInteractor::unmanage(Context *context)
|
|
||||||
{
|
|
||||||
if (context) {
|
|
||||||
context->uninstallIOCallbacks();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void EventLoopInteractor::actOn(int fd, Direction dir)
|
|
||||||
{
|
|
||||||
for (vector<Private::OneFD *>::const_iterator it = d->mCallbacks.begin();
|
|
||||||
it != d->mCallbacks.end() ; ++it) {
|
|
||||||
if ((*it)->fd == fd && ((*it)->dir ? Read : Write) == dir) {
|
|
||||||
(*((*it)->fnc))((*it)->fncData, fd);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace GpgME
|
|
@ -1,158 +0,0 @@
|
|||||||
/*
|
|
||||||
eventloopinteractor.h
|
|
||||||
Copyright (C) 2003,2004 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// -*- c++ -*-
|
|
||||||
#ifndef __GPGMEPP_EVENTLOOPINTERACTOR_H__
|
|
||||||
#define __GPGMEPP_EVENTLOOPINTERACTOR_H__
|
|
||||||
|
|
||||||
#include "gpgmepp_export.h"
|
|
||||||
|
|
||||||
namespace GpgME
|
|
||||||
{
|
|
||||||
|
|
||||||
class Context;
|
|
||||||
class Error;
|
|
||||||
class TrustItem;
|
|
||||||
class Key;
|
|
||||||
|
|
||||||
/*! \file eventloopinteractor.h
|
|
||||||
\brief Abstract base class for gpgme's external event loop support
|
|
||||||
|
|
||||||
This class does most of the work involved with hooking GpgME++
|
|
||||||
up with external event loops, such as the GTK or Qt ones.
|
|
||||||
|
|
||||||
It actually provides two interfaces: An interface to the gpgme
|
|
||||||
IO Callback handling and one for gpgme events. The IO Callback
|
|
||||||
interface consists of the three methods \c actOn(), \c
|
|
||||||
registerWatcher() and \c unregisterWatcher(). The event
|
|
||||||
interface consists of the three methods \c nextTrustItemEvent(),
|
|
||||||
\c nextKeyEvent() and \c operationDoneEvent().
|
|
||||||
|
|
||||||
\sect General Usage
|
|
||||||
|
|
||||||
\c EventLoopInteractor is designed to be used as a
|
|
||||||
singleton. However, in order to make any use of it, you have to
|
|
||||||
subclass it and reimplement it's pure virtual methods (see
|
|
||||||
below). We suggest you keep the constructor protected and
|
|
||||||
provide a static \c instance() method that returns the single
|
|
||||||
instance. Alternatively, you can create an instance on the
|
|
||||||
stack, e.g. in \c main().
|
|
||||||
|
|
||||||
If you want \c EventLoopInteractor to manage a particular \c
|
|
||||||
Context, just call \c manage() on the \c Context. OTOH, if you
|
|
||||||
want to disable IO callbacks for a \c Context, use \c unmanage().
|
|
||||||
|
|
||||||
\sect IO Callback Interface
|
|
||||||
|
|
||||||
One part of this interface is represented by \c
|
|
||||||
registerWatcher() and \c unregisterWatcher(), both of which are
|
|
||||||
pure virtual. \c registerWatcher() should do anything necessary
|
|
||||||
to hook up watching of file descriptor \c fd for reading (\c dir
|
|
||||||
= \c Read) or writing (\c dir = Write) to the event loop you use
|
|
||||||
and return a tag identifying that particular watching process
|
|
||||||
uniquely. This could be the index into an array of objects you
|
|
||||||
use for that purpose or the address of such an object. E.g. in
|
|
||||||
Qt, you'd essentially just create a new \c QSocketNotifier:
|
|
||||||
|
|
||||||
\verbatim
|
|
||||||
void * registerWatcher( int fd, Direction dir ) {
|
|
||||||
return new QSocketNotifier( fd, dir == Read ? QSocketNotifier::Read : QSocketNotifier::Write );
|
|
||||||
// misses connecting to the activated() signal...
|
|
||||||
}
|
|
||||||
\endverbatim
|
|
||||||
|
|
||||||
which uses the address of the created object as unique tag. The
|
|
||||||
tag returned by \c registerWatcher is stored by \c
|
|
||||||
EventLoopInteractor and passed as argument to \c
|
|
||||||
unregisterWatcher(). So, in the picture above, you'd implement \c
|
|
||||||
unregisterWatcher() like this:
|
|
||||||
|
|
||||||
\verbatim
|
|
||||||
void unregisterWatcher( void * tag ) {
|
|
||||||
delete static_cast<QSocketNotifier*>( tag );
|
|
||||||
}
|
|
||||||
\endverbatim
|
|
||||||
|
|
||||||
The other part of the IO callback interface is \c actOn(), which
|
|
||||||
you should call if you receive notification from your event loop
|
|
||||||
about activity on file descriptor \c fd in direction \c dir. In
|
|
||||||
the picture above, you'd call this from the slot connected to
|
|
||||||
the socket notifier's \c activated() signal.
|
|
||||||
|
|
||||||
\note \c registerWatcher() as well as \c unregisterWatcher() may
|
|
||||||
be called from within \c actOn(), so be careful with
|
|
||||||
e.g. locking in threaded environments and keep in mind that the
|
|
||||||
object you used to find the \c fd and \c dir fo the \c actOn()
|
|
||||||
call might be deleted when \c actOn() returns!
|
|
||||||
|
|
||||||
\sect Event Handler Interface
|
|
||||||
|
|
||||||
*/
|
|
||||||
class GPGMEPP_EXPORT EventLoopInteractor
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
EventLoopInteractor();
|
|
||||||
public:
|
|
||||||
virtual ~EventLoopInteractor();
|
|
||||||
|
|
||||||
static EventLoopInteractor *instance()
|
|
||||||
{
|
|
||||||
return mSelf;
|
|
||||||
}
|
|
||||||
|
|
||||||
void manage(Context *context);
|
|
||||||
void unmanage(Context *context);
|
|
||||||
|
|
||||||
enum Direction { Read, Write };
|
|
||||||
protected:
|
|
||||||
//
|
|
||||||
// IO Notification Interface
|
|
||||||
//
|
|
||||||
|
|
||||||
/** Call this if your event loop detected activity on file
|
|
||||||
descriptor fd, with direction dir */
|
|
||||||
void actOn(int fd, Direction dir);
|
|
||||||
|
|
||||||
virtual void *registerWatcher(int fd, Direction dir, bool &ok) = 0;
|
|
||||||
virtual void unregisterWatcher(void *tag) = 0;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Event Handler Interface
|
|
||||||
//
|
|
||||||
|
|
||||||
virtual void operationStartEvent(Context *context) = 0;
|
|
||||||
virtual void nextTrustItemEvent(Context *context, const TrustItem &item) = 0;
|
|
||||||
virtual void nextKeyEvent(Context *context, const Key &key) = 0;
|
|
||||||
virtual void operationDoneEvent(Context *context, const Error &e) = 0;
|
|
||||||
|
|
||||||
private:
|
|
||||||
class Private;
|
|
||||||
friend class Private;
|
|
||||||
Private *const d;
|
|
||||||
static EventLoopInteractor *mSelf;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // __GPGMEPP_EVENTLOOPINTERACTOR_H__
|
|
@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
exception.cpp - exception wrapping a gpgme error
|
|
||||||
Copyright (C) 2007 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// -*- c++ -*-
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "exception.h"
|
|
||||||
|
|
||||||
#include <gpgme.h>
|
|
||||||
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
using namespace GpgME;
|
|
||||||
using namespace std; // only safe b/c it's so small a file!
|
|
||||||
|
|
||||||
Exception::~Exception() throw() {}
|
|
||||||
|
|
||||||
// static
|
|
||||||
string Exception::make_message(const Error &err, const string &msg)
|
|
||||||
{
|
|
||||||
return make_message(err, msg, NoOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
// static
|
|
||||||
string Exception::make_message(const Error &err, const string &msg, Options opt)
|
|
||||||
{
|
|
||||||
if (opt & MessageOnly) {
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
char error_string[128];
|
|
||||||
error_string[0] = '\0';
|
|
||||||
gpgme_strerror_r(err.encodedError(), error_string, sizeof error_string);
|
|
||||||
error_string[sizeof error_string - 1] = '\0';
|
|
||||||
stringstream ss;
|
|
||||||
ss << gpgme_strsource(err.encodedError()) << ": ";
|
|
||||||
if (!msg.empty()) {
|
|
||||||
ss << msg << ": ";
|
|
||||||
}
|
|
||||||
ss << error_string << " (" << static_cast<unsigned long>(err.encodedError()) << ')';
|
|
||||||
return ss.str();
|
|
||||||
}
|
|
@ -1,70 +0,0 @@
|
|||||||
/*
|
|
||||||
exception.h - exception wrapping a gpgme error
|
|
||||||
Copyright (C) 2007 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// -*- c++ -*-
|
|
||||||
#ifndef __GPGMEPP_EXCEPTION_H__
|
|
||||||
#define __GPGMEPP_EXCEPTION_H__
|
|
||||||
|
|
||||||
#include "error.h"
|
|
||||||
|
|
||||||
#include <stdexcept>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace GpgME
|
|
||||||
{
|
|
||||||
|
|
||||||
class GPGMEPP_EXPORT Exception : public std::runtime_error
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum Options {
|
|
||||||
NoOptions = 0x0,
|
|
||||||
MessageOnly = 0x1,
|
|
||||||
|
|
||||||
AllOptions = MessageOnly
|
|
||||||
};
|
|
||||||
|
|
||||||
explicit Exception(const GpgME::Error &err, const std::string &msg = std::string(), Options opt = NoOptions)
|
|
||||||
: std::runtime_error(make_message(err, msg, opt)), m_error(err), m_message(msg) {}
|
|
||||||
|
|
||||||
~Exception() throw();
|
|
||||||
|
|
||||||
Error error() const
|
|
||||||
{
|
|
||||||
return m_error;
|
|
||||||
}
|
|
||||||
const std::string &message() const
|
|
||||||
{
|
|
||||||
return m_message;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
static std::string make_message(const GpgME::Error &err, const std::string &msg);
|
|
||||||
static std::string make_message(const GpgME::Error &err, const std::string &msg, Options opt);
|
|
||||||
private:
|
|
||||||
const GpgME::Error m_error;
|
|
||||||
const std::string m_message;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace GpgME
|
|
||||||
|
|
||||||
#endif /* __GPGMEPP_EXCEPTION_H__ */
|
|
@ -1,244 +0,0 @@
|
|||||||
/*
|
|
||||||
global.h - global gpgme functions and enums
|
|
||||||
Copyright (C) 2003, 2007 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// -*- c++ -*-
|
|
||||||
#ifndef __GPGMEPP_GLOBAL_H__
|
|
||||||
#define __GPGMEPP_GLOBAL_H__
|
|
||||||
|
|
||||||
#include "gpgmefw.h"
|
|
||||||
#include "gpgmepp_export.h"
|
|
||||||
|
|
||||||
#include <iosfwd>
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
namespace GpgME
|
|
||||||
{
|
|
||||||
class Error;
|
|
||||||
class EngineInfo;
|
|
||||||
class Context;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct _GIOChannel;
|
|
||||||
typedef struct _GIOChannel GIOChannel;
|
|
||||||
class QIODevice;
|
|
||||||
|
|
||||||
namespace GpgME
|
|
||||||
{
|
|
||||||
|
|
||||||
GPGMEPP_EXPORT void initializeLibrary();
|
|
||||||
/*!
|
|
||||||
Initializes the library, returns Error::code() ==
|
|
||||||
GPG_ERR_USER_1 if underlying gpgme is too old.
|
|
||||||
*/
|
|
||||||
GPGMEPP_EXPORT Error initializeLibrary(int);
|
|
||||||
|
|
||||||
enum Protocol { OpenPGP, CMS, UnknownProtocol };
|
|
||||||
|
|
||||||
enum Engine { GpgEngine, GpgSMEngine, GpgConfEngine, UnknownEngine, AssuanEngine, G13Engine, SpawnEngine };
|
|
||||||
|
|
||||||
enum KeyListMode {
|
|
||||||
Local = 0x1,
|
|
||||||
Extern = 0x2,
|
|
||||||
Locate = Local|Extern,
|
|
||||||
Signatures = 0x4,
|
|
||||||
SignatureNotations = 0x8,
|
|
||||||
Validate = 0x10,
|
|
||||||
Ephemeral = 0x20,
|
|
||||||
WithTofu = 0x40,
|
|
||||||
WithKeygrip = 0x80,
|
|
||||||
WithSecret = 0x100,
|
|
||||||
ForceExtern = 0x200,
|
|
||||||
LocateExternal = Locate|ForceExtern,
|
|
||||||
|
|
||||||
KeyListModeMask = 0x3ff
|
|
||||||
};
|
|
||||||
|
|
||||||
enum SignatureMode {
|
|
||||||
NormalSignatureMode = 0,
|
|
||||||
Detached = 1,
|
|
||||||
Clearsigned = 2,
|
|
||||||
SignArchive = 4,
|
|
||||||
SignFile = 8,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class RevocationReason {
|
|
||||||
Unspecified = 0,
|
|
||||||
Compromised = 1,
|
|
||||||
Superseded = 2,
|
|
||||||
NoLongerUsed = 3
|
|
||||||
};
|
|
||||||
|
|
||||||
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, Protocol proto);
|
|
||||||
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, Engine eng);
|
|
||||||
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, KeyListMode mode);
|
|
||||||
GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, SignatureMode mode);
|
|
||||||
|
|
||||||
GPGMEPP_EXPORT Error setDefaultLocale(int category, const char *value);
|
|
||||||
|
|
||||||
GPGMEPP_EXPORT Context *wait(Error &e, bool hang = true);
|
|
||||||
typedef void (*IdleFunction)(void);
|
|
||||||
GPGMEPP_EXPORT IdleFunction registerIdleFunction(IdleFunction idleFunction);
|
|
||||||
|
|
||||||
typedef void (*IOCallback)(void *data, int fd);
|
|
||||||
|
|
||||||
GPGMEPP_EXPORT EngineInfo engineInfo(Protocol proto);
|
|
||||||
GPGMEPP_EXPORT EngineInfo engineInfo(Engine engine);
|
|
||||||
/** Wrapper around gpgme_get_dirinfo. What can be:
|
|
||||||
homedir, sysconfdir, bindir, libexecdir, libdir,
|
|
||||||
datadir, localedir, agent-socket, agent-ssh-socket,
|
|
||||||
dirmngr-socket, uiserver-socket, gpgconf-name, gpg-name,
|
|
||||||
gpgsm-name, g13-name, keyboxd-name, agent-name, scdaemon-name,
|
|
||||||
dirmngr-name, pinentry-name, socketdir, gpg-wks-client-name, gpgtar-name.
|
|
||||||
|
|
||||||
This may be extended in the future.
|
|
||||||
*/
|
|
||||||
GPGMEPP_EXPORT const char *dirInfo(const char *what);
|
|
||||||
|
|
||||||
GPGMEPP_EXPORT Error checkEngine(Protocol proto);
|
|
||||||
GPGMEPP_EXPORT Error checkEngine(Engine engine);
|
|
||||||
|
|
||||||
/* Wrapper for gpgme_set_global_flag */
|
|
||||||
GPGMEPP_EXPORT int setGlobalFlag(const char *name, const char *value);
|
|
||||||
|
|
||||||
GPGMEPP_EXPORT GIOChannel *getGIOChannel(int fd);
|
|
||||||
GPGMEPP_EXPORT QIODevice *getQIODevice(int fd);
|
|
||||||
|
|
||||||
enum Feature {
|
|
||||||
ValidatingKeylistModeFeature = 0x00000001,
|
|
||||||
CancelOperationFeature = 0x00000002,
|
|
||||||
WrongKeyUsageFeature = 0x00000004,
|
|
||||||
DefaultCertificateInclusionFeature = 0x00000008,
|
|
||||||
|
|
||||||
GetSetEngineInfoFeature = 0x00000010,
|
|
||||||
EngineInfoHomeDirFeature = 0x00000020,
|
|
||||||
NoEncryptToEncryptionFlagFeature = 0x00000040,
|
|
||||||
EphemeralKeylistModeFeature = 0x00000080,
|
|
||||||
|
|
||||||
SetDataFileNameFeeature = 0x00000100,
|
|
||||||
VerificationResultFileNameFeature = 0x00000200,
|
|
||||||
DecryptionResultFileNameFeature = 0x00000400,
|
|
||||||
DecryptionResultRecipientsFeature = 0x00000800,
|
|
||||||
|
|
||||||
AuditLogFeature = 0x00001000,
|
|
||||||
GpgConfEngineFeature = 0x00002000,
|
|
||||||
CancelOperationAsyncFeature = 0x00004000,
|
|
||||||
AssuanEngineFeature = 0x00008000,
|
|
||||||
|
|
||||||
ClearAddGetSignatureNotationsFeature = 0x00010000,
|
|
||||||
SignatureNotationsKeylistModeFeature = 0x00020000,
|
|
||||||
KeySignatureNotationsFeature = 0x00040000,
|
|
||||||
SignatureNotationsFlagsFeature = 0x00080000,
|
|
||||||
SignatureNotationsCriticalFlagFeature = 0x00100000,
|
|
||||||
SignatureNotationsHumanReadableFlagFeature = 0x00200000,
|
|
||||||
CardKeyFeature = 0x00400000,
|
|
||||||
ImportFromKeyserverFeature = 0x00800000,
|
|
||||||
|
|
||||||
KeyIsQualifiedFeature = 0x01000200,
|
|
||||||
SubkeyIsQualifiedFeature = 0x02000000,
|
|
||||||
SignaturePkaFieldsFeature = 0x04000000,
|
|
||||||
SignatureAlgorithmFieldsFeature = 0x08000000,
|
|
||||||
|
|
||||||
FdPointerFeature = 0x10000000,
|
|
||||||
G13VFSFeature = 0x20000000,
|
|
||||||
PasswdFeature = 0x40000000, // gpgme >= 1.3.0
|
|
||||||
// unusable (max value)
|
|
||||||
|
|
||||||
FeatureMaxValue = 0x80000000
|
|
||||||
};
|
|
||||||
enum Feature2 {
|
|
||||||
BinaryAndFineGrainedIdentify = 0x00000001, // gpgme >= 1.7.0
|
|
||||||
Feature2MaxValue = 0x80000000
|
|
||||||
};
|
|
||||||
|
|
||||||
// use hasFeature( unsigned long, unsigned long ) instead
|
|
||||||
GPGMEPP_DEPRECATED_EXPORT bool hasFeature(unsigned long feature);
|
|
||||||
GPGMEPP_EXPORT bool hasFeature(unsigned long feature, unsigned long feature2);
|
|
||||||
|
|
||||||
} // namespace GpgME
|
|
||||||
|
|
||||||
# ifndef GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION
|
|
||||||
# define GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION( Class ) \
|
|
||||||
namespace std { template <> inline void swap< GpgME::Class >( GpgME::Class & lhs, GpgME::Class & rhs ) { lhs.swap( rhs ); } }
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef GPGMEPP_MAKE_SAFE_BOOL_OPERATOR
|
|
||||||
# define GPGMEPP_MAKE_SAFE_BOOL_OPERATOR( Cond ) \
|
|
||||||
private: \
|
|
||||||
struct __safe_bool_dummy__ { void nonnull() {} }; \
|
|
||||||
typedef void ( __safe_bool_dummy__::*unspecified_bool_type )(); \
|
|
||||||
public: \
|
|
||||||
operator unspecified_bool_type() const { return ( Cond ) ? &__safe_bool_dummy__::nonnull : nullptr; }
|
|
||||||
# endif
|
|
||||||
|
|
||||||
inline int _gpgmepp_strcmp(const char *s1, const char *s2)
|
|
||||||
{
|
|
||||||
return s1 ? s2 ? std::strcmp(s1, s2) : 1 : s2 ? -1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define _GPGMEPP_MAKE_STRCMP( Name, expr, cmp ) \
|
|
||||||
template <template <typename U> class Op> \
|
|
||||||
struct Name { \
|
|
||||||
typedef bool result_type; \
|
|
||||||
\
|
|
||||||
bool operator()( const char * lhs, const char * rhs ) const { \
|
|
||||||
return Op<int>()( cmp, 0 ); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
bool operator()( const std::string & lhs, const std::string & rhs ) const { \
|
|
||||||
return operator()( lhs.c_str(), rhs.c_str() ); \
|
|
||||||
} \
|
|
||||||
bool operator()( const char * lhs, const std::string & rhs ) const { \
|
|
||||||
return operator()( lhs, rhs.c_str() ); \
|
|
||||||
} \
|
|
||||||
bool operator()( const std::string & lhs, const char * rhs ) const { \
|
|
||||||
return operator()( lhs.c_str(), rhs ); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
template <typename T> \
|
|
||||||
bool operator()( const T & lhs, const T & rhs ) const { \
|
|
||||||
return operator()( (lhs expr), (rhs expr) ); \
|
|
||||||
} \
|
|
||||||
template <typename T> \
|
|
||||||
bool operator()( const T & lhs, const char * rhs ) const { \
|
|
||||||
return operator()( (lhs expr), rhs ); \
|
|
||||||
} \
|
|
||||||
template <typename T> \
|
|
||||||
bool operator()( const char * lhs, const T & rhs ) const { \
|
|
||||||
return operator()( lhs, (rhs expr) ); \
|
|
||||||
} \
|
|
||||||
template <typename T> \
|
|
||||||
bool operator()( const T & lhs, const std::string & rhs ) const { \
|
|
||||||
return operator()( (lhs expr), rhs ); \
|
|
||||||
} \
|
|
||||||
template <typename T> \
|
|
||||||
bool operator()( const std::string & lhs, const T & rhs ) const { \
|
|
||||||
return operator()( lhs, (rhs expr) ); \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define GPGMEPP_MAKE_STRCMP( Name, expr ) \
|
|
||||||
_GPGMEPP_MAKE_STRCMP( Name, expr, _gpgmepp_strcmp( lhs, rhs ) )
|
|
||||||
|
|
||||||
|
|
||||||
#endif // __GPGMEPP_GLOBAL_H__
|
|
@ -1,205 +0,0 @@
|
|||||||
/*
|
|
||||||
gpgaddexistingsubkeyeditinteractor.cpp - Edit Interactor to add an existing subkey to an OpenPGP key
|
|
||||||
Copyright (c) 2022 g10 Code GmbH
|
|
||||||
Software engineering by Ingo Klöcker <dev@ingo-kloecker.de>
|
|
||||||
|
|
||||||
This file is part of GPGME++.
|
|
||||||
|
|
||||||
GPGME++ is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "gpgaddexistingsubkeyeditinteractor.h"
|
|
||||||
|
|
||||||
#include "error.h"
|
|
||||||
|
|
||||||
#include <gpgme.h>
|
|
||||||
|
|
||||||
// avoid conflict (msvc)
|
|
||||||
#ifdef ERROR
|
|
||||||
# undef ERROR
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace GpgME;
|
|
||||||
|
|
||||||
class GpgAddExistingSubkeyEditInteractor::Private
|
|
||||||
{
|
|
||||||
enum {
|
|
||||||
START = EditInteractor::StartState,
|
|
||||||
COMMAND,
|
|
||||||
ADD_EXISTING_KEY,
|
|
||||||
KEYGRIP,
|
|
||||||
FLAGS,
|
|
||||||
VALID,
|
|
||||||
KEY_CREATED,
|
|
||||||
QUIT,
|
|
||||||
SAVE,
|
|
||||||
|
|
||||||
ERROR = EditInteractor::ErrorState
|
|
||||||
};
|
|
||||||
|
|
||||||
GpgAddExistingSubkeyEditInteractor *const q = nullptr;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Private(GpgAddExistingSubkeyEditInteractor *q, const std::string &keygrip)
|
|
||||||
: q{q}
|
|
||||||
, keygrip{keygrip}
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *action(Error &err) const;
|
|
||||||
unsigned int nextState(unsigned int statusCode, const char *args, Error &err) const;
|
|
||||||
|
|
||||||
std::string keygrip;
|
|
||||||
std::string expiry;
|
|
||||||
};
|
|
||||||
|
|
||||||
const char *GpgAddExistingSubkeyEditInteractor::Private::action(Error &err) const
|
|
||||||
{
|
|
||||||
switch (q->state()) {
|
|
||||||
case COMMAND:
|
|
||||||
return "addkey";
|
|
||||||
case ADD_EXISTING_KEY:
|
|
||||||
return "keygrip";
|
|
||||||
case KEYGRIP:
|
|
||||||
return keygrip.c_str();
|
|
||||||
case FLAGS:
|
|
||||||
return "Q"; // do not toggle any usage flags
|
|
||||||
case VALID:
|
|
||||||
return expiry.empty() ? "0" : expiry.c_str();
|
|
||||||
case QUIT:
|
|
||||||
return "quit";
|
|
||||||
case SAVE:
|
|
||||||
return "Y";
|
|
||||||
case START:
|
|
||||||
case KEY_CREATED:
|
|
||||||
case ERROR:
|
|
||||||
return nullptr;
|
|
||||||
default:
|
|
||||||
err = Error::fromCode(GPG_ERR_GENERAL);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int GpgAddExistingSubkeyEditInteractor::Private::nextState(unsigned int status, const char *args, Error &err) const
|
|
||||||
{
|
|
||||||
using std::strcmp;
|
|
||||||
|
|
||||||
static const Error GENERAL_ERROR = Error::fromCode(GPG_ERR_GENERAL);
|
|
||||||
static const Error NO_KEY_ERROR = Error::fromCode(GPG_ERR_NO_KEY);
|
|
||||||
static const Error INV_TIME_ERROR = Error::fromCode(GPG_ERR_INV_TIME);
|
|
||||||
|
|
||||||
switch (q->state()) {
|
|
||||||
case START:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keyedit.prompt") == 0) {
|
|
||||||
return COMMAND;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case COMMAND:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keygen.algo") == 0) {
|
|
||||||
return ADD_EXISTING_KEY;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case ADD_EXISTING_KEY:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keygen.keygrip") == 0) {
|
|
||||||
return KEYGRIP;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case KEYGRIP:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keygen.flags") == 0) {
|
|
||||||
return FLAGS;
|
|
||||||
} else if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keygen.keygrip") == 0) {
|
|
||||||
err = NO_KEY_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case FLAGS:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keygen.valid") == 0) {
|
|
||||||
return VALID;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case VALID:
|
|
||||||
if (status == GPGME_STATUS_KEY_CREATED) {
|
|
||||||
return KEY_CREATED;
|
|
||||||
}
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keyedit.prompt") == 0) {
|
|
||||||
return QUIT;
|
|
||||||
} else if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keygen.valid") == 0) {
|
|
||||||
err = INV_TIME_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case KEY_CREATED:
|
|
||||||
return QUIT;
|
|
||||||
case QUIT:
|
|
||||||
if (status == GPGME_STATUS_GET_BOOL &&
|
|
||||||
strcmp(args, "keyedit.save.okay") == 0) {
|
|
||||||
return SAVE;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case ERROR:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keyedit.prompt") == 0) {
|
|
||||||
return QUIT;
|
|
||||||
}
|
|
||||||
err = q->lastError();
|
|
||||||
return ERROR;
|
|
||||||
default:
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgAddExistingSubkeyEditInteractor::GpgAddExistingSubkeyEditInteractor(const std::string &keygrip)
|
|
||||||
: EditInteractor{}
|
|
||||||
, d{new Private{this, keygrip}}
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgAddExistingSubkeyEditInteractor::~GpgAddExistingSubkeyEditInteractor() = default;
|
|
||||||
|
|
||||||
void GpgAddExistingSubkeyEditInteractor::setExpiry(const std::string &timeString)
|
|
||||||
{
|
|
||||||
d->expiry = timeString;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *GpgAddExistingSubkeyEditInteractor::action(Error &err) const
|
|
||||||
{
|
|
||||||
return d->action(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int GpgAddExistingSubkeyEditInteractor::nextState(unsigned int status, const char *args, Error &err) const
|
|
||||||
{
|
|
||||||
return d->nextState(status, args, err);
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
gpgaddexistingsubkeyeditinteractor.h - Edit Interactor to add an existing subkey to an OpenPGP key
|
|
||||||
Copyright (c) 2022 g10 Code GmbH
|
|
||||||
Software engineering by Ingo Klöcker <dev@ingo-kloecker.de>
|
|
||||||
|
|
||||||
This file is part of GPGME++.
|
|
||||||
|
|
||||||
GPGME++ is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GPGMEPP_GPGADDEXISTINGSUBKEYEDITINTERACTOR_H__
|
|
||||||
#define __GPGMEPP_GPGADDEXISTINGSUBKEYEDITINTERACTOR_H__
|
|
||||||
|
|
||||||
#include "editinteractor.h"
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace GpgME
|
|
||||||
{
|
|
||||||
|
|
||||||
class GPGMEPP_EXPORT GpgAddExistingSubkeyEditInteractor : public EditInteractor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/** Edit interactor to add the existing subkey with keygrip \a keygrip
|
|
||||||
* to the key a key edit operation is working on.
|
|
||||||
**/
|
|
||||||
explicit GpgAddExistingSubkeyEditInteractor(const std::string &keygrip);
|
|
||||||
~GpgAddExistingSubkeyEditInteractor() override;
|
|
||||||
|
|
||||||
/** Sets the validity period of the added subkey. Use "0" for no expiration
|
|
||||||
* or a simplified ISO date string ("yyyymmddThhmmss") for setting an
|
|
||||||
* expiration date. */
|
|
||||||
void setExpiry(const std::string &timeString);
|
|
||||||
|
|
||||||
private:
|
|
||||||
const char *action(Error &err) const override;
|
|
||||||
unsigned int nextState(unsigned int statusCode, const char *args, Error &err) const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
class Private;
|
|
||||||
const std::unique_ptr<Private> d;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace GpgME
|
|
||||||
|
|
||||||
#endif // __GPGMEPP_GPGADDEXISTINGSUBKEYEDITINTERACTOR_H__
|
|
@ -1,191 +0,0 @@
|
|||||||
/*
|
|
||||||
gpgadduserideditinteractor.cpp - Edit Interactor to add a new UID to an OpenPGP key
|
|
||||||
Copyright (C) 2008 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "gpgadduserideditinteractor.h"
|
|
||||||
|
|
||||||
#include "error.h"
|
|
||||||
|
|
||||||
#include <gpgme.h>
|
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
using std::strcmp;
|
|
||||||
|
|
||||||
// avoid conflict (msvc)
|
|
||||||
#ifdef ERROR
|
|
||||||
# undef ERROR
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace GpgME;
|
|
||||||
|
|
||||||
GpgAddUserIDEditInteractor::GpgAddUserIDEditInteractor()
|
|
||||||
: EditInteractor(),
|
|
||||||
m_name(),
|
|
||||||
m_email(),
|
|
||||||
m_comment()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgAddUserIDEditInteractor::~GpgAddUserIDEditInteractor() {}
|
|
||||||
|
|
||||||
void GpgAddUserIDEditInteractor::setNameUtf8(const std::string &name)
|
|
||||||
{
|
|
||||||
m_name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GpgAddUserIDEditInteractor::setEmailUtf8(const std::string &email)
|
|
||||||
{
|
|
||||||
m_email = email;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GpgAddUserIDEditInteractor::setCommentUtf8(const std::string &comment)
|
|
||||||
{
|
|
||||||
m_comment = comment;
|
|
||||||
}
|
|
||||||
|
|
||||||
// work around --enable-final
|
|
||||||
namespace GpgAddUserIDEditInteractor_Private
|
|
||||||
{
|
|
||||||
enum {
|
|
||||||
START = EditInteractor::StartState,
|
|
||||||
COMMAND,
|
|
||||||
NAME,
|
|
||||||
EMAIL,
|
|
||||||
COMMENT,
|
|
||||||
QUIT,
|
|
||||||
SAVE,
|
|
||||||
|
|
||||||
ERROR = EditInteractor::ErrorState
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *GpgAddUserIDEditInteractor::action(Error &err) const
|
|
||||||
{
|
|
||||||
|
|
||||||
using namespace GpgAddUserIDEditInteractor_Private;
|
|
||||||
|
|
||||||
switch (state()) {
|
|
||||||
case COMMAND:
|
|
||||||
return "adduid";
|
|
||||||
case NAME:
|
|
||||||
return m_name.c_str();
|
|
||||||
case EMAIL:
|
|
||||||
return m_email.c_str();
|
|
||||||
case COMMENT:
|
|
||||||
return m_comment.c_str();
|
|
||||||
case QUIT:
|
|
||||||
return "quit";
|
|
||||||
case SAVE:
|
|
||||||
return "Y";
|
|
||||||
case START:
|
|
||||||
case ERROR:
|
|
||||||
return nullptr;
|
|
||||||
default:
|
|
||||||
err = Error::fromCode(GPG_ERR_GENERAL);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int GpgAddUserIDEditInteractor::nextState(unsigned int status, const char *args, Error &err) const
|
|
||||||
{
|
|
||||||
|
|
||||||
static const Error GENERAL_ERROR = Error::fromCode(GPG_ERR_GENERAL);
|
|
||||||
static const Error INV_NAME_ERROR = Error::fromCode(GPG_ERR_INV_NAME);
|
|
||||||
static const Error INV_EMAIL_ERROR = Error::fromCode(GPG_ERR_INV_USER_ID);
|
|
||||||
static const Error INV_COMMENT_ERROR = Error::fromCode(GPG_ERR_INV_USER_ID);
|
|
||||||
|
|
||||||
using namespace GpgAddUserIDEditInteractor_Private;
|
|
||||||
|
|
||||||
switch (state()) {
|
|
||||||
case START:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keyedit.prompt") == 0) {
|
|
||||||
return COMMAND;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case COMMAND:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keygen.name") == 0) {
|
|
||||||
return NAME;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case NAME:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keygen.email") == 0) {
|
|
||||||
return EMAIL;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keygen.name") == 0) {
|
|
||||||
err = INV_NAME_ERROR;
|
|
||||||
}
|
|
||||||
return ERROR;
|
|
||||||
case EMAIL:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keygen.comment") == 0) {
|
|
||||||
return COMMENT;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keygen.email") == 0) {
|
|
||||||
err = INV_EMAIL_ERROR;
|
|
||||||
}
|
|
||||||
return ERROR;
|
|
||||||
case COMMENT:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keyedit.prompt") == 0) {
|
|
||||||
return QUIT;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keygen.comment") == 0) {
|
|
||||||
err = INV_COMMENT_ERROR;
|
|
||||||
}
|
|
||||||
return ERROR;
|
|
||||||
case QUIT:
|
|
||||||
if (status == GPGME_STATUS_GET_BOOL &&
|
|
||||||
strcmp(args, "keyedit.save.okay") == 0) {
|
|
||||||
return SAVE;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case ERROR:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keyedit.prompt") == 0) {
|
|
||||||
return QUIT;
|
|
||||||
}
|
|
||||||
err = lastError();
|
|
||||||
return ERROR;
|
|
||||||
default:
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,69 +0,0 @@
|
|||||||
/*
|
|
||||||
gpgadduserideditinteractor.h - Edit Interactor to add a new UID to an OpenPGP key
|
|
||||||
Copyright (C) 2008 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GPGMEPP_GPGADDUSERIDEDITINTERACTOR_H__
|
|
||||||
#define __GPGMEPP_GPGADDUSERIDEDITINTERACTOR_H__
|
|
||||||
|
|
||||||
#include "editinteractor.h"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace GpgME
|
|
||||||
{
|
|
||||||
|
|
||||||
class GPGMEPP_EXPORT GpgAddUserIDEditInteractor : public EditInteractor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit GpgAddUserIDEditInteractor();
|
|
||||||
~GpgAddUserIDEditInteractor();
|
|
||||||
|
|
||||||
void setNameUtf8(const std::string &name);
|
|
||||||
const std::string &nameUtf8() const
|
|
||||||
{
|
|
||||||
return m_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setEmailUtf8(const std::string &email);
|
|
||||||
const std::string &emailUtf8() const
|
|
||||||
{
|
|
||||||
return m_email;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setCommentUtf8(const std::string &comment);
|
|
||||||
const std::string &commentUtf8() const
|
|
||||||
{
|
|
||||||
return m_comment;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
const char *action(Error &err) const override;
|
|
||||||
unsigned int nextState(unsigned int statusCode, const char *args, Error &err) const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string m_name, m_email, m_comment;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace GpgME
|
|
||||||
|
|
||||||
#endif // __GPGMEPP_GPGADDUSERIDEDITINTERACTOR_H__
|
|
@ -1,123 +0,0 @@
|
|||||||
/*
|
|
||||||
gpgagentgetinfoassuantransaction.cpp - Assuan Transaction to get information from gpg-agent
|
|
||||||
Copyright (C) 2009 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "gpgagentgetinfoassuantransaction.h"
|
|
||||||
#include "error.h"
|
|
||||||
#include "data.h"
|
|
||||||
#include "util.h"
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
using namespace GpgME;
|
|
||||||
|
|
||||||
GpgAgentGetInfoAssuanTransaction::GpgAgentGetInfoAssuanTransaction(InfoItem item)
|
|
||||||
: AssuanTransaction(),
|
|
||||||
m_item(item),
|
|
||||||
m_command(),
|
|
||||||
m_data()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgAgentGetInfoAssuanTransaction::~GpgAgentGetInfoAssuanTransaction() {}
|
|
||||||
|
|
||||||
std::string GpgAgentGetInfoAssuanTransaction::version() const
|
|
||||||
{
|
|
||||||
if (m_item == Version) {
|
|
||||||
return m_data;
|
|
||||||
} else {
|
|
||||||
return std::string();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int GpgAgentGetInfoAssuanTransaction::pid() const
|
|
||||||
{
|
|
||||||
if (m_item == Pid) {
|
|
||||||
return to_pid(m_data);
|
|
||||||
} else {
|
|
||||||
return 0U;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string GpgAgentGetInfoAssuanTransaction::socketName() const
|
|
||||||
{
|
|
||||||
if (m_item == SocketName) {
|
|
||||||
return m_data;
|
|
||||||
} else {
|
|
||||||
return std::string();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string GpgAgentGetInfoAssuanTransaction::sshSocketName() const
|
|
||||||
{
|
|
||||||
if (m_item == SshSocketName) {
|
|
||||||
return m_data;
|
|
||||||
} else {
|
|
||||||
return std::string();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *const gpgagent_getinfo_tokens[] = {
|
|
||||||
"version",
|
|
||||||
"pid",
|
|
||||||
"socket_name",
|
|
||||||
"ssh_socket_name",
|
|
||||||
"scd_running",
|
|
||||||
};
|
|
||||||
|
|
||||||
void GpgAgentGetInfoAssuanTransaction::makeCommand() const
|
|
||||||
{
|
|
||||||
assert(m_item >= 0);
|
|
||||||
assert(m_item < LastInfoItem);
|
|
||||||
m_command = "GETINFO ";
|
|
||||||
m_command += gpgagent_getinfo_tokens[m_item];
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *GpgAgentGetInfoAssuanTransaction::command() const
|
|
||||||
{
|
|
||||||
makeCommand();
|
|
||||||
return m_command.c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
Error GpgAgentGetInfoAssuanTransaction::data(const char *data, size_t len)
|
|
||||||
{
|
|
||||||
m_data.append(data, len);
|
|
||||||
return Error();
|
|
||||||
}
|
|
||||||
|
|
||||||
Data GpgAgentGetInfoAssuanTransaction::inquire(const char *name, const char *args, Error &err)
|
|
||||||
{
|
|
||||||
(void)name; (void)args; (void)err;
|
|
||||||
return Data::null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Error GpgAgentGetInfoAssuanTransaction::status(const char *status, const char *args)
|
|
||||||
{
|
|
||||||
(void)status; (void)args;
|
|
||||||
return Error();
|
|
||||||
}
|
|
@ -1,75 +0,0 @@
|
|||||||
/*
|
|
||||||
gpgagentgetinfoassuantransaction.h - Assuan Transaction to get information from gpg-agent
|
|
||||||
Copyright (C) 2009 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GPGMEPP_GPGAGENTGETINFOASSUANTRANSACTION_H__
|
|
||||||
#define __GPGMEPP_GPGAGENTGETINFOASSUANTRANSACTION_H__
|
|
||||||
|
|
||||||
#include "interfaces/assuantransaction.h"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace GpgME
|
|
||||||
{
|
|
||||||
|
|
||||||
class GPGMEPP_EXPORT GpgAgentGetInfoAssuanTransaction : public AssuanTransaction
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum InfoItem {
|
|
||||||
Version, // string
|
|
||||||
Pid, // unsigned long
|
|
||||||
SocketName, // string (path)
|
|
||||||
SshSocketName, // string (path)
|
|
||||||
ScdRunning, // (none, returns GPG_ERR_GENERAL when scdaemon isn't running)
|
|
||||||
//CommandHasOption, // not supported
|
|
||||||
|
|
||||||
LastInfoItem
|
|
||||||
};
|
|
||||||
|
|
||||||
explicit GpgAgentGetInfoAssuanTransaction(InfoItem item);
|
|
||||||
~GpgAgentGetInfoAssuanTransaction();
|
|
||||||
|
|
||||||
std::string version() const;
|
|
||||||
unsigned int pid() const;
|
|
||||||
std::string socketName() const;
|
|
||||||
std::string sshSocketName() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
const char *command() const;
|
|
||||||
Error data(const char *data, size_t datalen) override;
|
|
||||||
Data inquire(const char *name, const char *args, Error &err) override;
|
|
||||||
Error status(const char *status, const char *args) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void makeCommand() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
InfoItem m_item;
|
|
||||||
mutable std::string m_command;
|
|
||||||
std::string m_data;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace GpgME
|
|
||||||
|
|
||||||
#endif // __GPGMEPP_GPGAGENTGETINFOASSUANTRANSACTION_H__
|
|
@ -1,469 +0,0 @@
|
|||||||
/*
|
|
||||||
gpggencardkeyinteractor.cpp - Edit Interactor to generate a key on a card
|
|
||||||
Copyright (C) 2017 by Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "gpggencardkeyinteractor.h"
|
|
||||||
|
|
||||||
#include "error.h"
|
|
||||||
|
|
||||||
#include <gpgme.h>
|
|
||||||
|
|
||||||
using namespace GpgME;
|
|
||||||
|
|
||||||
class GpgGenCardKeyInteractor::Private
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Private() : keysize("2048")
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string name, email, backupFileName, expiry, serial, keysize;
|
|
||||||
bool backup = false;
|
|
||||||
Algo algo = RSA;
|
|
||||||
std::string curve;
|
|
||||||
};
|
|
||||||
|
|
||||||
GpgGenCardKeyInteractor::~GpgGenCardKeyInteractor() = default;
|
|
||||||
|
|
||||||
GpgGenCardKeyInteractor::GpgGenCardKeyInteractor(const std::string &serial):
|
|
||||||
d(new Private)
|
|
||||||
{
|
|
||||||
d->serial = serial;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GpgGenCardKeyInteractor::setNameUtf8(const std::string &name)
|
|
||||||
{
|
|
||||||
d->name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GpgGenCardKeyInteractor::setEmailUtf8(const std::string &email)
|
|
||||||
{
|
|
||||||
d->email = email;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GpgGenCardKeyInteractor::setDoBackup(bool value)
|
|
||||||
{
|
|
||||||
d->backup = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GpgGenCardKeyInteractor::setKeySize(int value)
|
|
||||||
{
|
|
||||||
d->keysize = std::to_string(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GpgGenCardKeyInteractor::setExpiry(const std::string &timeStr)
|
|
||||||
{
|
|
||||||
d->expiry = timeStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string GpgGenCardKeyInteractor::backupFileName() const
|
|
||||||
{
|
|
||||||
return d->backupFileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GpgGenCardKeyInteractor::setAlgo(Algo algo)
|
|
||||||
{
|
|
||||||
d->algo = algo;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GpgGenCardKeyInteractor::setCurve(Curve curve)
|
|
||||||
{
|
|
||||||
if (curve == DefaultCurve) {
|
|
||||||
d->curve.clear();
|
|
||||||
} else if (curve >= 1 && curve <= LastCurve) {
|
|
||||||
d->curve = std::to_string(static_cast<int>(curve));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace GpgGenCardKeyInteractor_Private
|
|
||||||
{
|
|
||||||
enum {
|
|
||||||
START = EditInteractor::StartState,
|
|
||||||
DO_ADMIN,
|
|
||||||
EXPIRE,
|
|
||||||
|
|
||||||
GOT_SERIAL,
|
|
||||||
COMMAND,
|
|
||||||
NAME,
|
|
||||||
EMAIL,
|
|
||||||
COMMENT,
|
|
||||||
BACKUP,
|
|
||||||
REPLACE,
|
|
||||||
SIZE,
|
|
||||||
SIZE2,
|
|
||||||
SIZE3,
|
|
||||||
BACKUP_KEY_CREATED,
|
|
||||||
KEY_CREATED,
|
|
||||||
QUIT,
|
|
||||||
SAVE,
|
|
||||||
|
|
||||||
KEY_ATTR,
|
|
||||||
KEY_ALGO1,
|
|
||||||
KEY_ALGO2,
|
|
||||||
KEY_ALGO3,
|
|
||||||
KEY_CURVE1,
|
|
||||||
KEY_CURVE2,
|
|
||||||
KEY_CURVE3,
|
|
||||||
|
|
||||||
ERROR = EditInteractor::ErrorState
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *GpgGenCardKeyInteractor::action(Error &err) const
|
|
||||||
{
|
|
||||||
|
|
||||||
using namespace GpgGenCardKeyInteractor_Private;
|
|
||||||
|
|
||||||
switch (state()) {
|
|
||||||
case DO_ADMIN:
|
|
||||||
return "admin";
|
|
||||||
case COMMAND:
|
|
||||||
return "generate";
|
|
||||||
case KEY_ATTR:
|
|
||||||
return "key-attr";
|
|
||||||
case KEY_ALGO1:
|
|
||||||
case KEY_ALGO2:
|
|
||||||
case KEY_ALGO3:
|
|
||||||
return d->algo == RSA ? "1" : "2";
|
|
||||||
case KEY_CURVE1:
|
|
||||||
case KEY_CURVE2:
|
|
||||||
case KEY_CURVE3:
|
|
||||||
return d->curve.empty() ? "1" : d->curve.c_str(); // default is Curve25519
|
|
||||||
case NAME:
|
|
||||||
return d->name.c_str();
|
|
||||||
case EMAIL:
|
|
||||||
return d->email.c_str();
|
|
||||||
case EXPIRE:
|
|
||||||
return d->expiry.c_str();
|
|
||||||
case BACKUP:
|
|
||||||
return d->backup ? "Y" : "N";
|
|
||||||
case REPLACE:
|
|
||||||
return "Y";
|
|
||||||
case SIZE:
|
|
||||||
case SIZE2:
|
|
||||||
case SIZE3:
|
|
||||||
return d->keysize.c_str();
|
|
||||||
case COMMENT:
|
|
||||||
return "";
|
|
||||||
case SAVE:
|
|
||||||
return "Y";
|
|
||||||
case QUIT:
|
|
||||||
return "quit";
|
|
||||||
case KEY_CREATED:
|
|
||||||
case START:
|
|
||||||
case GOT_SERIAL:
|
|
||||||
case BACKUP_KEY_CREATED:
|
|
||||||
case ERROR:
|
|
||||||
return nullptr;
|
|
||||||
default:
|
|
||||||
err = Error::fromCode(GPG_ERR_GENERAL);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int GpgGenCardKeyInteractor::nextState(unsigned int status, const char *args, Error &err) const
|
|
||||||
{
|
|
||||||
|
|
||||||
static const Error GENERAL_ERROR = Error::fromCode(GPG_ERR_GENERAL);
|
|
||||||
static const Error INV_NAME_ERROR = Error::fromCode(GPG_ERR_INV_NAME);
|
|
||||||
static const Error INV_EMAIL_ERROR = Error::fromCode(GPG_ERR_INV_USER_ID);
|
|
||||||
static const Error INV_COMMENT_ERROR = Error::fromCode(GPG_ERR_INV_USER_ID);
|
|
||||||
|
|
||||||
using namespace GpgGenCardKeyInteractor_Private;
|
|
||||||
|
|
||||||
switch (state()) {
|
|
||||||
case START:
|
|
||||||
if (status == GPGME_STATUS_CARDCTRL &&
|
|
||||||
!d->serial.empty()) {
|
|
||||||
const std::string sArgs = args;
|
|
||||||
if (sArgs.find(d->serial) == std::string::npos) {
|
|
||||||
// Wrong smartcard
|
|
||||||
err = Error::fromCode(GPG_ERR_WRONG_CARD);
|
|
||||||
return ERROR;
|
|
||||||
} else {
|
|
||||||
printf("EditInteractor: Confirmed S/N: %s %s\n",
|
|
||||||
d->serial.c_str(), sArgs.c_str());
|
|
||||||
}
|
|
||||||
return GOT_SERIAL;
|
|
||||||
} else if (d->serial.empty()) {
|
|
||||||
return GOT_SERIAL;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case GOT_SERIAL:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "cardedit.prompt") == 0) {
|
|
||||||
return DO_ADMIN;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case DO_ADMIN:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "cardedit.prompt") == 0) {
|
|
||||||
return KEY_ATTR;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
// Handling for key-attr subcommand
|
|
||||||
case KEY_ATTR:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "cardedit.prompt") == 0) {
|
|
||||||
// Happens if key attr is not yet supported.
|
|
||||||
return COMMAND;
|
|
||||||
}
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "cardedit.genkeys.algo") == 0) {
|
|
||||||
return KEY_ALGO1;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case KEY_ALGO1:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "cardedit.genkeys.size") == 0) {
|
|
||||||
return SIZE;
|
|
||||||
}
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keygen.curve") == 0) {
|
|
||||||
return KEY_CURVE1;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case KEY_ALGO2:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "cardedit.genkeys.size") == 0) {
|
|
||||||
return SIZE2;
|
|
||||||
}
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keygen.curve") == 0) {
|
|
||||||
return KEY_CURVE2;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case KEY_ALGO3:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "cardedit.genkeys.size") == 0) {
|
|
||||||
return SIZE3;
|
|
||||||
}
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keygen.curve") == 0) {
|
|
||||||
return KEY_CURVE3;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case KEY_CURVE1:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "cardedit.genkeys.algo") == 0) {
|
|
||||||
return KEY_ALGO2;
|
|
||||||
}
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "cardedit.prompt") == 0) {
|
|
||||||
return COMMAND;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case KEY_CURVE2:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "cardedit.genkeys.algo") == 0) {
|
|
||||||
return KEY_ALGO3;
|
|
||||||
}
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "cardedit.prompt") == 0) {
|
|
||||||
return COMMAND;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case KEY_CURVE3:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "cardedit.genkeys.algo") == 0) {
|
|
||||||
return KEY_ALGO3;
|
|
||||||
}
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "cardedit.prompt") == 0) {
|
|
||||||
return COMMAND;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
// End key-attr handling
|
|
||||||
case COMMAND:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "cardedit.genkeys.backup_enc") == 0) {
|
|
||||||
return BACKUP;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case BACKUP:
|
|
||||||
if (status == GPGME_STATUS_GET_BOOL &&
|
|
||||||
strcmp(args, "cardedit.genkeys.replace_keys") == 0) {
|
|
||||||
return REPLACE;
|
|
||||||
}
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "cardedit.genkeys.size") == 0) {
|
|
||||||
return SIZE;
|
|
||||||
}
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keygen.valid") == 0) {
|
|
||||||
return EXPIRE;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case REPLACE:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "cardedit.genkeys.size") == 0) {
|
|
||||||
return SIZE;
|
|
||||||
}
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keygen.valid") == 0) {
|
|
||||||
return EXPIRE;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case SIZE:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "cardedit.genkeys.size") == 0) {
|
|
||||||
return SIZE2;
|
|
||||||
}
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keygen.valid") == 0) {
|
|
||||||
return EXPIRE;
|
|
||||||
}
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "cardedit.genkeys.algo") == 0) {
|
|
||||||
return KEY_ALGO2;
|
|
||||||
}
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "cardedit.prompt") == 0) {
|
|
||||||
return COMMAND;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case SIZE2:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "cardedit.genkeys.size") == 0) {
|
|
||||||
return SIZE3;
|
|
||||||
}
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keygen.valid") == 0) {
|
|
||||||
return EXPIRE;
|
|
||||||
}
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "cardedit.genkeys.algo") == 0) {
|
|
||||||
return KEY_ALGO3;
|
|
||||||
}
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "cardedit.prompt") == 0) {
|
|
||||||
return COMMAND;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case SIZE3:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keygen.valid") == 0) {
|
|
||||||
return EXPIRE;
|
|
||||||
}
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "cardedit.prompt") == 0) {
|
|
||||||
return COMMAND;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case EXPIRE:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keygen.name") == 0) {
|
|
||||||
return NAME;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case NAME:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keygen.email") == 0) {
|
|
||||||
return EMAIL;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keygen.name") == 0) {
|
|
||||||
err = INV_NAME_ERROR;
|
|
||||||
}
|
|
||||||
return ERROR;
|
|
||||||
case EMAIL:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keygen.comment") == 0) {
|
|
||||||
return COMMENT;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keygen.email") == 0) {
|
|
||||||
err = INV_EMAIL_ERROR;
|
|
||||||
}
|
|
||||||
return ERROR;
|
|
||||||
case COMMENT:
|
|
||||||
if (status == GPGME_STATUS_BACKUP_KEY_CREATED) {
|
|
||||||
std::string sArgs = args;
|
|
||||||
const auto pos = sArgs.rfind(" ");
|
|
||||||
if (pos != std::string::npos) {
|
|
||||||
d->backupFileName = sArgs.substr(pos + 1);
|
|
||||||
return BACKUP_KEY_CREATED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (status == GPGME_STATUS_KEY_CREATED) {
|
|
||||||
return KEY_CREATED;
|
|
||||||
}
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keyedit.prompt") == 0) {
|
|
||||||
return QUIT;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keygen.comment") == 0) {
|
|
||||||
err = INV_COMMENT_ERROR;
|
|
||||||
}
|
|
||||||
return ERROR;
|
|
||||||
case BACKUP_KEY_CREATED:
|
|
||||||
if (status == GPGME_STATUS_KEY_CREATED) {
|
|
||||||
return KEY_CREATED;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case KEY_CREATED:
|
|
||||||
return QUIT;
|
|
||||||
case QUIT:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "cardedit.prompt") == 0) {
|
|
||||||
return QUIT;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case ERROR:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keyedit.prompt") == 0) {
|
|
||||||
return QUIT;
|
|
||||||
}
|
|
||||||
err = lastError();
|
|
||||||
return ERROR;
|
|
||||||
default:
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,95 +0,0 @@
|
|||||||
/*
|
|
||||||
gpggencardkeyinteractor.h - Edit Interactor to generate a key on a card
|
|
||||||
Copyright (C) 2017 by Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GPGMEPP_GPGGENCARDKEYEDITINTERACTOR_H__
|
|
||||||
#define __GPGMEPP_GPGGENCARDKEYEDITINTERACTOR_H__
|
|
||||||
|
|
||||||
#include "editinteractor.h"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace GpgME
|
|
||||||
{
|
|
||||||
|
|
||||||
class GPGMEPP_EXPORT GpgGenCardKeyInteractor: public EditInteractor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/** Edit interactor to generate a key on a smartcard.
|
|
||||||
*
|
|
||||||
* The \a serialnumber argument is intended to safeguard
|
|
||||||
* against accidentally working on the wrong smartcard.
|
|
||||||
*
|
|
||||||
* The edit interactor will fail if the card did not match.
|
|
||||||
*
|
|
||||||
* @param serialnumber: Serialnumber of the intended card.
|
|
||||||
**/
|
|
||||||
explicit GpgGenCardKeyInteractor(const std::string &serialnumber);
|
|
||||||
~GpgGenCardKeyInteractor();
|
|
||||||
|
|
||||||
/** Set the key sizes for the subkeys (default 2048) */
|
|
||||||
void setKeySize(int size);
|
|
||||||
|
|
||||||
void setNameUtf8(const std::string &name);
|
|
||||||
void setEmailUtf8(const std::string &email);
|
|
||||||
|
|
||||||
void setDoBackup(bool value);
|
|
||||||
void setExpiry(const std::string &timeString);
|
|
||||||
|
|
||||||
enum Algo {
|
|
||||||
RSA = 1,
|
|
||||||
ECC = 2,
|
|
||||||
};
|
|
||||||
void setAlgo(Algo algo);
|
|
||||||
|
|
||||||
// the enum values minus 1 have to match the indexes of the curves used by
|
|
||||||
// ask_curve() in gnupg's g10/keygen.c
|
|
||||||
enum Curve {
|
|
||||||
DefaultCurve = 0, // currently Curve25519
|
|
||||||
Curve25519 = 1,
|
|
||||||
Curve448,
|
|
||||||
NISTP256,
|
|
||||||
NISTP384,
|
|
||||||
NISTP521,
|
|
||||||
BrainpoolP256,
|
|
||||||
BrainpoolP384,
|
|
||||||
BrainpoolP512,
|
|
||||||
Secp256k1,
|
|
||||||
LastCurve = Secp256k1,
|
|
||||||
};
|
|
||||||
void setCurve(Curve curve);
|
|
||||||
|
|
||||||
std::string backupFileName() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
const char *action(Error &err) const override;
|
|
||||||
unsigned int nextState(unsigned int statusCode, const char *args, Error &err) const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
class Private;
|
|
||||||
std::shared_ptr<Private> d;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace GpgME
|
|
||||||
|
|
||||||
#endif // __GPGMEPP_GPGGENCARDKEYEDITINTERACTOR_H__
|
|
@ -1,81 +0,0 @@
|
|||||||
/*
|
|
||||||
gpgmefw.h - Forwards declarations for gpgme (0.3 and 0.4)
|
|
||||||
Copyright (C) 2004 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GPGMEPP_GPGMEFW_H__
|
|
||||||
#define __GPGMEPP_GPGMEFW_H__
|
|
||||||
|
|
||||||
struct gpgme_context;
|
|
||||||
typedef gpgme_context *gpgme_ctx_t;
|
|
||||||
|
|
||||||
struct gpgme_data;
|
|
||||||
typedef gpgme_data *gpgme_data_t;
|
|
||||||
|
|
||||||
struct gpgme_io_cbs;
|
|
||||||
|
|
||||||
struct _gpgme_key;
|
|
||||||
typedef struct _gpgme_key *gpgme_key_t;
|
|
||||||
|
|
||||||
struct _gpgme_trust_item;
|
|
||||||
typedef struct _gpgme_trust_item *gpgme_trust_item_t;
|
|
||||||
|
|
||||||
struct _gpgme_subkey;
|
|
||||||
typedef struct _gpgme_subkey *gpgme_sub_key_t;
|
|
||||||
|
|
||||||
struct _gpgme_user_id;
|
|
||||||
typedef struct _gpgme_user_id *gpgme_user_id_t;
|
|
||||||
|
|
||||||
struct _gpgme_key_sig;
|
|
||||||
typedef struct _gpgme_key_sig *gpgme_key_sig_t;
|
|
||||||
|
|
||||||
struct _gpgme_sig_notation;
|
|
||||||
typedef struct _gpgme_sig_notation *gpgme_sig_notation_t;
|
|
||||||
|
|
||||||
struct _gpgme_engine_info;
|
|
||||||
typedef struct _gpgme_engine_info *gpgme_engine_info_t;
|
|
||||||
|
|
||||||
struct _gpgme_op_keylist_result;
|
|
||||||
typedef struct _gpgme_op_keylist_result *gpgme_keylist_result_t;
|
|
||||||
|
|
||||||
struct _gpgme_recipient;
|
|
||||||
typedef struct _gpgme_recipient *gpgme_recipient_t;
|
|
||||||
|
|
||||||
struct gpgme_conf_opt;
|
|
||||||
typedef struct gpgme_conf_opt *gpgme_conf_opt_t;
|
|
||||||
|
|
||||||
struct gpgme_conf_comp;
|
|
||||||
typedef struct gpgme_conf_comp *gpgme_conf_comp_t;
|
|
||||||
|
|
||||||
struct gpgme_conf_arg;
|
|
||||||
typedef struct gpgme_conf_arg *gpgme_conf_arg_t;
|
|
||||||
|
|
||||||
struct _gpgme_tofu_info;
|
|
||||||
typedef struct _gpgme_tofu_info *gpgme_tofu_info_t;
|
|
||||||
|
|
||||||
struct _gpgme_op_query_swdb_result;
|
|
||||||
typedef struct _gpgme_op_query_swdb_result *gpgme_query_swdb_result_t;
|
|
||||||
|
|
||||||
struct _gpgme_revocation_key;
|
|
||||||
typedef struct _gpgme_revocation_key *gpgme_revocation_key_t;
|
|
||||||
|
|
||||||
#endif // __GPGMEPP_GPGMEFW_H__
|
|
@ -1,74 +0,0 @@
|
|||||||
/*gpgmepp_export.h - Export macros for gpgmepp
|
|
||||||
Copyright (C) 2016, by Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GPGMEPP_EXPORT_H
|
|
||||||
#define GPGMEPP_EXPORT_H
|
|
||||||
|
|
||||||
#ifdef GPGMEPP_STATIC_DEFINE
|
|
||||||
# define GPGMEPP_EXPORT
|
|
||||||
# define GPGMEPP_NO_EXPORT
|
|
||||||
#else
|
|
||||||
# ifndef GPGMEPP_EXPORT
|
|
||||||
# ifdef BUILDING_GPGMEPP
|
|
||||||
/* We are building this library */
|
|
||||||
# ifdef WIN32
|
|
||||||
# define GPGMEPP_EXPORT __declspec(dllexport)
|
|
||||||
# else
|
|
||||||
# define GPGMEPP_EXPORT __attribute__((visibility("default")))
|
|
||||||
# endif
|
|
||||||
# else
|
|
||||||
/* We are using this library */
|
|
||||||
# ifdef WIN32
|
|
||||||
# define GPGMEPP_EXPORT __declspec(dllimport)
|
|
||||||
# else
|
|
||||||
# define GPGMEPP_EXPORT __attribute__((visibility("default")))
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifndef GPGMEPP_NO_EXPORT
|
|
||||||
# ifdef WIN32
|
|
||||||
# define GPGMEPP_NO_EXPORT
|
|
||||||
# else
|
|
||||||
# define GPGMEPP_NO_EXPORT __attribute__((visibility("hidden")))
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef GPGMEPP_DEPRECATED
|
|
||||||
# define GPGMEPP_DEPRECATED __attribute__ ((__deprecated__))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef GPGMEPP_DEPRECATED_EXPORT
|
|
||||||
# define GPGMEPP_DEPRECATED_EXPORT GPGMEPP_EXPORT GPGMEPP_DEPRECATED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef GPGMEPP_DEPRECATED_NO_EXPORT
|
|
||||||
# define GPGMEPP_DEPRECATED_NO_EXPORT GPGMEPP_NO_EXPORT GPGMEPP_DEPRECATED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define DEFINE_NO_DEPRECATED 0
|
|
||||||
#if DEFINE_NO_DEPRECATED
|
|
||||||
# define GPGMEPP_NO_DEPRECATED
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,31 +0,0 @@
|
|||||||
/*gpgmepp_version.h - Version macros for gpgmepp
|
|
||||||
Copyright (C) 2016, Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef GPGMEPP_VERSION_H
|
|
||||||
#define GPGMEPP_VERSION_H
|
|
||||||
|
|
||||||
#define GPGMEPP_VERSION_STRING "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_MICRO@"
|
|
||||||
#define GPGMEPP_VERSION_MAJOR @VERSION_MAJOR@
|
|
||||||
#define GPGMEPP_VERSION_MINOR @VERSION_MINOR@
|
|
||||||
#define GPGMEPP_VERSION_PATCH @VERSION_MICRO@
|
|
||||||
#define GPGMEPP_VERSION ((@VERSION_MAJOR@<<16)|(@VERSION_MINOR@<<8)|(@VERSION_MICRO@))
|
|
||||||
#endif
|
|
@ -1,207 +0,0 @@
|
|||||||
/*
|
|
||||||
gpgrevokekeyeditinteractor.cpp - Edit Interactor to revoke own OpenPGP keys
|
|
||||||
Copyright (c) 2022 g10 Code GmbH
|
|
||||||
Software engineering by Ingo Klöcker <dev@ingo-kloecker.de>
|
|
||||||
|
|
||||||
This file is part of GPGME++.
|
|
||||||
|
|
||||||
GPGME++ is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "gpgrevokekeyeditinteractor.h"
|
|
||||||
|
|
||||||
#include "error.h"
|
|
||||||
|
|
||||||
#include <gpgme.h>
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
// avoid conflict (msvc)
|
|
||||||
#ifdef ERROR
|
|
||||||
# undef ERROR
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace GpgME;
|
|
||||||
|
|
||||||
class GpgRevokeKeyEditInteractor::Private
|
|
||||||
{
|
|
||||||
enum {
|
|
||||||
START = EditInteractor::StartState,
|
|
||||||
COMMAND,
|
|
||||||
CONFIRM_REVOKING_ENTIRE_KEY,
|
|
||||||
REASON_CODE,
|
|
||||||
REASON_TEXT,
|
|
||||||
// all these free slots belong to REASON_TEXT, too; we increase state()
|
|
||||||
// by one for each line of text, so that action() is called
|
|
||||||
REASON_TEXT_DONE = REASON_TEXT + 1000,
|
|
||||||
CONFIRM_REASON,
|
|
||||||
QUIT,
|
|
||||||
CONFIRM_SAVE,
|
|
||||||
|
|
||||||
ERROR = EditInteractor::ErrorState
|
|
||||||
};
|
|
||||||
|
|
||||||
GpgRevokeKeyEditInteractor *const q = nullptr;
|
|
||||||
|
|
||||||
public:
|
|
||||||
Private(GpgRevokeKeyEditInteractor *q)
|
|
||||||
: q{q}
|
|
||||||
, reasonCode{"0"}
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *action(Error &err) const;
|
|
||||||
unsigned int nextState(unsigned int statusCode, const char *args, Error &err);
|
|
||||||
|
|
||||||
std::string reasonCode;
|
|
||||||
std::vector<std::string> reasonLines;
|
|
||||||
int nextLine = -1;
|
|
||||||
};
|
|
||||||
|
|
||||||
const char *GpgRevokeKeyEditInteractor::Private::action(Error &err) const
|
|
||||||
{
|
|
||||||
switch (const auto state = q->state()) {
|
|
||||||
case COMMAND:
|
|
||||||
return "revkey";
|
|
||||||
case CONFIRM_REVOKING_ENTIRE_KEY:
|
|
||||||
return "Y";
|
|
||||||
case REASON_CODE:
|
|
||||||
return reasonCode.c_str();
|
|
||||||
case REASON_TEXT_DONE:
|
|
||||||
return "";
|
|
||||||
case CONFIRM_REASON:
|
|
||||||
return "Y";
|
|
||||||
case QUIT:
|
|
||||||
return "quit";
|
|
||||||
case CONFIRM_SAVE:
|
|
||||||
return "Y";
|
|
||||||
case START:
|
|
||||||
return nullptr;
|
|
||||||
default:
|
|
||||||
if (state >= REASON_TEXT && state < REASON_TEXT_DONE) {
|
|
||||||
return reasonLines[nextLine].c_str();
|
|
||||||
}
|
|
||||||
// fall through
|
|
||||||
case ERROR:
|
|
||||||
err = Error::fromCode(GPG_ERR_GENERAL);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int GpgRevokeKeyEditInteractor::Private::nextState(unsigned int status, const char *args, Error &err)
|
|
||||||
{
|
|
||||||
using std::strcmp;
|
|
||||||
|
|
||||||
static const Error GENERAL_ERROR = Error::fromCode(GPG_ERR_GENERAL);
|
|
||||||
|
|
||||||
switch (const auto state = q->state()) {
|
|
||||||
case START:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keyedit.prompt") == 0) {
|
|
||||||
return COMMAND;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case COMMAND:
|
|
||||||
if (status == GPGME_STATUS_GET_BOOL &&
|
|
||||||
strcmp(args, "keyedit.revoke.subkey.okay") == 0) {
|
|
||||||
return CONFIRM_REVOKING_ENTIRE_KEY;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case CONFIRM_REVOKING_ENTIRE_KEY:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "ask_revocation_reason.code") == 0) {
|
|
||||||
return REASON_CODE;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case REASON_CODE:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "ask_revocation_reason.text") == 0) {
|
|
||||||
nextLine++;
|
|
||||||
return static_cast<std::size_t>(nextLine) < reasonLines.size() ? REASON_TEXT : REASON_TEXT_DONE;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
default:
|
|
||||||
if (state >= REASON_TEXT && state < REASON_TEXT_DONE) {
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "ask_revocation_reason.text") == 0) {
|
|
||||||
nextLine++;
|
|
||||||
return static_cast<std::size_t>(nextLine) < reasonLines.size() ? state + 1 : REASON_TEXT_DONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case REASON_TEXT_DONE:
|
|
||||||
if (status == GPGME_STATUS_GET_BOOL &&
|
|
||||||
strcmp(args, "ask_revocation_reason.okay") == 0) {
|
|
||||||
return CONFIRM_REASON;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case CONFIRM_REASON:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keyedit.prompt") == 0) {
|
|
||||||
return QUIT;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case QUIT:
|
|
||||||
if (status == GPGME_STATUS_GET_BOOL &&
|
|
||||||
strcmp(args, "keyedit.save.okay") == 0) {
|
|
||||||
return CONFIRM_SAVE;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case ERROR:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keyedit.prompt") == 0) {
|
|
||||||
return QUIT;
|
|
||||||
}
|
|
||||||
err = q->lastError();
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgRevokeKeyEditInteractor::GpgRevokeKeyEditInteractor()
|
|
||||||
: EditInteractor{}
|
|
||||||
, d{new Private{this}}
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgRevokeKeyEditInteractor::~GpgRevokeKeyEditInteractor() = default;
|
|
||||||
|
|
||||||
void GpgRevokeKeyEditInteractor::setReason(RevocationReason reason, const std::vector<std::string> &description)
|
|
||||||
{
|
|
||||||
d->reasonCode = std::to_string(static_cast<int>(reason));
|
|
||||||
d->reasonLines = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *GpgRevokeKeyEditInteractor::action(Error &err) const
|
|
||||||
{
|
|
||||||
return d->action(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int GpgRevokeKeyEditInteractor::nextState(unsigned int status, const char *args, Error &err) const
|
|
||||||
{
|
|
||||||
return d->nextState(status, args, err);
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
/*
|
|
||||||
gpgrevokekeyeditinteractor.h - Edit Interactor to revoke own OpenPGP keys
|
|
||||||
Copyright (c) 2022 g10 Code GmbH
|
|
||||||
Software engineering by Ingo Klöcker <dev@ingo-kloecker.de>
|
|
||||||
|
|
||||||
This file is part of GPGME++.
|
|
||||||
|
|
||||||
GPGME++ is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GPGMEPP_GPGREVOKEKEYEDITINTERACTOR_H__
|
|
||||||
#define __GPGMEPP_GPGREVOKEKEYEDITINTERACTOR_H__
|
|
||||||
|
|
||||||
#include "editinteractor.h"
|
|
||||||
#include "global.h"
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace GpgME
|
|
||||||
{
|
|
||||||
|
|
||||||
/** Edit interactor to revoke the key a key edit operation is working on.
|
|
||||||
* Supports revocation of own keys only. */
|
|
||||||
class GPGMEPP_EXPORT GpgRevokeKeyEditInteractor : public EditInteractor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
GpgRevokeKeyEditInteractor();
|
|
||||||
~GpgRevokeKeyEditInteractor() override;
|
|
||||||
|
|
||||||
/** Sets the reason for the revocation. The reason defaults to \c Unspecified.
|
|
||||||
* \a description can be used for adding a comment for the revocation. The
|
|
||||||
* individual elements of \a description must be non-empty strings and they
|
|
||||||
* must not contain any endline characters.
|
|
||||||
*/
|
|
||||||
void setReason(RevocationReason reason, const std::vector<std::string> &description = {});
|
|
||||||
|
|
||||||
private:
|
|
||||||
const char *action(Error &err) const override;
|
|
||||||
unsigned int nextState(unsigned int statusCode, const char *args, Error &err) const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
class GPGMEPP_NO_EXPORT Private;
|
|
||||||
const std::unique_ptr<Private> d;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace GpgME
|
|
||||||
|
|
||||||
#endif // __GPGMEPP_GPGREVOKEKEYEDITINTERACTOR_H__
|
|
@ -1,143 +0,0 @@
|
|||||||
/*
|
|
||||||
gpgsetexpirytimeeditinteractor.cpp - Edit Interactor to change the expiry time of an OpenPGP key
|
|
||||||
Copyright (C) 2007 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "gpgsetexpirytimeeditinteractor.h"
|
|
||||||
#include "error.h"
|
|
||||||
|
|
||||||
#include <gpgme.h>
|
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
using std::strcmp;
|
|
||||||
|
|
||||||
// avoid conflict (msvc)
|
|
||||||
#ifdef ERROR
|
|
||||||
# undef ERROR
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace GpgME;
|
|
||||||
|
|
||||||
GpgSetExpiryTimeEditInteractor::GpgSetExpiryTimeEditInteractor(const std::string &t)
|
|
||||||
: EditInteractor(),
|
|
||||||
m_strtime(t)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgSetExpiryTimeEditInteractor::~GpgSetExpiryTimeEditInteractor() {}
|
|
||||||
|
|
||||||
// work around --enable-final
|
|
||||||
namespace GpgSetExpiryTimeEditInteractor_Private
|
|
||||||
{
|
|
||||||
enum {
|
|
||||||
START = EditInteractor::StartState,
|
|
||||||
COMMAND,
|
|
||||||
DATE,
|
|
||||||
QUIT,
|
|
||||||
SAVE,
|
|
||||||
|
|
||||||
ERROR = EditInteractor::ErrorState
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *GpgSetExpiryTimeEditInteractor::action(Error &err) const
|
|
||||||
{
|
|
||||||
|
|
||||||
using namespace GpgSetExpiryTimeEditInteractor_Private;
|
|
||||||
|
|
||||||
switch (state()) {
|
|
||||||
case COMMAND:
|
|
||||||
return "expire";
|
|
||||||
case DATE:
|
|
||||||
return m_strtime.c_str();
|
|
||||||
case QUIT:
|
|
||||||
return "quit";
|
|
||||||
case SAVE:
|
|
||||||
return "Y";
|
|
||||||
case START:
|
|
||||||
case ERROR:
|
|
||||||
return nullptr;
|
|
||||||
default:
|
|
||||||
err = Error::fromCode(GPG_ERR_GENERAL);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int GpgSetExpiryTimeEditInteractor::nextState(unsigned int status, const char *args, Error &err) const
|
|
||||||
{
|
|
||||||
|
|
||||||
static const Error GENERAL_ERROR = Error::fromCode(GPG_ERR_GENERAL);
|
|
||||||
static const Error INV_TIME_ERROR = Error::fromCode(GPG_ERR_INV_TIME);
|
|
||||||
|
|
||||||
using namespace GpgSetExpiryTimeEditInteractor_Private;
|
|
||||||
|
|
||||||
switch (state()) {
|
|
||||||
case START:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keyedit.prompt") == 0) {
|
|
||||||
return COMMAND;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case COMMAND:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keygen.valid") == 0) {
|
|
||||||
return DATE;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case DATE:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keyedit.prompt") == 0) {
|
|
||||||
return QUIT;
|
|
||||||
} else if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keygen.valid")) {
|
|
||||||
err = INV_TIME_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case QUIT:
|
|
||||||
if (status == GPGME_STATUS_GET_BOOL &&
|
|
||||||
strcmp(args, "keyedit.save.okay") == 0) {
|
|
||||||
return SAVE;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case ERROR:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keyedit.prompt") == 0) {
|
|
||||||
return QUIT;
|
|
||||||
}
|
|
||||||
err = lastError();
|
|
||||||
return ERROR;
|
|
||||||
default:
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
gpgsetexpirytimeeditinteractor.h - Edit Interactor to change the expiry time of an OpenPGP key
|
|
||||||
Copyright (C) 2007 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GPGMEPP_GPGSETEXPIRYTIMEEDITINTERACTOR_H__
|
|
||||||
#define __GPGMEPP_GPGSETEXPIRYTIMEEDITINTERACTOR_H__
|
|
||||||
|
|
||||||
#include "editinteractor.h"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace GpgME
|
|
||||||
{
|
|
||||||
|
|
||||||
class GPGMEPP_EXPORT GpgSetExpiryTimeEditInteractor : public EditInteractor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit GpgSetExpiryTimeEditInteractor(const std::string &timeString = "0");
|
|
||||||
~GpgSetExpiryTimeEditInteractor();
|
|
||||||
|
|
||||||
private:
|
|
||||||
const char *action(Error &err) const override;
|
|
||||||
unsigned int nextState(unsigned int statusCode, const char *args, Error &err) const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
const std::string m_strtime;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace GpgME
|
|
||||||
|
|
||||||
#endif // __GPGMEPP_GPGSETEXPIRYTIMEEDITINTERACTOR_H___
|
|
@ -1,153 +0,0 @@
|
|||||||
/*
|
|
||||||
gpgsetownertrusteditinteractor.cpp - Edit Interactor to change the expiry time of an OpenPGP key
|
|
||||||
Copyright (C) 2007 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "gpgsetownertrusteditinteractor.h"
|
|
||||||
#include "error.h"
|
|
||||||
|
|
||||||
#include <gpgme.h>
|
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
using std::strcmp;
|
|
||||||
|
|
||||||
// avoid conflict (msvc)
|
|
||||||
#ifdef ERROR
|
|
||||||
# undef ERROR
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace GpgME;
|
|
||||||
|
|
||||||
GpgSetOwnerTrustEditInteractor::GpgSetOwnerTrustEditInteractor(Key::OwnerTrust ot)
|
|
||||||
: EditInteractor(),
|
|
||||||
m_ownertrust(ot)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgSetOwnerTrustEditInteractor::~GpgSetOwnerTrustEditInteractor() {}
|
|
||||||
|
|
||||||
// work around --enable-final
|
|
||||||
namespace GpgSetOwnerTrustEditInteractor_Private
|
|
||||||
{
|
|
||||||
enum {
|
|
||||||
START = EditInteractor::StartState,
|
|
||||||
COMMAND,
|
|
||||||
VALUE,
|
|
||||||
REALLY_ULTIMATE,
|
|
||||||
QUIT,
|
|
||||||
SAVE,
|
|
||||||
|
|
||||||
ERROR = EditInteractor::ErrorState
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *GpgSetOwnerTrustEditInteractor::action(Error &err) const
|
|
||||||
{
|
|
||||||
static const char truststrings[][2] = { "1", "1", "2", "3", "4", "5" };
|
|
||||||
|
|
||||||
using namespace GpgSetOwnerTrustEditInteractor_Private;
|
|
||||||
|
|
||||||
switch (state()) {
|
|
||||||
case COMMAND:
|
|
||||||
return "trust";
|
|
||||||
case VALUE:
|
|
||||||
return truststrings[m_ownertrust];
|
|
||||||
case REALLY_ULTIMATE:
|
|
||||||
return "Y";
|
|
||||||
case QUIT:
|
|
||||||
return "quit";
|
|
||||||
case SAVE:
|
|
||||||
return "Y";
|
|
||||||
case START:
|
|
||||||
case ERROR:
|
|
||||||
return nullptr;
|
|
||||||
default:
|
|
||||||
err = Error::fromCode(GPG_ERR_GENERAL);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int GpgSetOwnerTrustEditInteractor::nextState(unsigned int status, const char *args, Error &err) const
|
|
||||||
{
|
|
||||||
|
|
||||||
static const Error GENERAL_ERROR = Error::fromCode(GPG_ERR_GENERAL);
|
|
||||||
//static const Error INV_TIME_ERROR = Error::fromCode( GPG_ERR_INV_TIME );
|
|
||||||
|
|
||||||
using namespace GpgSetOwnerTrustEditInteractor_Private;
|
|
||||||
|
|
||||||
switch (state()) {
|
|
||||||
case START:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keyedit.prompt") == 0) {
|
|
||||||
return COMMAND;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case COMMAND:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "edit_ownertrust.value") == 0) {
|
|
||||||
return VALUE;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case VALUE:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keyedit.prompt") == 0) {
|
|
||||||
return QUIT;
|
|
||||||
} else if (status == GPGME_STATUS_GET_BOOL &&
|
|
||||||
strcmp(args, "edit_ownertrust.set_ultimate.okay") == 0) {
|
|
||||||
return REALLY_ULTIMATE;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case REALLY_ULTIMATE:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keyedit.prompt") == 0) {
|
|
||||||
return QUIT;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case QUIT:
|
|
||||||
if (status == GPGME_STATUS_GET_BOOL &&
|
|
||||||
strcmp(args, "keyedit.save.okay") == 0) {
|
|
||||||
return SAVE;
|
|
||||||
}
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
case ERROR:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keyedit.prompt") == 0) {
|
|
||||||
return QUIT;
|
|
||||||
}
|
|
||||||
err = lastError();
|
|
||||||
return ERROR;
|
|
||||||
default:
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
};
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
gpgsetownertrusteditinteractor.h - Edit Interactor to change the owner trust of an OpenPGP key
|
|
||||||
Copyright (C) 2007 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GPGMEPP_GPGSETOWNERTRUSTEDITINTERACTOR_H__
|
|
||||||
#define __GPGMEPP_GPGSETOWNERTRUSTEDITINTERACTOR_H__
|
|
||||||
|
|
||||||
#include "editinteractor.h"
|
|
||||||
#include "key.h"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace GpgME
|
|
||||||
{
|
|
||||||
|
|
||||||
class GPGMEPP_EXPORT GpgSetOwnerTrustEditInteractor : public EditInteractor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit GpgSetOwnerTrustEditInteractor(Key::OwnerTrust ownertrust);
|
|
||||||
~GpgSetOwnerTrustEditInteractor();
|
|
||||||
|
|
||||||
private:
|
|
||||||
const char *action(Error &err) const override;
|
|
||||||
unsigned int nextState(unsigned int statusCode, const char *args, Error &err) const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
const Key::OwnerTrust m_ownertrust;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace GpgME
|
|
||||||
|
|
||||||
#endif // __GPGMEPP_GPGSETOWNERTRUSTEDITINTERACTOR_H__
|
|
@ -1,395 +0,0 @@
|
|||||||
/*
|
|
||||||
gpgsignkeyeditinteractor.cpp - Edit Interactor to change the expiry time of an OpenPGP key
|
|
||||||
Copyright (C) 2007 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "gpgsignkeyeditinteractor.h"
|
|
||||||
#include "error.h"
|
|
||||||
#include "key.h"
|
|
||||||
|
|
||||||
#include <gpgme.h>
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <string>
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
#include <cassert>
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
using std::strcmp;
|
|
||||||
|
|
||||||
// avoid conflict (msvc)
|
|
||||||
#ifdef ERROR
|
|
||||||
# undef ERROR
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#undef snprintf
|
|
||||||
#define snprintf _snprintf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace GpgME;
|
|
||||||
|
|
||||||
class GpgSignKeyEditInteractor::Private
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Private();
|
|
||||||
|
|
||||||
std::string scratch;
|
|
||||||
bool started;
|
|
||||||
int options;
|
|
||||||
std::vector<unsigned int> userIDs;
|
|
||||||
std::vector<unsigned int>::const_iterator currentId, nextId;
|
|
||||||
unsigned int checkLevel;
|
|
||||||
bool dupeOk;
|
|
||||||
Key key;
|
|
||||||
struct {
|
|
||||||
TrustSignatureTrust trust;
|
|
||||||
std::string depth;
|
|
||||||
std::string scope;
|
|
||||||
} trustSignature;
|
|
||||||
|
|
||||||
const char *command() const
|
|
||||||
{
|
|
||||||
const bool local = (options & Exportable) == 0;
|
|
||||||
const bool nonRevoc = options & NonRevocable;
|
|
||||||
const bool trust = options & Trust;
|
|
||||||
//TODO: check if all combinations are valid
|
|
||||||
if (local && nonRevoc && trust) {
|
|
||||||
return "ltnrsign";
|
|
||||||
}
|
|
||||||
if (local && nonRevoc) {
|
|
||||||
return "lnrsign";
|
|
||||||
}
|
|
||||||
if (local && trust) {
|
|
||||||
return "ltsign";
|
|
||||||
}
|
|
||||||
if (local) {
|
|
||||||
return "lsign";
|
|
||||||
}
|
|
||||||
if (nonRevoc && trust) {
|
|
||||||
return "tnrsign";
|
|
||||||
}
|
|
||||||
if (nonRevoc) {
|
|
||||||
return "nrsign";
|
|
||||||
}
|
|
||||||
if (trust) {
|
|
||||||
return "tsign";
|
|
||||||
}
|
|
||||||
return "sign";
|
|
||||||
}
|
|
||||||
|
|
||||||
bool signAll() const
|
|
||||||
{
|
|
||||||
return userIDs.empty();
|
|
||||||
}
|
|
||||||
unsigned int nextUserID()
|
|
||||||
{
|
|
||||||
assert(nextId != userIDs.end());
|
|
||||||
currentId = nextId++;
|
|
||||||
return currentUserID();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool allUserIDsListed() const
|
|
||||||
{
|
|
||||||
return nextId == userIDs.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int currentUserID() const
|
|
||||||
{
|
|
||||||
assert(currentId != userIDs.end());
|
|
||||||
return *currentId + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GpgSignKeyEditInteractor::Private::Private()
|
|
||||||
:
|
|
||||||
started(false),
|
|
||||||
options(0),
|
|
||||||
userIDs(),
|
|
||||||
currentId(),
|
|
||||||
nextId(),
|
|
||||||
checkLevel(0),
|
|
||||||
dupeOk(false),
|
|
||||||
trustSignature{TrustSignatureTrust::None, "0", {}}
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgSignKeyEditInteractor::GpgSignKeyEditInteractor()
|
|
||||||
: EditInteractor(), d(new Private)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
GpgSignKeyEditInteractor::~GpgSignKeyEditInteractor()
|
|
||||||
{
|
|
||||||
delete d;
|
|
||||||
}
|
|
||||||
|
|
||||||
// work around --enable-final
|
|
||||||
namespace GpgSignKeyEditInteractor_Private
|
|
||||||
{
|
|
||||||
enum SignKeyState {
|
|
||||||
START = EditInteractor::StartState,
|
|
||||||
COMMAND,
|
|
||||||
UIDS_ANSWER_SIGN_ALL,
|
|
||||||
UIDS_LIST_SEPARATELY,
|
|
||||||
// all these free slots belong to UIDS_LIST_SEPARATELY, too
|
|
||||||
// (we increase state() by one for each UID, so that action() is called)
|
|
||||||
UIDS_LIST_SEPARATELY_DONE = 1000000,
|
|
||||||
SET_EXPIRE,
|
|
||||||
SET_CHECK_LEVEL,
|
|
||||||
SET_TRUST_VALUE,
|
|
||||||
SET_TRUST_DEPTH,
|
|
||||||
SET_TRUST_REGEXP,
|
|
||||||
CONFIRM,
|
|
||||||
CONFIRM2,
|
|
||||||
DUPE_OK,
|
|
||||||
DUPE_OK2,
|
|
||||||
REJECT_SIGN_EXPIRED,
|
|
||||||
QUIT,
|
|
||||||
SAVE,
|
|
||||||
ERROR = EditInteractor::ErrorState
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef std::map<std::tuple<SignKeyState, unsigned int, std::string>, SignKeyState> TransitionMap;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *answer(bool b)
|
|
||||||
{
|
|
||||||
return b ? "Y" : "N";
|
|
||||||
}
|
|
||||||
|
|
||||||
static GpgSignKeyEditInteractor_Private::TransitionMap makeTable()
|
|
||||||
{
|
|
||||||
using namespace GpgSignKeyEditInteractor_Private;
|
|
||||||
TransitionMap tab;
|
|
||||||
const unsigned int GET_BOOL = GPGME_STATUS_GET_BOOL;
|
|
||||||
const unsigned int GET_LINE = GPGME_STATUS_GET_LINE;
|
|
||||||
#define addEntry( s1, status, str, s2 ) tab[std::make_tuple( s1, status, str)] = s2
|
|
||||||
addEntry(START, GET_LINE, "keyedit.prompt", COMMAND);
|
|
||||||
addEntry(COMMAND, GET_BOOL, "keyedit.sign_all.okay", UIDS_ANSWER_SIGN_ALL);
|
|
||||||
addEntry(COMMAND, GET_BOOL, "sign_uid.expired_okay", REJECT_SIGN_EXPIRED);
|
|
||||||
addEntry(COMMAND, GET_BOOL, "sign_uid.okay", CONFIRM);
|
|
||||||
addEntry(COMMAND, GET_BOOL, "sign_uid.local_promote_okay", CONFIRM2);
|
|
||||||
addEntry(COMMAND, GET_BOOL, "sign_uid.dupe_okay", DUPE_OK);
|
|
||||||
addEntry(COMMAND, GET_LINE, "trustsig_prompt.trust_value", SET_TRUST_VALUE);
|
|
||||||
addEntry(UIDS_ANSWER_SIGN_ALL, GET_BOOL, "sign_uid.okay", CONFIRM);
|
|
||||||
addEntry(UIDS_ANSWER_SIGN_ALL, GET_BOOL, "sign_uid.dupe_okay", DUPE_OK);
|
|
||||||
addEntry(UIDS_ANSWER_SIGN_ALL, GET_LINE, "sign_uid.expire", SET_EXPIRE);
|
|
||||||
addEntry(UIDS_ANSWER_SIGN_ALL, GET_LINE, "sign_uid.class", SET_CHECK_LEVEL);
|
|
||||||
addEntry(UIDS_ANSWER_SIGN_ALL, GET_LINE, "trustsig_prompt.trust_value", SET_TRUST_VALUE);
|
|
||||||
addEntry(SET_TRUST_VALUE, GET_LINE, "trustsig_prompt.trust_depth", SET_TRUST_DEPTH);
|
|
||||||
addEntry(SET_TRUST_DEPTH, GET_LINE, "trustsig_prompt.trust_regexp", SET_TRUST_REGEXP);
|
|
||||||
addEntry(SET_TRUST_REGEXP, GET_BOOL, "sign_uid.okay", CONFIRM);
|
|
||||||
addEntry(SET_CHECK_LEVEL, GET_BOOL, "sign_uid.okay", CONFIRM);
|
|
||||||
addEntry(SET_EXPIRE, GET_BOOL, "sign_uid.class", SET_CHECK_LEVEL);
|
|
||||||
addEntry(CONFIRM, GET_BOOL, "sign_uid.local_promote_okay", CONFIRM);
|
|
||||||
addEntry(DUPE_OK, GET_BOOL, "sign_uid.okay", CONFIRM);
|
|
||||||
addEntry(DUPE_OK2, GET_BOOL, "sign_uid.okay", CONFIRM);
|
|
||||||
addEntry(DUPE_OK, GET_LINE, "trustsig_prompt.trust_value", SET_TRUST_VALUE);
|
|
||||||
addEntry(DUPE_OK2, GET_LINE, "trustsig_prompt.trust_value", SET_TRUST_VALUE);
|
|
||||||
addEntry(CONFIRM, GET_BOOL, "sign_uid.okay", CONFIRM);
|
|
||||||
addEntry(CONFIRM2, GET_BOOL, "sign_uid.okay", CONFIRM);
|
|
||||||
addEntry(CONFIRM, GET_LINE, "keyedit.prompt", COMMAND);
|
|
||||||
addEntry(CONFIRM, GET_LINE, "trustsig_prompt.trust_value", SET_TRUST_VALUE);
|
|
||||||
addEntry(CONFIRM, GET_LINE, "sign_uid.expire", SET_EXPIRE);
|
|
||||||
addEntry(CONFIRM, GET_LINE, "sign_uid.class", SET_CHECK_LEVEL);
|
|
||||||
addEntry(UIDS_LIST_SEPARATELY_DONE, GET_BOOL, "sign_uid.local_promote_okay", CONFIRM);
|
|
||||||
addEntry(UIDS_LIST_SEPARATELY_DONE, GET_LINE, "keyedit.prompt", COMMAND);
|
|
||||||
addEntry(UIDS_LIST_SEPARATELY_DONE, GET_LINE, "trustsig_prompt.trust_value", SET_TRUST_VALUE);
|
|
||||||
addEntry(UIDS_LIST_SEPARATELY_DONE, GET_LINE, "sign_uid.expire", SET_EXPIRE);
|
|
||||||
addEntry(UIDS_LIST_SEPARATELY_DONE, GET_LINE, "sign_uid.class", SET_CHECK_LEVEL);
|
|
||||||
addEntry(UIDS_LIST_SEPARATELY_DONE, GET_BOOL, "sign_uid.okay", CONFIRM);
|
|
||||||
addEntry(UIDS_LIST_SEPARATELY_DONE, GET_BOOL, "sign_uid.dupe_okay", DUPE_OK);
|
|
||||||
addEntry(DUPE_OK, GET_BOOL, "sign_uid.dupe_okay", DUPE_OK2);
|
|
||||||
addEntry(DUPE_OK2, GET_BOOL, "sign_uid.dupe_okay", DUPE_OK);
|
|
||||||
addEntry(CONFIRM, GET_LINE, "keyedit.prompt", QUIT);
|
|
||||||
addEntry(REJECT_SIGN_EXPIRED, GET_LINE, "keyedit.prompt", QUIT);
|
|
||||||
addEntry(ERROR, GET_LINE, "keyedit.prompt", QUIT);
|
|
||||||
addEntry(QUIT, GET_BOOL, "keyedit.save.okay", SAVE);
|
|
||||||
#undef addEntry
|
|
||||||
return tab;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *GpgSignKeyEditInteractor::action(Error &err) const
|
|
||||||
{
|
|
||||||
static const char check_level_strings[][2] = { "0", "1", "2", "3" };
|
|
||||||
using namespace GpgSignKeyEditInteractor_Private;
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
switch (const unsigned int st = state()) {
|
|
||||||
case COMMAND:
|
|
||||||
return d->command();
|
|
||||||
case UIDS_ANSWER_SIGN_ALL:
|
|
||||||
return answer(d->signAll());
|
|
||||||
case UIDS_LIST_SEPARATELY_DONE:
|
|
||||||
return d->command();
|
|
||||||
case SET_EXPIRE:
|
|
||||||
return answer(true);
|
|
||||||
case SET_TRUST_VALUE:
|
|
||||||
return d->trustSignature.trust == TrustSignatureTrust::Partial ? "1" : "2";
|
|
||||||
case SET_TRUST_DEPTH:
|
|
||||||
return d->trustSignature.depth.c_str();
|
|
||||||
case SET_TRUST_REGEXP:
|
|
||||||
return d->trustSignature.scope.c_str();
|
|
||||||
case SET_CHECK_LEVEL:
|
|
||||||
return check_level_strings[d->checkLevel];
|
|
||||||
case DUPE_OK:
|
|
||||||
case DUPE_OK2:
|
|
||||||
return answer(d->dupeOk);
|
|
||||||
case CONFIRM2:
|
|
||||||
case CONFIRM:
|
|
||||||
return answer(true);
|
|
||||||
case REJECT_SIGN_EXPIRED:
|
|
||||||
err = Error::fromCode(GPG_ERR_KEY_EXPIRED);
|
|
||||||
return answer(false);
|
|
||||||
case QUIT:
|
|
||||||
return "quit";
|
|
||||||
case SAVE:
|
|
||||||
return answer(true);
|
|
||||||
default:
|
|
||||||
if (st >= UIDS_LIST_SEPARATELY && st < UIDS_LIST_SEPARATELY_DONE) {
|
|
||||||
std::stringstream ss;
|
|
||||||
auto nextID = d->nextUserID();
|
|
||||||
const char *hash;
|
|
||||||
assert (nextID);
|
|
||||||
if (!d->key.isNull() && (hash = d->key.userID(nextID - 1).uidhash())) {
|
|
||||||
/* Prefer uidhash if it is available as it might happen
|
|
||||||
* that uidattrs break the ordering of the uids in the
|
|
||||||
* edit-key interface */
|
|
||||||
ss << "uid " << hash;
|
|
||||||
} else {
|
|
||||||
ss << nextID;
|
|
||||||
}
|
|
||||||
d->scratch = ss.str();
|
|
||||||
return d->scratch.c_str();
|
|
||||||
}
|
|
||||||
// fall through
|
|
||||||
case ERROR:
|
|
||||||
err = Error::fromCode(GPG_ERR_GENERAL);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int GpgSignKeyEditInteractor::nextState(unsigned int status, const char *args, Error &err) const
|
|
||||||
{
|
|
||||||
d->started = true;
|
|
||||||
using namespace GpgSignKeyEditInteractor_Private;
|
|
||||||
static const Error GENERAL_ERROR = Error::fromCode(GPG_ERR_GENERAL);
|
|
||||||
//static const Error INV_TIME_ERROR = Error::fromCode( GPG_ERR_INV_TIME );
|
|
||||||
static const TransitionMap table(makeTable());
|
|
||||||
|
|
||||||
using namespace GpgSignKeyEditInteractor_Private;
|
|
||||||
|
|
||||||
//lookup transition in map
|
|
||||||
const TransitionMap::const_iterator it = table.find(std::make_tuple(static_cast<SignKeyState>(state()), status, std::string(args)));
|
|
||||||
if (it != table.end()) {
|
|
||||||
return it->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
//handle cases that cannot be handled via the map
|
|
||||||
switch (const unsigned int st = state()) {
|
|
||||||
case UIDS_ANSWER_SIGN_ALL:
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keyedit.prompt") == 0) {
|
|
||||||
if (!d->signAll()) {
|
|
||||||
return UIDS_LIST_SEPARATELY;
|
|
||||||
}
|
|
||||||
err = Error::fromCode(GPG_ERR_UNUSABLE_PUBKEY);
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (st >= UIDS_LIST_SEPARATELY && st < UIDS_LIST_SEPARATELY_DONE) {
|
|
||||||
if (status == GPGME_STATUS_GET_LINE &&
|
|
||||||
strcmp(args, "keyedit.prompt") == 0) {
|
|
||||||
return d->allUserIDsListed() ? UIDS_LIST_SEPARATELY_DONE : st + 1 ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case CONFIRM:
|
|
||||||
case ERROR:
|
|
||||||
err = lastError();
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = GENERAL_ERROR;
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
void GpgSignKeyEditInteractor::setKey(const Key &key)
|
|
||||||
{
|
|
||||||
d->key = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GpgSignKeyEditInteractor::setCheckLevel(unsigned int checkLevel)
|
|
||||||
{
|
|
||||||
assert(!d->started);
|
|
||||||
assert(checkLevel <= 3);
|
|
||||||
d->checkLevel = checkLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GpgSignKeyEditInteractor::setUserIDsToSign(const std::vector<unsigned int> &userIDsToSign)
|
|
||||||
{
|
|
||||||
assert(!d->started);
|
|
||||||
d->userIDs = userIDsToSign;
|
|
||||||
d->nextId = d->userIDs.begin();
|
|
||||||
d->currentId = d->userIDs.end();
|
|
||||||
|
|
||||||
}
|
|
||||||
void GpgSignKeyEditInteractor::setSigningOptions(int options)
|
|
||||||
{
|
|
||||||
assert(!d->started);
|
|
||||||
d->options = options;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GpgSignKeyEditInteractor::setDupeOk(bool value)
|
|
||||||
{
|
|
||||||
assert(!d->started);
|
|
||||||
d->dupeOk = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GpgSignKeyEditInteractor::setTrustSignatureTrust(GpgME::TrustSignatureTrust trust)
|
|
||||||
{
|
|
||||||
assert(!d->started);
|
|
||||||
assert(trust != TrustSignatureTrust::None);
|
|
||||||
d->trustSignature.trust = trust;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GpgSignKeyEditInteractor::setTrustSignatureDepth(unsigned short depth)
|
|
||||||
{
|
|
||||||
assert(!d->started);
|
|
||||||
assert(depth <= 255);
|
|
||||||
d->trustSignature.depth = std::to_string(depth);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GpgSignKeyEditInteractor::setTrustSignatureScope(const std::string &scope)
|
|
||||||
{
|
|
||||||
assert(!d->started);
|
|
||||||
d->trustSignature.scope = scope;
|
|
||||||
}
|
|
@ -1,77 +0,0 @@
|
|||||||
/*
|
|
||||||
gpgsignkeyeditinteractor.h - Edit Interactor to change the owner trust of an OpenPGP key
|
|
||||||
Copyright (C) 2008 Klarälvdalens Datakonsult AB
|
|
||||||
2016 Bundesamt für Sicherheit in der Informationstechnik
|
|
||||||
Software engineering by Intevation 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 Library General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 2 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 Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public License
|
|
||||||
along with GPGME++; see the file COPYING.LIB. If not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __GPGMEPP_GPGSIGNKEYEDITINTERACTOR_H__
|
|
||||||
#define __GPGMEPP_GPGSIGNKEYEDITINTERACTOR_H__
|
|
||||||
|
|
||||||
#include "editinteractor.h"
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace GpgME
|
|
||||||
{
|
|
||||||
|
|
||||||
class Key;
|
|
||||||
class UserID;
|
|
||||||
enum class TrustSignatureTrust : char;
|
|
||||||
|
|
||||||
class GPGMEPP_EXPORT GpgSignKeyEditInteractor : public EditInteractor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum SignOption {
|
|
||||||
Exportable = 0x1,
|
|
||||||
NonRevocable = 0x2,
|
|
||||||
Trust = 0x4
|
|
||||||
};
|
|
||||||
|
|
||||||
GpgSignKeyEditInteractor();
|
|
||||||
~GpgSignKeyEditInteractor();
|
|
||||||
|
|
||||||
void setCheckLevel(unsigned int checkLevel);
|
|
||||||
void setUserIDsToSign(const std::vector<unsigned int> &userIDsToSign);
|
|
||||||
void setKey(const Key &key);
|
|
||||||
void setSigningOptions(int options);
|
|
||||||
|
|
||||||
/* Set this if it is ok to overwrite an existing signature. In that
|
|
||||||
* case the context has to have the flag "extended-edit" set to 1 through
|
|
||||||
* Context::setFlag before calling edit.*/
|
|
||||||
void setDupeOk(bool value);
|
|
||||||
|
|
||||||
void setTrustSignatureTrust(TrustSignatureTrust trust);
|
|
||||||
void setTrustSignatureDepth(unsigned short depth);
|
|
||||||
void setTrustSignatureScope(const std::string &scope);
|
|
||||||
|
|
||||||
private:
|
|
||||||
const char *action(Error &err) const override;
|
|
||||||
unsigned int nextState(unsigned int statusCode, const char *args, Error &err) const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
class Private;
|
|
||||||
Private *const d;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace GpgME
|
|
||||||
|
|
||||||
#endif // __GPGMEPP_GPGSIGNKEYEDITINTERACTOR_H__
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user