gnupg.git
2 years agotests: Add script to build a CD with the test environment. justus/scm-9
Justus Winter [Fri, 22 Jan 2016 12:43:10 +0000 (13:43 +0100)]
tests: Add script to build a CD with the test environment.

* tests/make-windows-cd.sh: New file.
* tests/run-tests.bat: Likewise.
--
This makes it easy to deploy GnuPG with the test suite to a virtual
machine for testing.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agotests/openpgp: Reimplement tests in Scheme.
Justus Winter [Thu, 7 Jan 2016 16:01:45 +0000 (17:01 +0100)]
tests/openpgp: Reimplement tests in Scheme.

* Makefile.am: Build the test infrastructure on Windows.
* tests/openpgp/Makefile.am (required_pgms): Add gpgscm.
(TESTS_ENVIRONMENT): Make sure gpgscm and the libraries are found.
(TESTS): Replace tests with the new Scheme implementations.
* tests/openpgp/4gb-packet.scm: New file.
* tests/openpgp/README: Likewise.
* tests/openpgp/armdetach.scm: Likewise.
* tests/openpgp/armdetachm.scm: Likewise.
* tests/openpgp/armencrypt.scm: Likewise.
* tests/openpgp/armencryptp.scm: Likewise.
* tests/openpgp/armor.scm: Likewise.
* tests/openpgp/armsignencrypt.scm: Likewise.
* tests/openpgp/armsigs.scm: Likewise.
* tests/openpgp/clearsig.scm: Likewise.
* tests/openpgp/conventional-mdc.scm: Likewise.
* tests/openpgp/conventional.scm: Likewise.
* tests/openpgp/decrypt-dsa.scm: Likewise.
* tests/openpgp/decrypt.scm: Likewise.
* tests/openpgp/default-key.scm: Likewise.
* tests/openpgp/defs.scm: Likewise.
* tests/openpgp/detach.scm: Likewise.
* tests/openpgp/detachm.scm: Likewise.
* tests/openpgp/ecc.scm: Likewise.
* tests/openpgp/encrypt-dsa.scm: Likewise.
* tests/openpgp/encrypt.scm: Likewise.
* tests/openpgp/encryptp.scm: Likewise.
* tests/openpgp/finish.scm: Likewise.
* tests/openpgp/genkey1024.scm: Likewise.
* tests/openpgp/gpgtar.scm: Likewise.
* tests/openpgp/import.scm: Likewise.
* tests/openpgp/mds.scm: Likewise.
* tests/openpgp/multisig.scm: Likewise.
* tests/openpgp/run-tests.scm: Likewise.
* tests/openpgp/seat.scm: Likewise.
* tests/openpgp/setup.scm: Likewise.
* tests/openpgp/signencrypt-dsa.scm: Likewise.
* tests/openpgp/signencrypt.scm: Likewise.
* tests/openpgp/sigs-dsa.scm: Likewise.
* tests/openpgp/sigs.scm: Likewise.
* tests/openpgp/use-exact-key.scm: Likewise.
* tests/openpgp/verify.scm: Likewise.
* tests/openpgp/version.scm: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agotests/gpgscm: Add a TinySCHEME-based test driver.
Justus Winter [Wed, 6 Jan 2016 10:55:25 +0000 (11:55 +0100)]
tests/gpgscm: Add a TinySCHEME-based test driver.

* configure.ac: Add new component.
* tests/Makefile.am: Likewise.
* tests/gpgscm/Makefile.am: New file.
* tests/gpgscm/ffi-private.h: Likewise.
* tests/gpgscm/ffi.c: Likewise.
* tests/gpgscm/ffi.h: Likewise.
* tests/gpgscm/ffi.scm: Likewise.
* tests/gpgscm/lib.scm: Likewise.
* tests/gpgscm/main.c: Likewise.
* tests/gpgscm/private.h: Likewise.
* tests/gpgscm/repl.scm: Likewise.
* tests/gpgscm/scheme-config.h: Likewise.
* tests/gpgscm/t-child.c: Likewise.
* tests/gpgscm/t-child.scm: Likewise.
* tests/gpgscm/tests.scm: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agotests/gpgscm: Foreign objects support for TinySCHEME.
Justus Winter [Thu, 31 Mar 2016 11:49:56 +0000 (13:49 +0200)]
tests/gpgscm: Foreign objects support for TinySCHEME.

* tests/gpgscm/scheme-private.h (struct cell): Add 'foreign_object'.
(is_foreign_object): New prototype.
(get_foreign_object_{vtable,data}): Likewise.
* tests/gpgscm/scheme.c (enum scheme_types): New type.
(is_foreign_object): New function.
(get_foreign_object_{vtable,data}): Likewise.
(mk_foreign_object): Likewise.
(finalize_cell): Free foreign objects.
(atom2str): Pretty-print foreign objects.
(vtbl): Add new functions.
* tests/gpgscm/scheme.h (struct foreign_object_vtable): New type.
(mk_foreign_object): New prototype.
(struct scheme_interface): Add new functions.

Patch from Thomas Munro,
https://sourceforge.net/p/tinyscheme/patches/13/

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agotests/gpgscm: Dynamically allocate string buffer.
Justus Winter [Thu, 31 Mar 2016 11:33:03 +0000 (13:33 +0200)]
tests/gpgscm: Dynamically allocate string buffer.

* tests/gpgscm/scheme-config.h (strbuff{,_size}): Make buffer dynamic.
* tests/gpgscm/scheme.c (expand_strbuff): New function.
(putcharacter): Adapt length test.
(readstrexp): Expand buffer if necessary.
(scheme_init_custom_alloc): Initialize buffer.
(scheme_deinit): Free buffer.

