3 years agodoc: Replace "conventional encryption" by "symmetric encryption".
Werner Koch [Tue, 2 Jun 2015 15:46:42 +0000 (17:46 +0200)]
doc: Replace "conventional encryption" by "symmetric encryption".


Suggested-by: Daniel Kahn Gillmor <>
3 years agogpg: Consider that gcry_mpi_get_opaque may return NULL.
Werner Koch [Tue, 2 Jun 2015 15:41:30 +0000 (17:41 +0200)]
gpg: Consider that gcry_mpi_get_opaque may return NULL.

* g10/seckey-cert.c (do_check): Handle a NULL opaque MPI.

This patch extends b2d9d10 for secret keys.  The problem is that we
changed the semantics so that opaque MPIs may be NULL with a bit
length.  This patch is not required in GnuPG 2 because we do not use
secret keys there.

Signed-off-by: Werner Koch <>
3 years agogpg: Fix segv due to NULL value stored as opaque MPI (BRANCH 2.0)
Daniel Kahn Gillmor [Sat, 21 Feb 2015 23:23:44 +0000 (18:23 -0500)]
gpg: Fix segv due to NULL value stored as opaque MPI (BRANCH 2.0)

* g10/build-packet.c (do_secret_key): Check for NULL return from
* g10/keyid.c (hash_public_key): Ditto.

This is a backport of 76c8122adfed0f0f443cce7bda702ba2b39661b3 from
master to the STABLE-BRANCH-2-0

On the STABLE-BRANCH-2-0, we may also want to patch g10/seckey-cert.c,
but that has not been done in this patch.

This fix extends commmit 0835d2f44ef62eab51fce6a927908f544e01cf8f.

  gpg2 --export --no-default-keyring --keyring TESTDATA

With TESTDATA being below after unpacking.



Reported-by: Jodie Cunningham
Signed-off-by: Daniel Kahn Gillmor <>
3 years agodoc: Typo fix for "Creation-Date".
Werner Koch [Tue, 2 Jun 2015 15:20:56 +0000 (17:20 +0200)]
doc: Typo fix for "Creation-Date".


Debian-bug-id: 760273

This has already been fixed in master.

3 years agoPost release updates
Werner Koch [Tue, 2 Jun 2015 13:12:04 +0000 (15:12 +0200)]
Post release updates


The fuzzy entries of ru.po are not in the release.  Does not matter.

3 years agoRelease 2.0.28 gnupg-2.0.28
Werner Koch [Tue, 2 Jun 2015 12:31:13 +0000 (14:31 +0200)]
Release 2.0.28

3 years agopo: Auto-update
Werner Koch [Tue, 2 Jun 2015 12:30:36 +0000 (14:30 +0200)]
po: Auto-update


3 years agopo: Update Russian translation
Ineiev [Tue, 2 Jun 2015 11:24:22 +0000 (13:24 +0200)]
po: Update Russian translation


This pacth was missed for 2.0.27.
I fixed a typo in the PO-Revision-Date.
  - wk

3 years agopo: Update the German translation
Werner Koch [Tue, 2 Jun 2015 11:15:13 +0000 (13:15 +0200)]
po: Update the German translation


3 years agopo: Fix a LF mismatch in ja.po.
Werner Koch [Tue, 2 Jun 2015 11:06:08 +0000 (13:06 +0200)]
po: Fix a LF mismatch in ja.po.


3 years agoagent: Make --allow-external-password-cache work.
Werner Koch [Tue, 2 Jun 2015 08:36:21 +0000 (10:36 +0200)]
agent: Make --allow-external-password-cache work.

* agent/call-pinentry.c (start_pinentry): Remove first instance of
sending the option.

That option to tell Pinentry about an external password cache was send
twice and the first one unconditionally.

Signed-off-by: Werner Koch <>
3 years agoagent: Add strings for use by future Pinentry versions.
Werner Koch [Mon, 11 May 2015 08:25:09 +0000 (10:25 +0200)]
agent: Add strings for use by future Pinentry versions.

* agent/call-pinentry.c (start_pinentry): Add more strings.

We do this so that translations of these strings will be available at
the time a pinentry implements features which require these strings.

Signed-off-by: Werner Koch <>
This is a backport from master
commit 02d5e1205489aa5027a87a64552eaf15984dc22d
without the mode flag in the table.

3 years agoagent: Cleanup caching code for command GET_PASSPHRASE.
Werner Koch [Wed, 20 May 2015 14:13:55 +0000 (16:13 +0200)]
agent: Cleanup caching code for command GET_PASSPHRASE.

* agent/command.c (cmd_get_passphrase): Read from the user cache.

We used to read the passphrase with mode CACHE_MODE_NORMAL but we put
it into the cache with CACHE_MODE_USER.  However, agent_get_cache does
not yet distinguish between them and thus this does not change

(backported from commit 23d2ef83cda644c6a83499f9327350d3371e8a17)

3 years agoagent: Backport changes from 2.1 to support an external password manager.
Neal H. Walfield [Tue, 19 May 2015 11:53:43 +0000 (13:53 +0200)]
agent: Backport changes from 2.1 to support an external password manager.

* agent/agent.h (agent_askpin): Add arguments keyinfo and cache_mode.
Update callers.
(agent_get_passphrase): Likewise.
(agent_clear_passphrase): New function.
(opt): Add field allow_external_cache.
* agent/call-pinentry.c (start_pinentry): Send "OPTION
allow-external-password-cache" to the pinentry.
(pinentry_status_cb): New function.
(agent_askpin): Add arguments keyinfo and cache_mode.  If KEYINFO and
CACHE_MODE describe a cachable key, then send SETKEYINFO to the
pinentry.  Pass PINENTRY_STATUS_CB to the "GETPIN" invocation.  If the
passphrase was incorrect and PINENTRY_STATUS_PASSWORD_FROM_CACHE is
set, decrement PININFO->FAILED_TRIES.
(agent_get_passphrase): Add arguments keyinfo and cache_mode.  If
KEYINFO and CACHE_MODE describe a cachable key, then send SETKEYINFO
to the pinentry.
(agent_clear_passphrase): New function.
* agent/call-pinentry.c (start_pinentry): Act upon new var,
* agent/command.c (cmd_clear_passphrase): Call agent_clear_passphrase.
* agent/gpg-agent.c (oNoAllowExternalCache): New.
(opts): Add option --no-allow-external-cache.
(parse_rereadable_options): Set this option.