Patch from Thomas Munro,
https://sourceforge.net/p/tinyscheme/patches/11/

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agotests/gpgscm: Make exception value available.
Justus Winter [Mon, 22 Feb 2016 15:36:12 +0000 (16:36 +0100)]
tests/gpgscm: Make exception value available.

* tests/gpgscm/init.scm (throw): Hand exception value to the handler.
(catch): And bind it to *error*.

2 years agotests/gpgscm: Add package macro.
Justus Winter [Thu, 28 Jan 2016 17:19:07 +0000 (18:19 +0100)]
tests/gpgscm: Add package macro.

* tests/gpgscm/init.scm: Add package macro from manual.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agotests/gpgscm: Expose function to open streams as Scheme ports.
Justus Winter [Fri, 22 Jan 2016 10:15:20 +0000 (11:15 +0100)]
tests/gpgscm: Expose function to open streams as Scheme ports.

* tests/gpgscm/scheme.c (vtbl): Add 'port_from_file' to the vtable.
* tests/gpgscm/scheme.h (struct scheme_interface): New field
'mk_port_from_file'.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agotests/gpgscm: Nicer error message.
Justus Winter [Fri, 22 Jan 2016 10:13:14 +0000 (11:13 +0100)]
tests/gpgscm: Nicer error message.

* tests/gpgscm/scheme.c (opexe_0): Include the value that we tried to
evaluate as function-like in the error message.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agotests/gpgscm: Fix error hook.
Justus Winter [Thu, 7 Jan 2016 15:53:06 +0000 (16:53 +0100)]
tests/gpgscm: Fix error hook.

* tests/gpgscm/init.scm (*error-hook*): Fix error hook so that the
whole error message is displayed.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agotests/gpgscm: Handle unhandled enumeration values.
Justus Winter [Thu, 7 Jan 2016 13:07:20 +0000 (14:07 +0100)]
tests/gpgscm: Handle unhandled enumeration values.

* tests/gpgscm/scheme.c (opexe_{3,4}): Handle unhandled enumeration
values in the opcode dispatching code.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agotests/gpgscm: Verbatim import of latest TinySCHEME.
Justus Winter [Wed, 6 Jan 2016 10:54:03 +0000 (11:54 +0100)]
tests/gpgscm: Verbatim import of latest TinySCHEME.

* tests/gpgscm/COPYING: New file.
* tests/gpgscm/init.scm: Likewise.
* tests/gpgscm/opdefines.h: Likewise.
* tests/gpgscm/scheme-private.h: Likewise.
* tests/gpgscm/scheme.c: Likewise.
* tests/gpgscm/scheme.h: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agocommon: Drop unused variables, fix warnings.
Justus Winter [Thu, 21 Apr 2016 13:23:04 +0000 (15:23 +0200)]
common: Drop unused variables, fix warnings.

--
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agocommon: Add support for the new extended private key format.
Justus Winter [Fri, 8 Apr 2016 17:21:12 +0000 (19:21 +0200)]
common: Add support for the new extended private key format.

* agent/findkey.c (write_extended_private_key): New function.
(agent_write_private_key): Detect if an existing file is in extended
format and update the key within if it is.
(read_key_file): Handle the new format.
* agent/keyformat.txt: Document the new format.
* common/Makefile.am: Add the new files.
* common/private-keys.c: New file.
* common/private-keys.h: Likewise.
* common/t-private-keys.c: Likewise.
* common/util.h (alphap, alnump): New macros.
* tests/migrations: Add test demonstrating that we can cope with the
new format.

--
GnuPG 2.3+ will use a new format to store private keys that is both
more flexible and easier to read and edit by human beings.  The new
format stores name,value-pairs using the common mail and http header
convention.

This patch adds the parser and support code and prepares GnuPG 2.1 for
the new format.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agocommon: Add 'free_strlist_wipe' which wipes memory.
Justus Winter [Thu, 21 Apr 2016 10:59:59 +0000 (12:59 +0200)]
common: Add 'free_strlist_wipe' which wipes memory.

* common/strlist.c (free_strlist_wipe): New function.
* common/strlist.h (free_strlist_wipe): New prototype.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agocommon: Add 'append_to_strlist_try' which can fail.
Justus Winter [Thu, 21 Apr 2016 10:36:04 +0000 (12:36 +0200)]
common: Add 'append_to_strlist_try' which can fail.

* common/strlist.c (append_to_strlist): Use the new function.
(append_to_strlist_try): New function.
* common/strlist.h (append_to_strlist_try): New prototype.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoagent: Convert key format document to org.
Justus Winter [Wed, 13 Apr 2016 12:25:30 +0000 (14:25 +0200)]
agent: Convert key format document to org.

* agent/keyformat.txt: Convert to org mode.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agotests: Make migration test more robust and silent.
Justus Winter [Thu, 21 Apr 2016 12:36:21 +0000 (14:36 +0200)]
tests: Make migration test more robust and silent.

* tests/migrations/from-classic.test: Fix in-tree build, silence test.

Fixes-commit: defbc70b
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agow32: Use --enable-gpg2-is-gpg by default.
Werner Koch [Thu, 21 Apr 2016 07:18:10 +0000 (09:18 +0200)]
w32: Use --enable-gpg2-is-gpg by default.

* autogen.rc: Add option also for plain Windows.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agow32: Replace libiconv DLL by iconv feature of libgpg-error.
Werner Koch [Thu, 21 Apr 2016 07:17:11 +0000 (09:17 +0200)]
w32: Replace libiconv DLL by iconv feature of libgpg-error.

* configure.ac: Do nor require libiconv for W32.
* common/utf8conv.c [W32]: Do not incluce iconv.h.  Request
libgpg-error iconv macros.
(jnlib_iconv): Use ICONV_CONST macro.
* build-aux/speedo/w32/inst.nsi [!WITH_GUI]: Do not install libiconv.
* build-aux/speedo.mk (speedo_spkgs) [!WITH_GUI]: Likewise.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agoagent: Sanitize permissions of the private key directory.
Justus Winter [Wed, 20 Apr 2016 12:55:45 +0000 (14:55 +0200)]
agent: Sanitize permissions of the private key directory.

* agent/gpg-agent.c (create_private_keys_directory): Set permissions.
* common/sysutils.c (modestr_to_mode): New function.
(gnupg_mkdir): Use new function.
(gnupg_chmod): New function.
* common/sysutils.h (gnupg_chmod): New prototype.
* tests/migrations/from-classic.test: Test migration with existing
directory.

GnuPG-bug-id: 2312
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agotests: Test the migration from a classic GnuPG home directory.
Justus Winter [Wed, 20 Apr 2016 12:48:12 +0000 (14:48 +0200)]
tests: Test the migration from a classic GnuPG home directory.

* configure.ac: Add new directory.
* tests/Makefile.am (SUBDIRS): Likewise.
* tests/migrations/Makefile.am: New file.
* tests/migrations/from-classic.gpghome/pubring.gpg.asc: Likewise.
* tests/migrations/from-classic.gpghome/secring.gpg.asc: Likewise.
* tests/migrations/from-classic.gpghome/trustdb.gpg.asc: Likewise.
* tests/migrations/from-classic.test: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agospeedo: Use swdb.lst to define the SQLite version.
Werner Koch [Wed, 20 Apr 2016 09:02:39 +0000 (11:02 +0200)]
speedo: Use swdb.lst to define the SQLite version.

* build-aux/speedo.mk: Change sqlite to use our mirror and the
swdb.lst file.
* build-aux/speedo/w32/inst.nsi: gpg is now build and installed as
gpg.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agogpg: Improve UID selction of --quick-sign-key.
Werner Koch [Tue, 19 Apr 2016 15:47:24 +0000 (17:47 +0200)]
gpg: Improve UID selction of --quick-sign-key.

* g10/keyedit.c (keyedit_quick_sign): Improve UID selection and print
error for non-found userids.
--

GnuPG-bug-id: 2315

2 years agogpg: Avoid debug like output at start of --edit-key.
Werner Koch [Tue, 19 Apr 2016 15:45:27 +0000 (17:45 +0200)]
gpg: Avoid debug like output at start of --edit-key.

* g10/keyedit.c (check_all_keysigs): Print info only after something
has been modified.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agodirmngr: Fix https never reported in general help
Andre Heinecke [Fri, 15 Apr 2016 15:50:07 +0000 (17:50 +0200)]
dirmngr: Fix https never reported in general help

* dirmngr/ks-engine-http.c (ks_hkp_help): Also print https
when supported and no uri provided.

--
Wrong reporting was pointed out by K_F, again.

2 years agodirmngr: Fix https incorrectly reported in help
Andre Heinecke [Fri, 15 Apr 2016 15:19:40 +0000 (17:19 +0200)]
dirmngr: Fix https incorrectly reported in help

* dirmngr/ks-engine-http.c (ks_hkp_help): Only print https if tls
is supported.

--
Wrong reporting was pointed out by K_F. Check is the same as
in ks-engine-hkp.c

2 years agopo: Fix a string in de.po.
Werner Koch [Fri, 15 Apr 2016 09:46:10 +0000 (11:46 +0200)]
po: Fix a string in de.po.

--

With commit b3378b3a56fc90ba8ae38e6298b23a378305af32 from July 2014 we
use strconcat instead of sprintf for the string and thus we need to
remove one level of percent escaping.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agoagent: Fix regression due to recent commit 4159567.
Werner Koch [Thu, 14 Apr 2016 10:16:51 +0000 (12:16 +0200)]
agent: Fix regression due to recent commit 4159567.

* agent/protect.c (do_encryption): Fix CBC hashing.
--

The buggy code included an extra closing parenthesis before
the (protected-at) term in the CBC hashing.  We now do it by
explicitly hashing the protected stuff and append the rest of the
expression instead of a fixed closing parenthesis.  Note that the OCB
hashing only differs that it does no include the protected part.

Fixes-commit: 4159567f7ed7a1139fdc3a6c92988e1648ad84ab
Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agoagent: Allow gpg-protect-tool to handle openpgp-native protection.
Werner Koch [Thu, 14 Apr 2016 10:28:48 +0000 (12:28 +0200)]
agent: Allow gpg-protect-tool to handle openpgp-native protection.

* agent/protect-tool.c (read_and_unprotect): Add arg ctrl and pass to
agent_unprotect.
(main): Allocate a simple CTRL object and pass it to
read_and_unprotect.
(convert_from_openpgp_native): Remove stub.
(agent_key_available, agent_get_cache): New stubs.
(agent_askpin): New emulation for the one in call-pinentry.c.
(agent_write_private_key): New to dump key.
* agent/Makefile.am (gpg_protect_tool_SOURCES): Add cvt-openpgp.c
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agotests: Set fake-pinentry's stdout and stdin to _IOLBF.
Werner Koch [Thu, 14 Apr 2016 07:08:50 +0000 (09:08 +0200)]
tests: Set fake-pinentry's stdout and stdin to _IOLBF.

* tests/openpgp/fake-pinentry.c (main): Call setvbuf.  Show passphrase
at startup.  Increase buffer.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agoagent: Implement new protection mode openpgp-s2k3-ocb-aes.
Werner Koch [Tue, 12 Apr 2016 12:37:26 +0000 (14:37 +0200)]
agent: Implement new protection mode openpgp-s2k3-ocb-aes.