Signed-off-by: Neal H. Walfield <>
Based on commits:


3 years agog10: detects public key encryption packet error properly.
NIIBE Yutaka [Tue, 19 May 2015 01:32:07 +0000 (10:32 +0900)]
g10: detects public key encryption packet error properly.

g10/mainproc.c (proc_pubkey_enc): Only allow relevant algorithms for


(backport from 2.1 commit c771963140cad7c1c25349bcde27e427effc0058)

3 years agog10: Improve handling of no corresponding public key.
NIIBE Yutaka [Tue, 19 May 2015 01:14:09 +0000 (10:14 +0900)]
g10: Improve handling of no corresponding public key.

* g10/getkey.c (get_seckey): Return G10ERR_NO_PUBKEY when it's not
exact match.


(ported from 1.4 commit b3fd30451a5464b124b0296afbc341cb98b3977c)

In the situation of corrupted .gnupg/ where only private subkey is
available but no corresponding public key of the subkey, the code
returned public primary key which caused mysterious error (for a
user).  This fix detects an error earlier.

GnuPG-bug-id: 1422
Debian-Bug-Id: #638619

3 years agogpg-connect-agent: Fix quoting of internal percent+ function.
Werner Koch [Mon, 11 May 2015 17:38:07 +0000 (19:38 +0200)]
gpg-connect-agent: Fix quoting of internal percent+ function.

* tools/gpg-connect-agent.c (get_var_ext) <percent, percent+): Also
escape '+'.

GnuPG-bug-id: 1841
Signed-off-by: Werner Koch <>
3 years agoscd: PC/SC reader selection by partial string match.
NIIBE Yutaka [Thu, 30 Apr 2015 03:36:38 +0000 (12:36 +0900)]
scd: PC/SC reader selection by partial string match.

* scd/apdu.c (open_pcsc_reader_direct): Partial string match.
* scd/pcsc-wrapper.c (handle_open): Likewise.


(backport from 2.1 commit 01a2a61bc4b34817c4216888265f65d59a33dad3)

The card reader name by PC/SC service might include USB bus,
which varies (on some platform like GNU/Linux).  Thus, it's
better to match partial string.

Original patch was submitted by anstein.  I changed it to fallback to
the first reader if no match found.

GnuPG-bug-id: 1618, 1930

3 years agog10: fix cmp_public_key and cmp_secret_keys.
NIIBE Yutaka [Thu, 30 Apr 2015 08:02:42 +0000 (17:02 +0900)]
g10: fix cmp_public_key and cmp_secret_keys.

* g10/free-packet.c (cmp_public_keys, cmp_secret_keys): Compare opaque
data at the first entry of the array when it's unknown algo.
* (NEED_LIBGCRYPT_VERSION): Require 1.5.0.


GnuPG-bug-id: 1962

3 years agogpg: Emit status line NEWSIG before signature verification starts.
Werner Koch [Thu, 19 Mar 2015 19:38:25 +0000 (20:38 +0100)]
gpg: Emit status line NEWSIG before signature verification starts.

* g10/mainproc.c (check_sig_and_print): Emit STATUS_NEWSIG.

gpgsm does this for a long time but somehow it never made it into gpg.

Signed-off-by: Werner Koch <>
(backported from 2.1 commit e7ddaad0fd2c8774a1d3367adfaa68014eaf65de)

3 years agoscd: better handling of extended APDU.
NIIBE Yutaka [Tue, 14 Apr 2015 05:17:03 +0000 (14:17 +0900)]
scd: better handling of extended APDU.

* scd/apdu.c (send_le): Bug fix for not append Z when lc<0&&le<0.
* scd/app-common.h (struct app_ctx_s): Use bit fields for flags.
* scd/ccid-driver.c (CCID_MAX_BUF): New.  Only for OpenPGPcard.
(struct ccid_driver_s): New field of max_ccid_msglen.
 Remove ifsd field.
(parse_ccid_descriptor): Initialize max_ccid_msglen.
(ccid_transceive_apdu_level): Implement sending extended APDU in
chain of CCID message.


With this patch, we won't need PC/SC library/service any more.
GnuPG-bug-id: 1947
(backported from 2.1 commit 971d558e862db878a7310e06ed7116dbe36886ab)

3 years agogpgparsemail: Fix last commit (3f2bdac)
Werner Koch [Fri, 10 Apr 2015 06:34:35 +0000 (08:34 +0200)]
gpgparsemail: Fix last commit (3f2bdac)

* tools/rfc822parse.c (parse_field): Replace break by goto.

Brown paper bag bug: Changing an IF to a WHILE inside another loop
requires to fix the inner break.

Reported-by: Hanno Böck
Signed-off-by: Werner Koch <>
(backported from 2.1 commit 9433661419043431a6cfc7d84c8450e0b2f6c353)

3 years agogpgparsemail: Fix case of zero length continuation lines.
Werner Koch [Thu, 9 Apr 2015 17:06:33 +0000 (19:06 +0200)]
gpgparsemail: Fix case of zero length continuation lines.

* tools/rfc822parse.c (parse_field): Loop after continuation line.

Using header lines like


resulted in running into the "(s2 = strchr (delimiters2, *s)" branch
and inserting a new token for the empty continuation line.  This also
led to one byte read after the string which is what Hanno figured.
The new code should handle empty continuation lines correct.

Reported-by: Hanno Böck
Signed-off-by: Werner Koch <>
(backported from 2.1 commit 3fbeba64a8bfb2b673230c124a3d616b6568fd2f)