* agent/protect.c (agent_protect): Add arg use_ocb.  Change all caller
to pass -1 for default.
* agent/protect-tool.c: New option --debug-use-ocb.
(oDebugUseOCB): New.
(opt_debug_use_ocb): New.
(main): Set option.
(read_and_protect): Implement option.

* agent/protect.c (OCB_MODE_SUPPORTED): New macro.
(PROT_DEFAULT_TO_OCB): New macro.
(do_encryption): Add args use_ocb, hashbegin, hashlen, timestamp_exp,
and timestamp_exp_len.  Implement OCB.
(agent_protect): Change to support OCB.
(do_decryption): Add new args is_ocb, aadhole_begin, and aadhole_len.
Implement OCB.
(merge_lists): Allow NULL for sha1hash.
(agent_unprotect): Change to support OCB.
(agent_private_key_type): Remove debug output.
--

Instead of using the old OpenPGP way of appending a hash of the
plaintext and encrypt that along with the plaintext, the new scheme
uses a proper authenticated encryption mode.  See keyformat.txt for a
description.  Libgcrypt 1.7 is required.

This mode is not yet enabled because there would be no way to return
to an older GnuPG version.  To test the new scheme use
gpg-protect-tool:

 ./gpg-protect-tool -av -P abc -p --debug-use-ocb <plain.key >prot.key
 ./gpg-protect-tool -av -P abc -u <prot.key

Any key from the private key storage should work.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agodoc: Note that the persistant passphrase format is unimplemented.
Werner Koch [Tue, 12 Apr 2016 12:20:53 +0000 (14:20 +0200)]
doc: Note that the persistant passphrase format is unimplemented.

--

2 years agoindent: Help Emacs not to get confused by conditional compilation.
Werner Koch [Mon, 11 Apr 2016 08:24:15 +0000 (10:24 +0200)]
indent: Help Emacs not to get confused by conditional compilation.

* agent/protect.c (calibrate_get_time) [W32]: Use separate function
calls for W32 and W32CE.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agodoc: Point to RFC-4880 for keyedit subcommand "tsign".
Werner Koch [Fri, 8 Apr 2016 07:49:15 +0000 (09:49 +0200)]
doc: Point to RFC-4880 for keyedit subcommand "tsign".

--

GnuPG-bug-id: 2283

2 years agog10: Fix exporting secret keys of certain sizes.
Justus Winter [Thu, 7 Apr 2016 11:55:42 +0000 (13:55 +0200)]
g10: Fix exporting secret keys of certain sizes.

* g10/build-packet.c (do_key): Do not use the header length specified
by the public key packet from the keyring, but let 'write_header2'
compute the required length.
--
Specifically exporting RSA keys of length 1024 failed, as the encoded
public key packet requires 141 bytes a length that fits into one byte,
but the secret key is significantly larger, making the export fail.

GnuPG-bug-id: 2307
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agog10: Fix typo.
Justus Winter [Thu, 7 Apr 2016 11:51:26 +0000 (13:51 +0200)]
g10: Fix typo.

--
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agodoc: Update help.ru.txt
Ineiev [Wed, 6 Apr 2016 16:42:31 +0000 (18:42 +0200)]
doc: Update help.ru.txt

--

2 years agoRevert "g10: Support armored keyrings in gpgv."
Justus Winter [Wed, 6 Apr 2016 09:34:11 +0000 (11:34 +0200)]
Revert "g10: Support armored keyrings in gpgv."

This reverts commit abb352de51bc964c06007fce43ed6f6caea87c15.

2 years agodirmngr: Autodetect PEM format in dirmngr-client.
Justus Winter [Tue, 5 Apr 2016 14:01:05 +0000 (16:01 +0200)]
dirmngr: Autodetect PEM format in dirmngr-client.

* dirmngr/dirmngr-client.c (init_asctobin): New function.
(main): Move the initialization code to the new function.
(read_pem_certificate): Initialize base64 table.
(read_certificate): Try to decode certificates given in files as PEM
first.

GnuPG-bug-id: 1844
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agobuild: Fix for: Build gpgcompose only in maintainer mode
Werner Koch [Tue, 5 Apr 2016 13:24:56 +0000 (15:24 +0200)]
build: Fix for: Build gpgcompose only in maintainer mode

* g10/Makefile.am (noinst_PROGRAMS): Always add module_tests.
--

Fixes-commit: 4b5341d

2 years agodoc: Install gpg and gpgv man pages under the correct name.
Werner Koch [Tue, 5 Apr 2016 13:15:28 +0000 (15:15 +0200)]
doc: Install gpg and gpgv man pages under the correct name.

* doc/mkdefsinc.c (main): Add double include guard.  Set variable
gpgtwohack. Define macros gpgname and gpgvname.
* doc/gpg.texi: Remove macro definition for gpgname.  Use Texinfo var
gpgtwohack to prepare the man pages.  Use @gpgname everywhere.
* doc/gpgv.texi: Likewise.
* doc/Makefile.am (myman_pages): Remove gpg2.1 and gpgv2.1 but add
them depending on USE_GPG2_HACK.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agobuild: Build gpgcompose only in maintainer mode
Werner Koch [Tue, 5 Apr 2016 09:18:45 +0000 (11:18 +0200)]
build: Build gpgcompose only in maintainer mode

* g10/Makefile.am (noinst_PROGRAMS): Add gpgcompose only in maintainer
mode.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agogpg: Replace use of "gpg2" by GPG_NAME
Werner Koch [Tue, 5 Apr 2016 09:10:09 +0000 (11:10 +0200)]
gpg: Replace use of "gpg2" by GPG_NAME

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agoNow build "gpg" binary but install as "gpg2"
Werner Koch [Mon, 4 Apr 2016 15:42:24 +0000 (17:42 +0200)]
Now build "gpg" binary but install as "gpg2"

* configure.ac (USE_GPG2_HACK): New ac_define am_conditional.
* common/homedir.c (gnupg_module_name): Replace use of macro
NAME_OF_INSTALLED_GPG.
* g10/keygen.c (generate_keypair): Ditto.
* g10/Makefile.am (bin_PROGRAMS): Remove.
(noinst_PROGRAMS): Add gpg or gpg2 and gpgv or gpg2.
(gpg2_hack_list): New.
(use_gpg2_hack): New.
(gpg2_SOURCES): Rename to gpg_SOURCES.
(gpgv2_SOURCES): Rename to gpgv_SOURCES.
(gpg2_LDADD): Rename to gpg_LDADD.
(gpgv2_LDADD): Rename to gpgv_LDADD.
(gpg2_LDFLAGS): Rename to gpg_LDFLAGS.
(gpgv2_LDFLAGS): Rename to gpgv2_LDFLAGS.
(install-exec-hook): Remove WinCE specific rules and add new rules.
(uninstall-local): Uninstall gpg/gpg2 and gpgv/gpgv2.
* tests/openpgp/Makefile.am (required_pgms): s/gpg2/gpg/.
* tests/openpgp/defs.inc: Ditto.
* tests/openpgp/gpgtar.test: Ditto.
* tests/openpgp/mkdemodirs: Ditto.
* tests/openpgp/signdemokey: Ditto.

* Makefile.am (DISTCHECK_CONFIGURE_FLAGS): Remove obsolete
--enable-mailto, add --enable-gpg2-is-gpg.
--

Although we need to duplicate some automake generated code this method
allows to easily switch the name of the installed target using the
configure option "--enable-gpg2-is-gpg".

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agotests: Add missing file.
Werner Koch [Mon, 4 Apr 2016 16:38:53 +0000 (18:38 +0200)]
tests: Add missing file.

* tests/openpgp/Makefile.am (TEST_FILES): Add plain-largeo.asc.
--

Fixes-commit: 785a7f463ec4e937304ce1263c5e6a46e8079137

2 years agog10: Support armored keyrings in gpgv.
Justus Winter [Mon, 4 Apr 2016 15:05:50 +0000 (17:05 +0200)]
g10: Support armored keyrings in gpgv.

* doc/gpgv.texi: Document the feature.
* g10/Makefile.am (gpgv2_SOURCES): Add dearmor.c.
* g10/dearmor.c (dearmor_file): Add sink argument.
* g10/gpg.c (main): Adapt accordingly.
* g10/gpgv.c (make_temp_dir): New function.
(main): De-armor keyrings.
* g10/main.h (dearmor_file): Adapt prototype.

GnuPG-bug-id: 2290
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agotests: Fix default key test.
Justus Winter [Mon, 4 Apr 2016 11:10:28 +0000 (13:10 +0200)]
tests: Fix default key test.

* tests/openpgp/default-key.test: Avoid using the option
'--trust-model' unconditionally.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agopo: Fix misleading german translation.
Justus Winter [Fri, 1 Apr 2016 14:38:24 +0000 (16:38 +0200)]
po: Fix misleading german translation.

--
GnuPG-bug-id: 2239
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agobuild: Check for conflicting trust model options.
Justus Winter [Fri, 1 Apr 2016 12:53:48 +0000 (14:53 +0200)]
build: Check for conflicting trust model options.

* configure.ac: Disable TOFU if configured without trust models, and
check for conflicting options.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agog10: Remove option --always-trust if compiled without trust models.
Justus Winter [Fri, 1 Apr 2016 12:51:56 +0000 (14:51 +0200)]
g10: Remove option --always-trust if compiled without trust models.

* g10/gpg.c (opts): Remove option --always-trust if compiled without
trust models.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agospeedo,w32: Build libsqlite3.
Justus Winter [Thu, 31 Mar 2016 15:51:39 +0000 (17:51 +0200)]
speedo,w32: Build libsqlite3.

* build-aux/speedo.mk (speedo_spkgs): Add libsqlite3 on w32.
(libsqlite3_ver): New variable.
(speedo_pkg_libsqlite3_tar): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agog10: Use gpg-error abstraction of sched_yield.
Justus Winter [Thu, 31 Mar 2016 15:23:31 +0000 (17:23 +0200)]
g10: Use gpg-error abstraction of sched_yield.

* g10/tofu.c (begin_transaction): Use 'gpgrt_yield'.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agogpg: Fix NULL-segv for missing tofu DB.
Werner Koch [Tue, 29 Mar 2016 11:30:19 +0000 (13:30 +0200)]
gpg: Fix NULL-segv for missing tofu DB.

* g10/tofu.c (opendb): Guard call to timeout function.
--

GnuPG-bug-id: 2294

Fix not tested but is pretty obvious.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agogpg: Improve message when asking for key capabilities.
Werner Koch [Tue, 22 Mar 2016 19:24:52 +0000 (20:24 +0100)]
gpg: Improve message when asking for key capabilities.

* g10/keygen.c (ask_key_flags): Improve message.
--

Because the curve is only selected after the capabilities are queried
we do not know whether ECDSA or EdDSA will eventually be used.  When
printing the possible capabilities we now use print "ECDSA/EdDSA" for
the algorithm.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agogpg: Remove the extra prompt for Curve25519.
Werner Koch [Tue, 22 Mar 2016 18:55:25 +0000 (19:55 +0100)]
gpg: Remove the extra prompt for Curve25519.

* g10/keygen.c (MY_USE_ECDSADH): New macro local to ask_curve.
(ask_curve): Use a fixed table of curve names and reserve a slot for
Curve448.  Simplify CurveNNNN/EdNNNN switching.
(ask_curve): Remove the Curve25519 is non-standard prompt.
--