3 years agoagent: Fix length test in sshcontrol parser.
Werner Koch [Sun, 15 Mar 2015 12:04:48 +0000 (13:04 +0100)]
agent: Fix length test in sshcontrol parser.

* agent/command-ssh.c (ssh_search_control_file): Check S before
upcasing it.

In contradiction to the comment we did not check the length of HEXGRIP
and thus the GPG_ERR_INV_LENGTH was never triggered.

Detected by Stack 0.3:

  bug: anti-simplify
  model: |
    %cmp8 = icmp ne i32 %i.0, 40, !dbg !986
    -->  false
    - /home/wk/s/gnupg/agent/command-ssh.c:1226:0
  ncore: 2
    - /home/wk/s/gnupg/agent/command-ssh.c:1225:0
      - buffer overflow
    - /home/wk/s/gnupg/agent/command-ssh.c:1225:0
      - buffer overflow

(backported from 2.1 commit 3529dd8bb5bafc4e02915648d5f409bd27a9cc37)

3 years agoscd: Fix possible NULL deref in apdu.c
Werner Koch [Sun, 15 Mar 2015 11:15:55 +0000 (12:15 +0100)]
scd: Fix possible NULL deref in apdu.c

* scd/apdu.c (control_pcsc_direct): Take care of BUFLEN being NULL.
(control_pcsc_wrapped): Ditto.

pcsc_vendor_specific_init calls the above with BUFFER and BUFLEN as

Reported by Stack 0.3:

  bug: anti-dce
  model: |
    %retval.0.i.i76 = phi i32 [ %rc.0.i.i.i73, \
            %pcsc_error_to_sw.exit.i.i74 ], [ 0, %if.end.i.i75 ]
    %tobool198 = icmp ne i32 %retval.0.i.i76, 0, !dbg !728
    br i1 %tobool198, label %if.then199, label %if.end200, !dbg !728
    - /home/wk/s/gnupg/scd/apdu.c:1882:0
  ncore: 1
    - /home/wk/s/gnupg/scd/apdu.c:1309:0
      - buffer overflow

(backported from 2.1 commit ef0a3abf7305133d071bf1a94a7f461082f9a9aa)

3 years agopo: Update Japanese translation.
NIIBE Yutaka [Wed, 15 Apr 2015 04:41:48 +0000 (13:41 +0900)]
po: Update Japanese translation.

3 years agogpg: Fix DoS while parsing mangled secret key packets.
Werner Koch [Sun, 5 Apr 2015 17:33:36 +0000 (19:33 +0200)]
gpg: Fix DoS while parsing mangled secret key packets.

* g10/parse-packet.c (parse_key): Check PKTLEN before calling mpi_read
et al.

Due to the missing length checks PKTLEN may turn negative.  Because
PKTLEN is an unsigned int the malloc in read_rest would try to malloc
a too large number and terminate the process with "error reading rest
of packet: Cannot allocate memory".

Reported-by: Hanno Böck.
Signed-off-by: Werner Koch <>
(backported from 2.1 commit d901efcebaefaf6eae4a9b9aa8f0c2c055d3518a)

3 years agodoc: Document the changed default algos for gpgsm.
Werner Koch [Wed, 25 Mar 2015 09:16:37 +0000 (10:16 +0100)]
doc: Document the changed default algos for gpgsm.


3 years agosm: Change default algos to SHA256 (CSR) and AES128 (bulk encryption).
Werner Koch [Wed, 25 Mar 2015 09:12:11 +0000 (10:12 +0100)]
sm: Change default algos to SHA256 (CSR) and AES128 (bulk encryption).

* sm/certreqgen.c (create_request): Change default hash algo.
* sm/gpgsm.c (main): Change default bulk cipher algo.

Signed-off-by: Werner Koch <>
3 years agogpgtar: Fix extracting files with !(size % 512)
Andre Heinecke [Tue, 17 Mar 2015 09:48:09 +0000 (10:48 +0100)]
gpgtar: Fix extracting files with !(size % 512)

* tools/gpgtar-extract.c (extract_regular): Handle size multiples

  If a hdr->size was a multiple of 512 the last record would
  not have been written and the files corrupted accordingly.

GnuPG-bug-id: 1926

Signed-off-by: Andre Heinecke <>
Changed to use only if-else.

Signed-off-by: Werner Koch <>
(cherry picked from commit 6cbbb0bec98e1acefc4c7163cc41a507469db920)

3 years agocommon: Check option arguments for a valid range
Werner Koch [Thu, 5 Mar 2015 01:33:47 +0000 (02:33 +0100)]
common: Check option arguments for a valid range

* common/argparse.h (ARGPARSE_INVALID_ARG): New.
* common/argparse.c: Include limits h and errno.h.
(initialize): Add error strings for new error constant.
(set_opt_arg): Add range checking.
Signed-off-by: Werner Koch <>
[ This is a backport of 0d73a242cb53522669cf712b5ece7d1ed05d003a from
  master to STABLE-BRANCH-2-0 ]

Signed-off-by: Daniel Kahn Gillmor <>
3 years agogpg: New command --list-gcrypt-config.
Werner Koch [Wed, 11 Mar 2015 13:58:38 +0000 (14:58 +0100)]
gpg: New command --list-gcrypt-config.

* g10/gpg.c (aListGcryptConfig): New.
(main): Implement command.

Signed-off-by: Werner Koch <>
3 years agogpg: Remove left-over debug message.
Werner Koch [Thu, 26 Feb 2015 08:38:58 +0000 (09:38 +0100)]
gpg: Remove left-over debug message.

* g10/armor.c (check_input): Remove log_debug.

3 years agoPost release updates.
Werner Koch [Wed, 18 Feb 2015 13:32:11 +0000 (14:32 +0100)]
Post release updates.


3 years agoRelease 2.0.27 gnupg-2.0.27
Werner Koch [Wed, 18 Feb 2015 13:10:57 +0000 (14:10 +0100)]
Release 2.0.27