Given that ECC generation is only available in export mode and that
gpg will in any case support our current ed2559/cv25519 definition the
extra prompt does not make anymore sense.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agogpg: Silence trustdb computation with --quiet.
Werner Koch [Sat, 19 Mar 2016 13:43:18 +0000 (14:43 +0100)]
gpg: Silence trustdb computation with --quiet.

* g10/trustdb.c (validate_keys): Do not print log_info stuff in quiet
mode.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agosm: Always create a keybox header when creating a new keybox.
Werner Koch [Thu, 17 Mar 2016 14:15:48 +0000 (15:15 +0100)]
sm: Always create a keybox header when creating a new keybox.

* sm/keydb.c (maybe_create_keybox): Create the header blob.
--

This is required so that g10/keydb.c can properly detect that a keybox
file is actually there.  Just writing a 0 zero length keybox file is
not sufficient because a file with that name may also be an old-style
OpenPGP keyring.

GnuPG-bug-id: 2275
Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agodoc: Improve documentation of --enable-large-rsa.
Neal H. Walfield [Thu, 17 Mar 2016 10:13:57 +0000 (11:13 +0100)]
doc: Improve documentation of --enable-large-rsa.

* doc/gpg.texi (--enable-large-rsa): Improve text.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
Suggested-by: Bernhard Reiter <bernhard@intevation.de>
2 years agoagent: allow removal of the shadowed key.
NIIBE Yutaka [Wed, 16 Mar 2016 23:37:58 +0000 (08:37 +0900)]
agent: allow removal of the shadowed key.

* agent/findkey.c (agent_delete_key): Remove the key when asked.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agog10: Add const qualifier.
NIIBE Yutaka [Wed, 16 Mar 2016 02:52:41 +0000 (11:52 +0900)]
g10: Add const qualifier.

* g10/gpgcompose.c (show_help): Those are strings not to be modified.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agogpg: Do not rely on a certain evaluation order.
Werner Koch [Tue, 15 Mar 2016 08:22:24 +0000 (09:22 +0100)]
gpg: Do not rely on a certain evaluation order.

* g10/keyedit.c (print_and_check_one_sig): Call check_key_signature
before derefing IS_SELFSIG.
--

Fixes-commit: 5fbd80579aea0f75ca1d2700515c5b8747a75c7d
Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agoscd: Add manufacturer id 0x000a
Werner Koch [Mon, 14 Mar 2016 16:49:36 +0000 (17:49 +0100)]
scd: Add manufacturer id 0x000a

* g10/card-util.c (get_manufacturer): Add it.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agog10: Silence message if --quiet is given.
Kevin J. McCarthy [Thu, 10 Mar 2016 11:41:06 +0000 (12:41 +0100)]
g10: Silence message if --quiet is given.

* g10/getkey.c (parse_def_secret_key): Silence message if --quiet is
given.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agogpg: Add a new test.
Neal H. Walfield [Tue, 8 Mar 2016 13:08:15 +0000 (14:08 +0100)]
gpg: Add a new test.

* g10/Makefile.am (EXTRA_DIST): Add t-stutter-data.asc.
(module_tests): Add t-stutter.
(t_stutter_SOURCES): New variable.
(t_stutter_LDADD): New variable.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
Add a test to check that the Mister and Zuccerato attack described in
"An Attack on CFB Mode Encryption As Used by OpenPGP" works.

2 years agosm: Implement pinentry loopback and reading passphrases from fd.
Justus Winter [Mon, 7 Mar 2016 17:09:41 +0000 (18:09 +0100)]
sm: Implement pinentry loopback and reading passphrases from fd.

* doc/gpgsm.texi: Document '--pinentry-mode' and '--passphrase-fd'.
* sm/Makefile.am (gpgsm_SOURCES): Add new files
* sm/call-agent.c (struct default_inq_parm_s): New definition.
(start_agent): Pass in the pinentry mode.
(default_inq_cb): Handle 'PASSPHRASE' and 'NEW_PASSPHRASE' inquiries.
Adapt all call sites to the new callback cookie.
* sm/gpgsm.c (cmd_and_opt_values): Add new values.
(opts): Add new options.
(main): Handle new options.
* sm/gpgsm.h (struct opt): Add field 'pinentry_mode'.
* sm/passphrase.c: New file.
* sm/passphrase.h: Likewise.

GnuPG-bug-id: 1970
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agosm: Remove unused argument '--fixed-passphrase'.
Justus Winter [Mon, 7 Mar 2016 12:32:35 +0000 (13:32 +0100)]
sm: Remove unused argument '--fixed-passphrase'.

* doc/gpgsm.texi: Drop description.
* sm/gpgsm.c (cmd_and_opt_values): Drop enum value.
(opts): Drop argument.
(main): Drop argument handling.
* sm/gpgsm.h (struct opt): Drop field 'fixed_passphrase'.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agokbx: Avoid undefined behavior.
Justus Winter [Mon, 7 Mar 2016 13:25:38 +0000 (14:25 +0100)]
kbx: Avoid undefined behavior.

* kbx/keybox-file.c (_keybox_read_blob2): Cast to unsigned int before
shifting.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agoscd: Bug fix for a device with multiple interfaces.
NIIBE Yutaka [Mon, 7 Mar 2016 11:12:38 +0000 (20:12 +0900)]
scd: Bug fix for a device with multiple interfaces.

* scd/ccid-driver.c (scan_or_find_usb_device): Use IFC_NO when
accessing interface information.