3 years agogpg: Remove an unused variable.
Werner Koch [Wed, 18 Feb 2015 13:19:46 +0000 (14:19 +0100)]
gpg: Remove an unused variable.

* g10/import.c (import): Remove need_armor.

3 years agopo: Auto update
Werner Koch [Wed, 18 Feb 2015 11:53:39 +0000 (12:53 +0100)]
po: Auto update


3 years agopo: Update German translation
Werner Koch [Wed, 18 Feb 2015 11:52:55 +0000 (12:52 +0100)]
po: Update German translation

3 years agocurl-shim: clean up varargs
Daniel Kahn Gillmor [Wed, 18 Feb 2015 09:11:31 +0000 (04:11 -0500)]
curl-shim: clean up varargs

* keyserver/curl-shim.c (curl_easy_setopt) : ensure that va_end is


stdarg(3) says:
      Each invocation of va_start() must be matched by a
      corresponding invocation of va_end() in the same function.

Observed by Joshua Rogers <>

Debian-Bug-Id: #773475

3 years agogpg: Print better diagnostics for keyserver operations.
Werner Koch [Wed, 18 Feb 2015 11:14:22 +0000 (12:14 +0100)]
gpg: Print better diagnostics for keyserver operations.

* g10/armor.c (parse_key_failed_line): New.
(check_input): Watch out for gpgkeys_ error lines.
* g10/filter.h (armor_filter_context_t): Add field key_failed_code.
* g10/import.c (import): Add arg r_gpgkeys_err.
(import_keys_internal): Ditto.
(import_keys_stream): Ditto.
* g10/keyserver.c (keyserver_errstr): New.
(keyserver_spawn): Detect "KEY " lines while sending.  Get gpgkeys_err
while receiving keys.
(keyserver_work): Add kludge for better error messages.

GnuPG-bug-id: 1832

Note that these changes can be backported to 1.4 but they don't make
sense for 2.1 due to the removal of the keyserver helpers.  The error
reporting could be improved even more but given that this is an old
GnuPG branch it is not justified to put too much effort into it.

Signed-off-by: Werner Koch <>
3 years agokeyserver: Show log prefix when not build with cURL.
Werner Koch [Fri, 13 Feb 2015 10:37:17 +0000 (11:37 +0100)]
keyserver: Show log prefix when not build with cURL.

* keyserver/ksutil.c (init_ks_options) [!HAVE_LIBCURL]: Set logging

Signed-off-by: Werner Koch <>
3 years agoUse inline functions to convert buffer data to scalars.
Werner Koch [Thu, 12 Feb 2015 19:34:44 +0000 (20:34 +0100)]
Use inline functions to convert buffer data to scalars.

* include/host2net.h (buf16_to_ulong, buf16_to_uint): New.
(buf16_to_ushort, buf16_to_u16): New.
(buf32_to_size_t, buf32_to_ulong, buf32_to_uint, buf32_to_u32): New.

This fixes sign extension on shift problems.  Hanno Böck found a case
with an invalid read due to this problem.  To fix that almost all uses
of "<< 24" and "<< 8" are changed by this patch to use an inline
function from host2net.h.

(back ported from commit 2183683bd633818dd031b090b5530951de76f392)

Signed-off-by: Werner Koch <>
3 years agobuild: Update standard build-aux files.
Werner Koch [Wed, 11 Feb 2015 17:51:00 +0000 (18:51 +0100)]
build: Update standard build-aux files.


3 years agodoc: Change remaining http links to to https
Werner Koch [Thu, 12 Feb 2015 18:32:19 +0000 (19:32 +0100)]
doc: Change remaining http links to to https

GnuPG-bug-id: 1830

3 years agogpg: Prevent an invalid memory read using a garbled keyring.
Werner Koch [Thu, 12 Feb 2015 17:58:36 +0000 (18:58 +0100)]
gpg: Prevent an invalid memory read using a garbled keyring.

* g10/keyring.c (keyring_get_keyblock): Whitelist allowed packet

The keyring DB code did not reject packets which don't belong into a
keyring.  If for example the keyblock contains a literal data packet
it is expected that the processing code stops at the data packet and
reads from the input stream which is referenced from the data packets.
Obviously the keyring processing code does not and cannot do that.
However, when exporting this messes up the IOBUF and leads to an
invalid read of sizeof (int).

We now skip all packets which are not allowed in a keyring.

Reported-by: Hanno Böck <>
(back ported from commit f0f71a721ccd7ab9e40b8b6b028b59632c0cc648)

3 years agogpg: Fix a NULL-deref in export due to invalid packet lengths.
Werner Koch [Thu, 12 Feb 2015 17:54:17 +0000 (18:54 +0100)]
gpg: Fix a NULL-deref in export due to invalid packet lengths.

* g10/build-packet.c (write_fake_data): Take care of a NULL stored as
opaque MPI.

Reported-by: Hanno Böck <>
(back ported from commit 0835d2f44ef62eab51fce6a927908f544e01cf8f)

3 years agogpg: Fix a NULL-deref due to empty ring trust packets.
Werner Koch [Thu, 12 Feb 2015 17:52:07 +0000 (18:52 +0100)]
gpg: Fix a NULL-deref due to empty ring trust packets.

* g10/parse-packet.c (parse_trust): Always allocate a packet.

Reported-by: Hanno Böck <>
Signed-off-by: Werner Koch <>
(back ported from commit 39978487863066e59bb657f5fe4e8baab510da7e)

3 years agokbx: Fix resource leak.
Joshua Rogers [Fri, 30 Jan 2015 02:42:52 +0000 (11:42 +0900)]
kbx: Fix resource leak.

* kbx/keybox-update.c (blob_filecopy): Fix resource leak.  On error
return, 'fp' and 'newfp' was never closed.


Signed-off-by: Joshua Rogers <>
[Log entry reformatted, and added more fixes - gniibe]

(cherry picked from commit 7db6c82cec49b7c56c403a8ea98364086baf75f3)

3 years agogpg: Limit the size of key packets to a sensible value.
Werner Koch [Thu, 12 Feb 2015 17:45:08 +0000 (18:45 +0100)]
gpg: Limit the size of key packets to a sensible value.

* g10/parse-packet.c (MAX_KEY_PACKET_LENGTH): New.
(parse_key): Limit the size of a key packet to 256k.
(parse_user_id): Use macro for the packet size limit.
(parse_attribute): Ditto.
(parse_comment): Ditto.

Without that it is possible to force gpg to allocate large amounts of
memory by using a bad encoded MPI.  This would be an too easy DoS.
Another way to mitigate would be to change the MPI read function to
allocate memory dynamically while reading the MPI.  However, that
complicates and possibly slows down the code.  A too large key packet
is in any case a sign for broken data and thus gpg should not use it.

Reported-by: Hanno Böck
GnuPG-bug-id: 1823
Signed-off-by: Werner Koch <>
(back ported from commit 382ba4b137b42d5f25a7e256bb7c053ee5ac7b64)

3 years agoAvoid double-close in unusual dotlock situations.
Werner Koch [Thu, 12 Feb 2015 17:26:58 +0000 (18:26 +0100)]
Avoid double-close in unusual dotlock situations.

* jnlib/dotlock.c (create_dotlock): Avoid double close due to EINTR.

close(2) says:

  close() should not be retried after an EINTR since this may cause a
  reused descriptor from another thread to be closed.

(backported from commit 628b111fa679612e23c0d46505b1ecbbf091897d)

Debian-Bug-Id: 773423
Signed-off-by: Werner Koch <>
3 years agogpg: Allow predefined names as answer to the keygen.algo prompt.
Werner Koch [Wed, 28 Jan 2015 08:11:02 +0000 (09:11 +0100)]
gpg: Allow predefined names as answer to the keygen.algo prompt.

* g10/keygen.c (ask_algo): Add list of strings.

Signed-off-by: Werner Koch <>
(backported from commit b1d5ed6ac842469afcb84868d0f6641dc286a6c7)

3 years agogpg: Print a warning if the subkey expiration may not be what you want.
Werner Koch [Mon, 26 Jan 2015 13:55:24 +0000 (14:55 +0100)]
gpg: Print a warning if the subkey expiration may not be what you want.

* g10/keyedit.c (subkey_expire_warning): New.
keyedit_menu): Call it when needed.
GnuPG-bug-id: 1715

The heuristic to detect a problem is not very advanced but it should
catch the most common cases.

(backported from commit ae3d1bbb65b65cf3c57bb14886be120f5e31635d)

3 years agobuild: Update to gettext 0.19.3.
Werner Koch [Mon, 26 Jan 2015 13:27:46 +0000 (14:27 +0100)]
build: Update to gettext 0.19.3.

3 years agobuild: Require automake 1.14.
Werner Koch [Mon, 26 Jan 2015 13:31:01 +0000 (14:31 +0100)]
build: Require automake 1.14.

* (AUTOMAKE_OPTIONS): Move to ...
* (AM_INIT_AUTOMAKE): here.  Add option serial-tests.
* kbx/ (INCLUDES): Remove.  Include ../am/cmacros.

3 years agopo: Yet another update for Chinese (traditional)
Jedi Lin [Wed, 26 Nov 2014 10:58:03 +0000 (11:58 +0100)]
po: Yet another update for Chinese (traditional)

3 years agoRemove incorrect expression leading to errors.
Joshua Rogers [Fri, 23 Jan 2015 16:03:33 +0000 (03:03 +1100)]
Remove incorrect expression leading to errors.

* scd/ccid-driver.c (send_escape_cmd): Fix setting of 'rc'.

Variable 'rc' in send_escape_cmd was overwritten before it was
returned, leading to incorrect computation.

Signed-off-by: Joshua Rogers <>
[Log entry reformatted - wk]

3 years agogpgconf: Fix validity check for UINT32 values.
Werner Koch [Fri, 23 Jan 2015 14:37:51 +0000 (15:37 +0100)]
gpgconf: Fix validity check for UINT32 values.

* tools/gpgconf-comp.c (option_check_validity): Enable check for

Reported-by: Günther Noack <>
This is actually a bug which inhibited the checking of values of type

Signed-off-by: Werner Koch <>
(cherry picked from commit 3f6abb57a7b5e54b593c5775c8f7a07d61119705)

3 years agotools: Free variable before return
Joshua Rogers [Mon, 22 Dec 2014 13:47:50 +0000 (00:47 +1100)]
tools: Free variable before return

* tools/gpgconf-comp.c: Free 'dest_filename' before it is returned
upon error.

Signed-off-by: Joshua Rogers <>
3 years agosm: Avoid double-free on iconv failure
Daniel Kahn Gillmor [Fri, 19 Dec 2014 23:53:34 +0000 (18:53 -0500)]
sm: Avoid double-free on iconv failure

* sm/minip12.c: (p12_build) if jnlib_iconv_open fails, avoid
double-free of pwbuf.


Observed by Joshua Rogers <>, who proposed a
slightly different fix.

Debian-Bug-Id: 773472

Added fix at a second place - wk.

3 years agoscd: Avoid double-free on error condition in scd
Daniel Kahn Gillmor [Fri, 19 Dec 2014 23:07:55 +0000 (18:07 -0500)]
scd: Avoid double-free on error condition in scd

* scd/command.c (cmd_readkey): avoid double-free of cert


When ksba_cert_new() fails, cert will be double-freed.

Debian-Bug-Id: 773471

Original patch changed by wk to do the free only at leave.

3 years agoavoid future chance of using uninitialized memory
Daniel Kahn Gillmor [Fri, 19 Dec 2014 22:53:36 +0000 (17:53 -0500)]
avoid future chance of using uninitialized memory

* common/iobuf.c: (iobuf_open): initialize len


In iobuf_open, IOBUFCTRL_DESC and IOBUFCTRL_INIT commands are invoked
(via file_filter()) on fcx, passing in a pointer to an uninitialized

With these two commands, file_filter doesn't actually do anything with
the value of len, so there's no actual risk of use of uninitialized
memory in the code as it stands.