--
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2 years agobuild: Make libusb a hard requirement if the ccid driver is requested.
Justus Winter [Fri, 4 Mar 2016 14:03:26 +0000 (15:03 +0100)]
build: Make libusb a hard requirement if the ccid driver is requested.

* configure.ac: Print an error message and die if the internal ccid
driver is requested but no suitable libusb is found.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agog10: Drop superfluous declaration.
Justus Winter [Fri, 4 Mar 2016 12:33:04 +0000 (13:33 +0100)]
g10: Drop superfluous declaration.

* g10/main.h (disable_core_dumps): Drop declaration.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agog10: Guard code against errors.
Justus Winter [Fri, 4 Mar 2016 12:29:45 +0000 (13:29 +0100)]
g10: Guard code against errors.

* g10/keygen.c (do_generate_keypair): Check for errors, in which case
'pri_psk' is NULL.

Fixes-commit: bf9d1248
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agodoc: Drop superfluous 'is'.
Justus Winter [Fri, 4 Mar 2016 12:09:11 +0000 (13:09 +0100)]
doc: Drop superfluous 'is'.

--
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agodirmngr: Add more missing CFLAGS.
Justus Winter [Thu, 3 Mar 2016 12:47:42 +0000 (13:47 +0100)]
dirmngr: Add more missing CFLAGS.

* dirmngr/Makefile.am (t_ldap_parse_uri_CFLAGS): Add
'GCRYPT_CFLAGS'.
(t_dns_stuff_CFLAGS): Likewise.

GnuPG-bug-id: 2235
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agotests/openpgp: Skip gpgtar test if it has not been built.
Justus Winter [Thu, 3 Mar 2016 11:22:30 +0000 (12:22 +0100)]
tests/openpgp: Skip gpgtar test if it has not been built.

* tests/openpgp/gpgtar.test: Check if executable exists.

GnuPG-bug-id: 2261
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agogpg: Add new program gpgcompose.
Neal H. Walfield [Wed, 2 Mar 2016 15:00:44 +0000 (16:00 +0100)]
gpg: Add new program gpgcompose.

* g10/packet.h: Include "util.h".
* g10/encrypt.c (encrypt_seskey): Don't mark as static.
* g10/gpgcompose.c: New file.
* g10/Makefile.am (noinst_PROGRAMS): Add gpgcompose.
(gpg2_SOURCES): Split everything but gpg.c into...
(gpg_sources): ... this new variable.
(gpgcompose_SOURCES): New variable.
(gpgcompose_LDADD): Likewise.
(gpgcompose_LDFLAGS): Likewise.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2 years agogpg: More robustly detect valid non-armored OpenPGP messages.
Neal H. Walfield [Wed, 2 Mar 2016 14:47:01 +0000 (15:47 +0100)]
gpg: More robustly detect valid non-armored OpenPGP messages.

* g10/armor.c (is_armored): More robustly detect valid non-armored
OpenPGP messages.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2 years agocommon: Provide a function for mapping packet types to strings.
Neal H. Walfield [Wed, 2 Mar 2016 14:45:39 +0000 (15:45 +0100)]
common: Provide a function for mapping packet types to strings.

* common/openpgpdefs.h (pkttype_str): New function.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2 years agogpg: Rename pop_filter to iobuf_pop_filter and export it.
Neal H. Walfield [Wed, 2 Mar 2016 14:42:18 +0000 (15:42 +0100)]
gpg: Rename pop_filter to iobuf_pop_filter and export it.

* common/iobuf.c (pop_filter): Rename from this...
(iobuf_pop_filter): ... to this.  Don't mark it as static.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2 years agogpg: Split write_pubkey_enc_from_list.
Neal H. Walfield [Wed, 2 Mar 2016 14:38:16 +0000 (15:38 +0100)]
gpg: Split write_pubkey_enc_from_list.

* g10/encrypt.c (write_pubkey_enc_from_list): Split the body of this
function out into...
(write_pubkey_enc): ... this new function.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2 years agogpg: Allow the caller to write the contents of a plaintext packet.
Neal H. Walfield [Wed, 2 Mar 2016 14:35:39 +0000 (15:35 +0100)]
gpg: Allow the caller to write the contents of a plaintext packet.

* g10/build-packet.c (do_plaintext): Change the semantics such that if
PT->BUF is NULL, it is the caller's responsibility to write the
content (and disable partial body length mode, if appropriate).

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2 years agogpg: Add a new function for creating binary notations.
Neal H. Walfield [Mon, 29 Feb 2016 13:12:57 +0000 (14:12 +0100)]
gpg: Add a new function for creating binary notations.

* g10/build-packet.c (blob_to_notation): New function.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2 years agogpg: Refactor the printing of binary notations.
Neal H. Walfield [Mon, 29 Feb 2016 13:09:43 +0000 (14:09 +0100)]
gpg: Refactor the printing of binary notations.

* g10/build-packet.c (sig_to_notation): Break printing of binary
notations into...
(notation_value_to_human_readable_string): ... this new function.
Provide a small preview of the binary data substituting non-printable
characters with '?'.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2 years agotests/openpgp: Make tests more portable.
Uldis Anšmits [Wed, 2 Mar 2016 16:55:56 +0000 (17:55 +0100)]
tests/openpgp: Make tests more portable.

* tests/openpgp/default-key.test: Avoid 'grep -q'.
* tests/openpgp/gpgtar.test: Avoid 'grep -qe' and 'diff -q'.
* tests/openpgp/use-exact-key.test: Avoid 'grep -q'.

GnuPG-bug-id: 2262
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agocommon: Update README.
Justus Winter [Wed, 2 Mar 2016 13:27:30 +0000 (14:27 +0100)]
common: Update README.

--
Signed-off-by: Justus Winter <justus@g10code.com>
2 years agocommon: Consolidate Assuan server argument handling.
Justus Winter [Wed, 2 Mar 2016 13:14:33 +0000 (14:14 +0100)]
common: Consolidate Assuan server argument handling.

* common/Makefile.am (common_sources): Add new files.
* common/server-help.c: New file.
* common/server-help.h: Likewise.
* agent/command.c: Drop argument handling primitives in favor of using
the consolidated ones.
* dirmngr/server.c: Likewise.
* g10/server.c: Likewise.
* g13/server.c: Likewise.
* scd/command.c: Likewise.
* sm/server.c: Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agodirmngr: Add missing CFLAGS.
Justus Winter [Tue, 1 Mar 2016 14:07:29 +0000 (15:07 +0100)]
dirmngr: Add missing CFLAGS.

* dirmngr/Makefile.am (t_ldap_parse_uri_CFLAGS): Add
'GPG_ERROR_CFLAGS'.
(t_dns_stuff_CFLAGS): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agotools: Drop superfluous include.
Justus Winter [Tue, 1 Mar 2016 13:51:35 +0000 (14:51 +0100)]
tools: Drop superfluous include.

* tools/gpgtar.c: Do not include unused 'npth.h'.

Signed-off-by: Justus Winter <justus@g10code.com>
2 years agogpg: Prettify a 2 octet hex output.
Werner Koch [Fri, 26 Feb 2016 10:41:18 +0000 (11:41 +0100)]
gpg: Prettify a 2 octet hex output.

* g10/sig-check.c (check_key_signature2): Wrap line and use %02x.

Signed-off-by: Werner Koch <wk@gnupg.org>
2 years agogpg: Show debugging info if a sig with an unsupported sig class is used.
Neal H. Walfield [Thu, 25 Feb 2016 20:22:55 +0000 (21:22 +0100)]
gpg: Show debugging info if a sig with an unsupported sig class is used.

* g10/sig-check.c (check_key_signature2): If SIG->CLASS is
unsupported, show some debugging information.  Don't use BUG to fail.
Just return GPG_ERR_BAD_SIGNATURE.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2 years agogpg: More carefully encode a packet's length.
Neal H. Walfield [Thu, 25 Feb 2016 20:20:32 +0000 (21:20 +0100)]
gpg: More carefully encode a packet's length.

* g10/build-packet.c (write_header2): Make sure the length bits are
cleared.  Fail if HDRLEN is set and the specified length can't be
encoded in the available space.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2 years agogpg: Avoid directly twiddling bits.
Neal H. Walfield [Thu, 25 Feb 2016 20:16:41 +0000 (21:16 +0100)]
gpg: Avoid directly twiddling bits.

* g10/build-packet.c (do_plaintext): Use ctb_new_format_p to check the
packet's format.
(write_header2): Likewise.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2 years agogpg: Improve documentation and comments related to OpenPGP packets.
Neal H. Walfield [Thu, 25 Feb 2016 20:08:56 +0000 (21:08 +0100)]
gpg: Improve documentation and comments related to OpenPGP packets.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2 years agogpg: Add some asserts.
Neal H. Walfield [Thu, 25 Feb 2016 14:19:04 +0000 (15:19 +0100)]
gpg: Add some asserts.

* g10/build-packet.c (ctb_new_format_p): New function.
(ctb_pkttype): New function.
(do_user_id): Add some asserts.
(do_key): Likewise.
(do_symkey_enc): Likewise.
(do_pubkey_enc): Likewise.
(do_plaintext): Likewise.
(do_encrypted): Likewise.
(do_encrypted_mdc): Likewise.
(do_compressed): Likewise.
(do_signature): Likewise.
(do_signature): Likewise.
(write_header2): Likewise.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2 years agogpg: Avoid an unnecessary copy.
Neal H. Walfield [Thu, 25 Feb 2016 13:51:55 +0000 (14:51 +0100)]
gpg: Avoid an unnecessary copy.

* g10/build-packet.c (sig_to_notation): Avoid an unnecessary copy of
the data: the size of the packet is fixed.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2 years agocommon: Reduce buffer size.
Neal H. Walfield [Tue, 23 Feb 2016 21:39:58 +0000 (22:39 +0100)]
common: Reduce buffer size.

* common/iobuf.c (iobuf_copy): Change buffer size from 1 MB to 32 KB.

--
Change suggested by Werner based on the observation that other buffers
are of a similar size.

Signed-off-by: Neal H. Walfield <neal@g10code.com>
2 years agocommon: Improve a function's documentation and comments.
Neal H. Walfield [Tue, 23 Feb 2016 20:28:24 +0000 (21:28 +0100)]
common: Improve a function's documentation and comments.

* common/iobuf.c (iobuf_set_partial_body_length_mode): Fix
documentation and comment.  Add an assert.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2 years agocommon: Add log_assert.
Neal H. Walfield [Tue, 23 Feb 2016 20:14:21 +0000 (21:14 +0100)]
common: Add log_assert.

* common/logging.h (log_assert): New macro.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2 years agogpg: Use higher-level functions.
Neal H. Walfield [Tue, 23 Feb 2016 20:07:09 +0000 (21:07 +0100)]
gpg: Use higher-level functions.

* g10/build-packet.c (do_symkey_enc): Use iobuf_write instead of
iobuf_put in a loop.  Use iobuf_copy instead of iobuf_read and
iobuf_write in a loop.  Move the memory wiping from here...
* common/iobuf.c (iobuf_copy): ... to here.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
2 years agocommon: Check for an error before reading.
Neal H. Walfield [Tue, 23 Feb 2016 20:04:29 +0000 (21:04 +0100)]
common: Check for an error before reading.

* common/iobuf.c (iobuf_copy): If DEST has a pending error, don't
start copying.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>