However, some static analysis tools might flag this situation with a
warning, and initializing the value doesn't hurt anything, so i think
this trivial cleanup is warranted.

Debian-Bug-Id: 773469

3 years agogpgkey2ssh: clean up varargs
Daniel Kahn Gillmor [Fri, 19 Dec 2014 22:12:05 +0000 (17:12 -0500)]
gpgkey2ssh: clean up varargs

* tools/gpgkey2ssh.c (key_to_blob) : ensure that va_end is called.


stdarg(3) says:
       Each invocation of va_start() must be matched by a
       corresponding invocation of va_end() in the same function.

Observed by Joshua Rogers <>

Debian-Bug-Id: 773415

3 years agodoc: Fix memory leak in yat2m.
Werner Koch [Mon, 22 Dec 2014 11:44:13 +0000 (12:44 +0100)]
doc: Fix memory leak in yat2m.

* doc/yat2m.c (write_th): Free NAME.

Reported-by: Joshua Rogers <>
3 years agogpgsm: Return NULL on fail
Werner Koch [Mon, 22 Dec 2014 11:16:46 +0000 (12:16 +0100)]
gpgsm: Return NULL on fail

* sm/gpgsm.c (parse_keyserver_line): Set SERVER to NULL.


Cherry-pick of abd5f6752d693b7f313c19604f0723ecec4d39a6.

Reported-by: Joshua Rogers <>
  "If something inside the ldapserver_parse_one function failed,
   'server' would be freed, then returned, leading to a
   use-after-free.  This code is likely copied from sm/gpgsm.c, which
   was also susceptible to this bug."

Signed-off-by: Werner Koch <>
3 years agogpg: Fix possible read of unallocated memory
Werner Koch [Fri, 12 Dec 2014 09:41:25 +0000 (10:41 +0100)]
gpg: Fix possible read of unallocated memory

* g10/parse-packet.c (can_handle_critical): Check content length
before calling can_handle_critical_notation.

The problem was found by Jan Bee and gniibe proposed the used fix.

This bug can't be exploited: Only if the announced length of the
notation is 21 or 32 a memcmp against fixed strings using that length
would be done.  The compared data is followed by the actual signature
and thus it is highly likely that not even read of unallocated memory
will happen.  Nevertheless such a bug needs to be fixed.

Signed-off-by: Werner Koch <>
3 years agoscd: Fix possibly inhibited checkpin of the admin pin.
Werner Koch [Fri, 12 Dec 2014 19:08:45 +0000 (20:08 +0100)]
scd: Fix possibly inhibited checkpin of the admin pin.

* scd/app-openpgp.c (do_check_pin): Do not check a byte of a released

Signed-off-by: Werner Koch <>
3 years agoscd: fix get_public_key for OpenPGPcard v1.0.
Joshua Rogers [Sat, 20 Dec 2014 00:38:53 +0000 (11:38 +1100)]
scd: fix get_public_key for OpenPGPcard v1.0.

* scd/app-openpgp.c (get_public_key): correctly close 'fp' upon use.


Inside the get_public_key function, 'fp' was opened using popen, but
incorrectly closed using fclose.

Debian-Bug-Id: 773474

4 years agogpg: release DEK soon after its use.
NIIBE Yutaka [Fri, 12 Dec 2014 08:41:56 +0000 (17:41 +0900)]
gpg: release DEK soon after its use.

* g10/keygen.c (generate_subkeypair): Release DEK soon.


This fixes the out_of_core error in the test case of adding
RSA-4096 subkey to RSA-4096 primary key with configuration:

    s2k-cipher-algo S10

Debian-bug-id: 772780

Cherry-picked da66ad5bba4215b9ddd0cb927a89aa75355632aa from
STABLE-BRANCH-1-4 branch.

4 years agopo: Update French translation
David Prévot [Mon, 3 Nov 2014 03:24:09 +0000 (23:24 -0400)]
po: Update French translation

4 years agopo: Update Danish translation
David Prévot [Sun, 16 Nov 2014 21:00:18 +0000 (17:00 -0400)]
po: Update Danish translation

4 years agopo: Update Ukrainian translation
Yuri Chornoivan [Wed, 26 Nov 2014 10:04:49 +0000 (11:04 +0100)]
po: Update Ukrainian translation

4 years agopo: Update Chinese (traditional) translation
Jedi Lin [Tue, 18 Nov 2014 21:12:29 +0000 (17:12 -0400)]
po: Update Chinese (traditional) translation

4 years agopo: Update Russian translation
Ineiev [Tue, 18 Nov 2014 21:30:00 +0000 (17:30 -0400)]
po: Update Russian translation

4 years agopo: Update pl.po
Jakub Bogusz [Wed, 26 Nov 2014 09:56:37 +0000 (10:56 +0100)]
po: Update pl.po


4 years agopo: Convert pl.po to utf-8
Werner Koch [Wed, 26 Nov 2014 09:54:24 +0000 (10:54 +0100)]
po: Convert pl.po to utf-8


4 years agopo: New Dutch translation
Frans Spiesschaert [Tue, 25 Nov 2014 19:46:25 +0000 (15:46 -0400)]
po: New Dutch translation

* po/LINGUAS: Add nl.po.
Debian-Bug-Id: 770981

4 years agopo: Update es.po
Manuel "Venturi" Porras Peralta [Wed, 26 Nov 2014 09:37:37 +0000 (10:37 +0100)]
po: Update es.po


4 years agopo: Convert es.po to utf-8
Werner Koch [Wed, 26 Nov 2014 09:36:08 +0000 (10:36 +0100)]
po: Convert es.po to utf-8


4 years agogpg: Fix use of uninit.value in listing sig subpkts.
Werner Koch [Mon, 24 Nov 2014 18:24:47 +0000 (19:24 +0100)]
gpg: Fix use of uninit.value in listing sig subpkts.

* g10/parse-packet.c (dump_sig_subpkt): Print regex subpacket

We may not use "%s" to print an arbitrary buffer.  At least "%.*s"
should have been used.  However, it is in general preferable to escape
control characters while printf user data.

Reported-by: Hanno Böck
Signed-off-by: Werner Koch <>
(backported from commit 596ae9f5433ca3b0e01f7acbe06fd2e424c42ae8)

4 years agogpg: Fix off-by-one read in the attribute subpacket parser.
Werner Koch [Mon, 24 Nov 2014 18:12:37 +0000 (19:12 +0100)]
gpg: Fix off-by-one read in the attribute subpacket parser.

* g10/parse-packet.c (parse_attribute_subpkts): Check that the
attribute packet is large enough for the subpacket type.

Reported-by: Hanno Böck
Signed-off-by: Werner Koch <>
(backported from commit 0988764397f99db4efef1eabcdb8072d6159af76)

4 years agogpg: Fix a NULL-deref for invalid input data.
Werner Koch [Mon, 24 Nov 2014 17:19:31 +0000 (18:19 +0100)]
gpg: Fix a NULL-deref for invalid input data.

* g10/mainproc.c (proc_encrypted): Take care of canceled passpharse

GnuPG-bug-id: 1761
Signed-off-by: Werner Koch <>
(backported from commit 32e85668b82f6fbcb824eea9548970804fb41d9e)

4 years agopo: Update Japanese translation.
NIIBE Yutaka [Tue, 18 Nov 2014 02:19:51 +0000 (11:19 +0900)]
po: Update Japanese translation.


4 years agogpg: Make the use of "--verify FILE" for detached sigs harder.
Werner Koch [Fri, 14 Nov 2014 08:36:19 +0000 (09:36 +0100)]
gpg: Make the use of "--verify FILE" for detached sigs harder.

* g10/openfile.c (open_sigfile): Factor some code out to ...
(get_matching_datafile): new function.
* g10/plaintext.c (hash_datafiles): Do not try to find matching file
in batch mode.
* g10/mainproc.c (check_sig_and_print): Print a warning if a possibly
matching data file is not used by a standard signatures.

Allowing to use the abbreviated form for detached signatures is a long
standing bug which has only been noticed by the public with the
release of 2.1.0.  :-(

What we do is to remove the ability to check detached signature in
--batch using the one file abbreviated mode.  This should exhibit
problems in scripts which use this insecure practice.  We also print a
warning if a matching data file exists but was not considered because
the detached signature was actually a standard signature:

  gpgv: Good signature from "Werner Koch (dist sig)"
  gpgv: WARNING: not a detached signature; \
  file 'gnupg-2.1.0.tar.bz2' was NOT verified!

We can only print a warning because it is possible that a standard
signature is indeed to be verified but by coincidence a file with a
matching name is stored alongside the standard signature.

Reported-by: Simon Nicolussi (to gnupg-users on Nov 7)
Signed-off-by: Werner Koch <>
(backported from commit 69384568f66a48eff3968bb1714aa13925580e9f)

4 years agogpg: Add import option "keep-ownertrust".
Werner Koch [Wed, 12 Nov 2014 08:56:40 +0000 (09:56 +0100)]
gpg: Add import option "keep-ownertrust".

* g10/options.h (IMPORT_KEEP_OWNERTTRUST): New.
* g10/import.c (parse_import_options): Add "keep-ownertrust".
(import_one): Act upon new option.

This option is in particular useful to convert from a pubring.gpg to
the new pubring.kbx in GnuPG 2.1 or vice versa:

gpg1 --export | gpg2 --import-options keep-ownertrust --import

(cherry-picked from commit ffc2307843ce6c4ac3c8d99ba8c70ffa1ae28e39)

4 years agogpg: Show v3 key fingerprints as all zero.
Werner Koch [Sat, 11 Oct 2014 17:44:13 +0000 (19:44 +0200)]
gpg: Show v3 key fingerprints as all zero.

* g10/keyid.c (fingerprint_from_pk): Show v3 fingerprints as all zero.

MD5 is considered broken for a long time now.  To make it easier for
users to notice that a listing shows a v3 key, the fingerprint is now
displayed as 16 zero bytes unless --allow-weak-digest-algos is active.

Signed-off-by: Werner Koch <>
4 years agogpg: Avoid using cached MD5 signature status.
Werner Koch [Sat, 11 Oct 2014 17:41:51 +0000 (19:41 +0200)]
gpg: Avoid using cached MD5 signature status.

* g10/sig-check.c (check_key_signature2): Avoid using a cached MD5
signature status.
* g10/keyring.c (keyring_get_keyblock): Ditto.
(write_keyblock): Ditto.

* g10/sig-check.c (do_check): Move reject warning to ...
* g10/misc.c (print_md5_rejected_note): new.

Signed-off-by: Werner Koch <>
4 years agogpg: Add build and runtime support for larger RSA keys
Daniel Kahn Gillmor [Fri, 3 Oct 2014 17:59:34 +0000 (13:59 -0400)]
gpg: Add build and runtime support for larger RSA keys

* Added --enable-large-secmem option.
* g10/options.h: Add opt.flags.large_rsa.
* g10/gpg.c: Contingent on configure option: adjust secmem size,
add gpg --enable-large-rsa, bound to opt.flags.large_rsa.
* g10/keygen.c: Adjust max RSA size based on opt.flags.large_rsa
* doc/gpg.texi: Document --enable-large-rsa.


This is a cherry-pick of 534e2876acc05f9f8d9b54c18511fe768d77dfb5 from

Some older implementations built and used RSA keys up to 16Kib, but
the larger secret keys now fail when used by more recent GnuPG, due to
secure memory limitations.

Building with ./configure --enable-large-secmem will make gpg
capable of working with those secret keys, as well as permitting the
use of a new gpg option --enable-large-rsa, which let gpg generate RSA
keys up to 8Kib when used with --batch --gen-key.

Debian-bug-id: 739424

Minor edits by wk.

GnuPG-bug-id: 1732

4 years agobuild: Update m4 scripts
Werner Koch [Thu, 2 Oct 2014 14:17:45 +0000 (16:17 +0200)]
build: Update m4 scripts

* m4/gpg-error.m4: Update from Libgpg-error git master.
* m4/libgcrypt.m4: Update from Libgcrypt git master.
* Declare SYSROOT a precious variable.  Add extra error
message for library configuration mismatches.

4 years agogpg: --compress-sigs and --compress-keys are not no-ops in 2.0
Daniel Kahn Gillmor [Mon, 29 Sep 2014 21:49:53 +0000 (17:49 -0400)]
gpg: --compress-sigs and --compress-keys are not no-ops in 2.0

* g10/gpg.c: Cleanup argument parsing.


c76117f8b0165fe5cec5e7f234f55f5a4cd7f0ab mistakenly marked
compress-sigs and compress-keys as no-ops on the 2.0.x branch.

These options still have an effect on the 2.0.x branch, and the
duplicate declaration also causes the gpg argument parser to fail when
shortened versions of the option are present, like:

  gpg: option "--compress-k" is ambiguous

4 years agogpg: Avoid duplicate declaration of {no-,}sk-comments noops.
Daniel Kahn Gillmor [Mon, 29 Sep 2014 21:49:52 +0000 (17:49 -0400)]
gpg: Avoid duplicate declaration of {no-,}sk-comments noops.

* g10/gpg.c: Cleanup argument parsing.


With c76117f8b0165fe5cec5e7f234f55f5a4cd7f0ab, the GnuPG 2.0.x branch
accidentally introduced a second (identical) argument parser for both
--sk-comments, and for --no-sk-comments.

This caused short versions (e.g. omitting the trailing "s", as gpgme
does) of either command to fail with:

   gpg: option "--sk-comment" is ambiguous

4 years agogpg: Default to SHA-256 for all signature types on RSA keys.
Werner Koch [Sat, 27 Sep 2014 13:21:02 +0000 (15:21 +0200)]
gpg: Default to SHA-256 for all signature types on RSA keys.

* g10/main.h (DEFAULT_DIGEST_ALGO): Use SHA256 in --gnupg and SHA1 in
strict RFC or PGP modes.
* g10/sign.c (make_keysig_packet): Use DEFAULT_DIGEST_ALGO also for
RSA key signatures.

(Backported from commit d33246700578cddd1cb8ed8164cfbba50aba4ef3)

4 years agodoc: Update the file OpenPGP
Werner Koch [Sat, 27 Sep 2014 09:17:07 +0000 (11:17 +0200)]
doc: Update the file OpenPGP


It should actually be completey reworked but for now I added just a
few notes.

4 years agogpg: Add shortcut for setting key capabilities.
Werner Koch [Fri, 26 Sep 2014 12:43:48 +0000 (14:43 +0200)]
gpg: Add shortcut for setting key capabilities.

* g10/keygen.c (ask_key_flags): Add shortcut '='.
* doc/help.txt (gpg.keygen.flags): New.

4 years agogpg: Warn about (but don't fail) on scdaemon options in gpg.conf.
Daniel Kahn Gillmor [Thu, 25 Sep 2014 18:45:37 +0000 (14:45 -0400)]
gpg: Warn about (but don't fail) on scdaemon options in gpg.conf.

* g10/gpg.c: Add config options that should belong in scdaemon.conf
* g10/main.h, g10/misc.c (obsolete_scdaemon_option): New.


In gpg2, the following options are only relevant for scdaemon:


but in gpg1, they are options for gpg itself.

Some users of gpg1 might have these options in their
~/.gnupg/gpg.conf, which causes gpg2 to fail hard if it reads that
config file.

gpg2 should not fail hard, though giving a warning (and suggesting a
move to scdaemon.conf) seems OK.

This patch does *not* reintroduce any documentation for these options
in gpg.texi, even to indicate that they are "dummy" options, since
scdaemon.texi contains the appropriate documentation.

Debian-bug-id: 762844

Program names factored out from obsolete_scdaemon_option to make
reuse without new translations easier. -wk

This is a backport of commit 371c2b14b0347209efd23b4e54e1981a12d7aeab
with parts of 20c6da50d4f6264d26d113d7de606971f719a0ca but without those
which would change existing translated strings. -wk

4 years agogpg: Need to init the trustdb for import.
Kristian Fiskerstrand [Wed, 13 Aug 2014 09:13:34 +0000 (11:13 +0200)]
gpg: Need to init the trustdb for import.

* g10/trustdb.c (clear_ownertrusts): Init trustdb.


This was fixed in 1.4 branch in commit
23191d7851eae2217ecdac6484349849a24fd94a but was not applied to the
2.0 branch that exhibits the same problem. This is actually a hack
to fix a bug introduced with commit 2528178.

GnuPG-bug-id: 1622

4 years agobuild: Print an error message if zlib is not installed.
Werner Koch [Tue, 26 Aug 2014 14:13:21 +0000 (16:13 +0200)]
build: Print an error message if zlib is not installed.

* (missing_zlib): New.

4 years agogpg: Allow for positional parameters in the passphrase prompt.
Werner Koch [Tue, 26 Aug 2014 08:16:04 +0000 (10:16 +0200)]
gpg: Allow for positional parameters in the passphrase prompt.

* g10/passphrase.c (passphrase_get): Replace sprintf by xasprintf.

Without that at least the French translation does not always work
because it requires positional parameters.  Windows for example does
not support them as they are not defined by C99 but by POSIX.

4 years agoPost release updates.
Werner Koch [Tue, 12 Aug 2014 08:36:30 +0000 (10:36 +0200)]
Post release updates.


4 years agoRelease 2.0.26 gnupg-2.0.26
Werner Koch [Tue, 12 Aug 2014 08:36:30 +0000 (10:36 +0200)]
Release 2.0.26

4 years agopo: Auto-update due to removed string.
Werner Koch [Tue, 12 Aug 2014 08:36:30 +0000 (10:36 +0200)]
po: Auto-update due to removed string.