16 months agopo: Update Japanese translation.
NIIBE Yutaka [Mon, 18 Dec 2017 05:09:53 +0000 (14:09 +0900)]
po: Update Japanese translation.

* po/ja.po: Fix message with no "%s".


Backport of master commit from: 77e2fcb4ffbad8577a2cf41f17bf92dec6a93ad8

The wrong message caused segmentation fault for key generation when
no expiration is specified.

GnuPG-bug-id: 3619
Signed-off-by: NIIBE Yutaka <>
16 months agog10: Fix regexp sanitization.
NIIBE Yutaka [Thu, 9 Nov 2017 05:03:22 +0000 (14:03 +0900)]
g10: Fix regexp sanitization.

* g10/trustdb.c (sanitize_regexp): Only escape operators.


Backport from master commit:

To sanitize a regular expression, quoting by backslash should be only
done for defined characters.  POSIX defines 12 characters including
dot and backslash.

Quoting other characters is wrong, in two ways; It may build an
operator like: \b, \s, \w when using GNU library.  Case ignored match
doesn't work, because quoting lower letter means literally and no
much to upper letter.

GnuPG-bug-id: 2923
Co-authored-by: Damien Goutte-Gattat <>
Signed-off-by: NIIBE Yutaka <>
21 months agogpgsm: Allow ciphers AES192 and SERPENT256
Werner Koch [Tue, 14 Jun 2016 13:57:57 +0000 (15:57 +0200)]
gpgsm: Allow ciphers AES192 and SERPENT256

* sm/gpgsm.c (main): Add AES192 cipher.  Allow SERPENT256.

Note that currently released Libcgrypt versions miss OIDs for Serpent
and thus Serpent can only be used with tye forthcoming Libgcrypt

(backport of master commit 5f9bd7a9e1ed4edcbb6c4e908d4bea5cd7dc9e68)

GnuPG-bug-id: 2273, 2934
Signed-off-by: Werner Koch <>
2 years agogpg: Fix export porting of zero length user ID packets.
Werner Koch [Thu, 30 Mar 2017 08:35:20 +0000 (10:35 +0200)]
gpg: Fix export porting of zero length user ID packets.

* g10/build-packet.c (do_user_id): Avoid indeterminate length header.

We are able to import such user ids but when exporting them the
exported data could not be imported again because the parser bails out
on invalid keyrings.  This is now fixed and should be backported.

Note that in 2.0 this is only an issue for attribute packets.  In 2.1
user IDs were also affected.a

Signed-off-by: Werner Koch <>
2 years agoscd: Support OpenPGP card V3 for RSA.
NIIBE Yutaka [Fri, 25 Nov 2016 07:12:26 +0000 (16:12 +0900)]
scd: Support OpenPGP card V3 for RSA.

* scd/app-openpgp.c (struct app_local_s): Remove max_cmd_data and
max_rsp_data fields as Extended Capabilities bits are different.
(get_cached_data) Use extcap.max_certlen_3.
(get_one_do): Don't use exmode=1.
(determine_rsa_response): New.
(get_public_key, do_genkey): Call determine_rsa_response.
(do_sign): Use keyattr[0].rsa.n_bits / 8, instead of max_rsp_data.
(do_auth): Use keyattr[2].rsa.n_bits / 8, instead of max_rsp_data.
(do_decipher): Likewise with Use keyattr[1].rsa.n_bits / 8.
(show_caps): Remove max_cmd_data and max_rsp_data.
(app_select_openpgp): Likewise.

Backport of master commit: b89e63e5c326af71470124b410e6429cbd2b5c43

OpenPGP card V3 had introduced incompatible change in Extended
Capabilities bits.  We can work around by this change by not
using those bits.

Signed-off-by: NIIBE Yutaka <>
2 years agoscd: Fix receive buffer size.
NIIBE Yutaka [Tue, 22 Nov 2016 11:53:57 +0000 (20:53 +0900)]
scd: Fix receive buffer size.

* scd/apdu.c (send_le): Fix the size, adding two for status
bytes to Le.

Backport of master commit: 5c2db9dedfe9dbb14ffec24751ca23a69cead94e

This is long standing bug.  So far, Le was not exact value.
Since forthcoming change will introduce exact value of expected length
of response data, this change is needed.

Signed-off-by: NIIBE Yutaka <>
2 years agoscd: Don't limit to ST-2xxx for PC/SC.
NIIBE Yutaka [Thu, 17 Nov 2016 23:54:04 +0000 (08:54 +0900)]
scd: Don't limit to ST-2xxx for PC/SC.

* scd/apdu.c (pcsc_vendor_specific_init): Only check vender ID.

Backport of master commit: b6066ab18a67195817babaf9eccf896c2b3c7b0e

Some other products by Cherry works with pinpad, although it only works
for smaller keys (RSA 1024).  TPDU support is good for larger keys.

Signed-off-by: NIIBE Yutaka <>
2 years agoscd: Fix status info encoding.
NIIBE Yutaka [Mon, 14 Nov 2016 01:25:43 +0000 (10:25 +0900)]
scd: Fix status info encoding.

* scd/command.c (send_status_info): Do percent plus encoding correctly.

Backport of master commit: 4ee4d0b02172cf56d9582bb99e32a65c75315b25

Reported-by: David Härdeman <>
Signed-off-by: NIIBE Yutaka <>
2 years agoscd: minor cleanup to merge other works.
NIIBE Yutaka [Tue, 18 Oct 2016 11:40:09 +0000 (20:40 +0900)]
scd: minor cleanup to merge other works.

* scd/iso7816.c (do_generate_keypair): Use const char * for DATA.
(iso7816_generate_keypair, iso7816_read_public_key): Likewise.
* scd/app-openpgp.c (get_public_key): Follow the change.
(do_genkey): Ditto.  Use ERR instead of RC.  Use u32 for CREATED_AT.
Backport of master commit: f1845f25dbea79c191427710fa56ed01e63a045b

Signed-off-by: NIIBE Yutaka <>
2 years agoscd: Fix an action after card removal.
NIIBE Yutaka [Sat, 3 Sep 2016 06:27:30 +0000 (15:27 +0900)]
scd: Fix an action after card removal.

* scd/command.c (update_card_removed): Call apdu_close_reader here.

Backport of master commit: f9e49c80e706a27d5e30d4b3237ff26367a67130

This is update of the commit 8fe81055762d9c9e6f03fb7853a985c94ef73ac3
It is better apdu_close_reader is called in update_card_removed.

The commit 1598a4476466822e7e9c757ac471089d3db4b545 introduced a
regression, it doesn't close the reader after removal of the card, while
the code before the commit call apdu_close_reader in do_reset.
So, this fix.

GnuPG-bug-id: 2449
Signed-off-by: NIIBE Yutaka <>
2 years agoscd: Release the card reader after card removal.
NIIBE Yutaka [Fri, 2 Sep 2016 05:45:26 +0000 (14:45 +0900)]
scd: Release the card reader after card removal.

* scd/command.c (update_reader_status_file): Call apdu_close_reader.

Backport of master commit: 8fe81055762d9c9e6f03fb7853a985c94ef73ac3

GnuPG-bug-id: 2651
Signed-off-by: NIIBE Yutaka <>
2 years agoscd: Clean up unused shutdown method.
NIIBE Yutaka [Fri, 2 Sep 2016 04:58:33 +0000 (13:58 +0900)]
scd: Clean up unused shutdown method.

* scd/apdu.c (shutdown_ccid_reader, apdu_shutdown_reader): Remove.
(reset_ccid_reader): Don't set shutdown_reader.
* scd/ccid-driver.c (ccid_shutdown_reader): Remove.

Backport of master commit: d1ae7103352fbda2a05f098379cd3043a0ab5566

Signed-off-by: NIIBE Yutaka <>
2 years agoscd: Fix card removal/reset on multiple contexts.
NIIBE Yutaka [Wed, 20 Jul 2016 02:35:05 +0000 (11:35 +0900)]
scd: Fix card removal/reset on multiple contexts.

* scd/app.c (application_notify_card_reset): Add message for debug.
*scd/command.c (update_card_removed): Call release_application and set
SLOT -1 here.
(struct server_local_s): Remove app_ctx_marked_for_release.
(do_reset): Don't mark release but call release_application here.
(open_card): Remove app_ctx_marked_for_release handling.
(update_reader_status_file): Don't set SLOT here, so that it can be
released the APP by application_notify_card_reset in
Backport of master commit: 1598a4476466822e7e9c757ac471089d3db4b545

Signed-off-by: NIIBE Yutaka <>
2 years agoscd: Fix race conditions for release_application.
NIIBE Yutaka [Tue, 19 Jul 2016 01:53:39 +0000 (10:53 +0900)]
scd: Fix race conditions for release_application.

* scd/command.c (do_reset, cmd_restart): Reset app_ctx before calling

Backport of master commit: 0c1fd4e9884ed7c1edd1819762b9e8a77f606ed3

Thanks to Ben Warren for the report.

Signed-off-by: NIIBE Yutaka <>
2 years agoscd: Make option --homedir work.
Werner Koch [Fri, 17 Jun 2016 06:36:07 +0000 (08:36 +0200)]
scd: Make option --homedir work.

* scd/scdaemon.c (opts): Add --homedir.
Backport of master commit: def512eb67c8a380f3b873cee0f156deef0b6dda

Without that entry the homedir setting won't work.

GnuPG-bug-id: 2386
Signed-off-by: Werner Koch <>
2 years agoscd: More fix of error return path.
NIIBE Yutaka [Mon, 2 May 2016 06:56:02 +0000 (15:56 +0900)]
scd: More fix of error return path.

* scd/command.c (open_card): Return GPG_ERR_ENODEV on the failure of

Backport of master commit: 6677d8b61446eb5760a30a2488c992d6e895a9ed

GnuPG-bug-id: 2306
Signed-off-by: NIIBE Yutaka <>
2 years agoscd: Improve error handling.
Justus Winter [Tue, 17 Nov 2015 17:05:51 +0000 (18:05 +0100)]
scd: Improve error handling.

* scd/app-openpgp.c (get_public_key): Improve error handling.
Backport master commit: 6a37b45a7f13cf5d2ae7d6c9cd796a4bd197b80d

Found using the Clang Static Analyzer.

Signed-off-by: Justus Winter <>
2 years agoscd: Fix error handling with libusb-compat library.
NIIBE Yutaka [Wed, 4 Nov 2015 12:07:49 +0000 (21:07 +0900)]
scd: Fix error handling with libusb-compat library.

* scd/ccid-driver.c (bulk_out): Use LIBUSB_ERRNO_NO_SUCH_DEVICE.


With libusb-compat library, the error is different than original
libusb.  (The libusb-compat library is used by Fedora.)

Backport of master commit: 1e94a672efb8bf66f416bc63bf6670e509a21fe5

2 years agoscd: Handle error correctly.
NIIBE Yutaka [Mon, 28 Sep 2015 04:41:59 +0000 (13:41 +0900)]
scd: Handle error correctly.

* scd/apdu.c (apdu_connect): Initialize variables and check an error
of apdu_get_status_internal.

Backport from master commit: 6bb7206e357acfd7276a8f1334c0f0c9cc6ed100

2 years agoscd: KEYNO cleanup.
NIIBE Yutaka [Mon, 7 Sep 2015 04:09:01 +0000 (13:09 +0900)]
scd: KEYNO cleanup.

* scd/app-openpgp.c (get_public_key, send_keypair_info, do_readkey)
(change_keyattr, change_keyattr_from_string, ecc_writekey, do_genkey)
(compare_fingerprint, check_against_given_fingerprint): KEYNO starts
from 0.

Backport of master commit: fd689e85423d0d80d725f0315c52d94f0e9766f8

2 years agoscd: Use cipher.h for constants.
NIIBE Yutaka [Fri, 17 Jul 2015 00:34:47 +0000 (09:34 +0900)]
scd: Use cipher.h for constants.

* scd/app-openpgp.c: Include cipher.h.

Backport from master commit:f5d356fb5bbbd0e05a753612455253e4bc335266

2 years agogpg: Avoid publishing the GnuPG version by default
Daniel Kahn Gillmor [Fri, 5 Aug 2016 14:47:51 +0000 (10:47 -0400)]
gpg: Avoid publishing the GnuPG version by default

* g10/gpg.c (main): initialize opt.emit_version to 0
* doc/gpg.texi: document different default for --emit-version


The version of GnuPG in use is not particularly helpful.  It is not
cryptographically verifiable, and it doesn't distinguish between
significant version differences like 2.0.x and 2.1.x.

Additionally, it leaks metadata that can be used to distinguish users
from one another, and can potentially be used to target specific
attacks if there are known behaviors that differ between major

It's probably better to take the more parsimonious approach to
metadata production by default.

(backport of master commit c9387e41db7520d176edd3d6613b85875bdeb32c)

Signed-off-by: Daniel Kahn Gillmor <>
2 years agog10: Fix checking key for signature validation.
NIIBE Yutaka [Thu, 4 Aug 2016 07:21:39 +0000 (16:21 +0900)]
g10: Fix checking key for signature validation.

* g10/sig-check.c (signature_check2): Not only subkey, but also primary
key should have flags.valid=1.


(backport of master
commit 6f284e6ed63f514b15fe610f490ffcefc87a2164)

Signed-off-by: NIIBE Yutaka <>
2 years agogpgv: Tweak default options for extra security.
NIIBE Yutaka [Sat, 9 Jul 2016 01:20:02 +0000 (10:20 +0900)]
gpgv: Tweak default options for extra security.

* g10/gpgv.c (main): Set opt.no_sig _cache, so that it doesn't depend on
cached status.  Similarly, set opt.flags.require_cross_cert for backsig
validation for subkey signature.


(backport of master
commit e32c575e0f3704e7563048eea6d26844bdfc494b)

It is common that an organization distributes binary keyrings with
signature cache (Tag 12, Trust Packet) and people use gpgv to validate
signature with such keyrings.  In such a use case, it is possible that
the key validation itself is skipped.

For the purpose of gpgv validation of signatures, we should not depend
on signature cache in keyrings (if any), but we should validate the key
by its self signature for primary key, and back signature for subkey.

Signed-off-by: NIIBE Yutaka <>
2 years agog10: Fix keysize with --expert.
NIIBE Yutaka [Wed, 6 Jul 2016 02:45:05 +0000 (11:45 +0900)]
g10: Fix keysize with --expert.

* g10/keygen.c (ask_keysize): It's 768 only for DSA.


(forwardport of
1.4 commit ca1fc596267b42a894a3fc85c3733007c672ed1f)

GnuPG-bug-id: 2238
Signed-off-by: NIIBE Yutaka <>
2 years agog10: Fix --list-packets.
NIIBE Yutaka [Tue, 28 Jun 2016 06:56:48 +0000 (15:56 +0900)]
g10: Fix --list-packets.

* g10/gpg.c (main): Call set_packet_list_mode after assignment of
* g10/mainproc.c (do_proc_packets): Don't stop processing with
--list-packets as the comment says.
* g10/options.h (list_packets): Fix the comment.
* g10/parse-packet.c: Fix the condition for opt.list_packets.


(backport of master
commit 52f65281f9743c42a48bf5a3354c9ab0ecdb681a)

Debian-bug-id: 828109
Signed-off-by: NIIBE Yutaka <>
2 years agog10: Fix card-edit/fetch to use keyserver_fetch.
NIIBE Yutaka [Thu, 23 Jun 2016 03:12:43 +0000 (12:12 +0900)]
g10: Fix card-edit/fetch to use keyserver_fetch.

* g10/card-util.c (fetch_url): Call keyserver_fetch instead of

Signed-off-by: NIIBE Yutaka <>
GnuPG-bug-id: 1828
(backport of master
commit 6f5ff1cfe449cf1f4cb7287bc57570eb794216b2)

2 years agoscd: Reset nonnull_nad to zero for VENDOR_GEMPC.
Niibe Yutaka [Sun, 19 Jun 2016 02:24:50 +0000 (11:24 +0900)]
scd: Reset nonnull_nad to zero for VENDOR_GEMPC.

* (parse_ccid_descriptor): nonnull_nad = 0 for all GEMPC device.


We can't use the driver for 08E6:3438, while it works well under PC/SC
service.  I found that the library of ccid always uses the node
address = ZERO for all transactions.  So, we extend the same handling
for not only GEMPC_CT30, but also for all its devices.

Debian-bug-id: 814584
Signed-off-by: NIIBE Yutaka <>
(backport form master
commit 971064f8b7ad676326b2a468f688037a303717df)

2 years agog10: Fix another race condition for trustdb access.
Niibe Yutaka [Tue, 14 Jun 2016 23:41:56 +0000 (08:41 +0900)]
g10: Fix another race condition for trustdb access.

* g10/tdbio.c (create_version_record): Call create_hashtable to always
make hashtable, together with the version record.
(get_trusthashrec): Remove call to create_hashtable.


GnuPG-bug-id: 1675
Thanks to Scott Moser to reproducible script and patience.

Signed-off-by: NIIBE Yutaka <>
(backport from master
 commit 35a3ce2acf78a95fecbccfd8db0560cca24232df)

3 years agodoc: Remove description of --faked-system-time from gpg.texi
Werner Koch [Fri, 8 Apr 2016 06:30:14 +0000 (08:30 +0200)]
doc: Remove description of --faked-system-time from gpg.texi


This option is only available in 2.1.

3 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 <>
3 years agoPost release updates
Werner Koch [Thu, 31 Mar 2016 10:58:31 +0000 (12:58 +0200)]
Post release updates


3 years agoRelease 2.0.30 gnupg-2.0.30
Werner Koch [Thu, 31 Mar 2016 10:47:24 +0000 (12:47 +0200)]
Release 2.0.30

3 years agopo: Auto update
Werner Koch [Thu, 31 Mar 2016 09:48:35 +0000 (11:48 +0200)]
po: Auto update


3 years agodoc: Update
Ineiev [Thu, 31 Mar 2016 08:51:39 +0000 (10:51 +0200)]
doc: Update

3 years agobuild: Create *.swdb file during make distcheck.
Werner Koch [Thu, 31 Mar 2016 08:36:48 +0000 (10:36 +0200)]
build: Create *.swdb file during make distcheck.

* (distcheck-hook): New.

Signed-off-by: Werner Koch <>
3 years agogpg: Silence trustdb messages with --quiet.
Werner Koch [Thu, 31 Mar 2016 08:33:30 +0000 (10:33 +0200)]
gpg: Silence trustdb messages with --quiet.

* g10/trustdb.c (validate_keys): Silence messages

Signed-off-by: Werner Koch <>
3 years agoagent: Do not remove the ssh socket.
Justus Winter [Wed, 2 Mar 2016 15:41:04 +0000 (16:41 +0100)]
agent: Do not remove the ssh socket.

* agent/gpg-agent.c (create_server_socket): Also inhibit the removal
of the ssh socket if another agent process is already running.

GnuPG modern is not affected.

GnuPG-bug-id: 2258
Signed-off-by: Justus Winter <>
3 years agog10: Make sure to have the directory for trustdb.
NIIBE Yutaka [Fri, 12 Feb 2016 01:15:52 +0000 (10:15 +0900)]
g10: Make sure to have the directory for trustdb.

* g10/tdbio.c (tdbio_set_dbname): Return earlier if !CREATE.  Check
the directory and create it if none before calling take_write_lock.


Thanks to Marc Deslauriers for the bug report and his patch.

GnuPG-bug-id: 2246

Signed-off-by: NIIBE Yutaka <>
(backport from master
 commit 2f3e42047d17313eeb38d354048f343158402a8d)

3 years agocommon: Cope with AIX problem on number of open files.
Werner Koch [Fri, 15 Jan 2016 14:32:18 +0000 (15:32 +0100)]
common: Cope with AIX problem on number of open files.

* common/exechelp.c: Limit returned value for too hight values.

GnuPG-bug-id: 1778

(backport from master commit 987532b038a2d9b9e76c0de425ee036ca2bffa1b)

Signed-off-by: Werner Koch <>
3 years agoFix to support git worktree.
NIIBE Yutaka [Wed, 13 Jan 2016 08:22:37 +0000 (17:22 +0900)]
Fix to support git worktree.

* Use -e for testing .git.

Signed-off-by: NIIBE Yutaka <>
(backport commit of 96237b9a63a50aed1884cb06f84279b977d6a8fa)

3 years agosm: Handle gcry_pk_encrypt return value.
NIIBE Yutaka [Tue, 15 Dec 2015 03:38:25 +0000 (12:38 +0900)]
sm: Handle gcry_pk_encrypt return value.

* sm/encrypt.c (encrypt_dek): Don't ignore failure of gcry_pk_encrypt.


Thanks to Sami Farin.

GnuPG-bug-id: 2154

(backport commit of 4ee881bff4c8fdfa4b3b7a4b7afab611471e97f1)

3 years agoscd: Fix commit 9a9bfd77.
NIIBE Yutaka [Tue, 15 Dec 2015 00:56:08 +0000 (09:56 +0900)]
scd: Fix commit 9a9bfd77.

* scd/app.c (check_application_conflict): Get SLOT.

3 years agoscd: Fix removal of unplugged usb readers on Windows.
Daniel Hoffend [Sun, 6 Dec 2015 23:13:59 +0000 (00:13 +0100)]
scd: Fix removal of unplugged usb readers on Windows.

* scd/apdu.c (pcsc_error_to_sw): map PCSC_E_NO_SERVICE and
PCSC_E_SERVICE_STOPPED to the internal SW_HOST_NO_READER error code.


Signed-off-by: Daniel Hoffend <>
GnuPG-bug-id: 2167

In Windows 8 (and later), PC/SC service only runs when reader/token is
plugged in.  After its removal, it returns PCSC_E_NO_SERVICE error.
This error should be handled as no reader.  This comment is by gniibe.

(backport of commit d1a97585c5e73fbc7d4cf90e38f76ffc5aea305f)

3 years agoscd: Simplify saving application context.
NIIBE Yutaka [Fri, 4 Dec 2015 05:13:23 +0000 (14:13 +0900)]
scd: Simplify saving application context.

* scd/app.c (lock_table): Remove LAST_APP field.
(lock_reader, app_dump_state, application_notify_card_reset)
(release_application): Follow the change.
(check_conflict): New.
(check_application_conflict): Lock the slot and call check_conflict.
(select_application): Call check_conflict and not use LAST_APP.


We don't need LAST_APP field but just keep the application context by
APP field.  Since we have a reference counter, it is possible if we
can deallocate or not.

(backport of commit 9639af5f16a7ed908cbce2415330b9fcd88edc90)

3 years agoscd: Fix "Conflicting usage" bug.
NIIBE Yutaka [Thu, 3 Dec 2015 02:26:24 +0000 (11:26 +0900)]
scd: Fix "Conflicting usage" bug.

* scd/apdu.c (apdu_close_reader): Call CLOSE_READER method even if we
  got an error from apdu_disconnect.
* scd/app-common.h (no_reuse): Remove.
* scd/app.c (application_notify_card_reset): Deallocate APP here.
(select_application, release_application): Don't use NO_REUSE.


Reproducible scenario: Invoke gpg --card-edit session from a terminal.
Invoke another gpg --card-edit session from another.  Remove a token.
Insert a token again.  Type RET on both terminals.  One of terminal
answers "Conflicting usage".

Perhaps, having NO_REUSE field was to avoid race conditions.  Now,
APP can be safely deallocated by application_notify_card_reset.

Thanks to the2nd.

(backport of commit f42c50dbf00c2e6298ca6830cbe6d36805fa54a3)

3 years agodoc: Don't install gpg-zip.1.
NIIBE Yutaka [Thu, 29 Oct 2015 01:26:04 +0000 (10:26 +0900)]
doc: Don't install gpg-zip.1.

* doc/ (myman_pages): Remove gpg-zip.1.
(DISTCLEANFILES): Add gpg-zip.1.


(backport of commit d25e29ad9374da1c11ccfc38f392dbab2d707042)

Thanks to Thomas Klausner.

GnuPG-bug-id: 2095

3 years agoagent: Fix alignment problem with the second passphrase struct.
Werner Koch [Thu, 1 Oct 2015 11:21:25 +0000 (13:21 +0200)]
agent: Fix alignment problem with the second passphrase struct.

* agent/genkey.c (agent_ask_new_passphrase): Use a separate malloc for
PI2.  Check return value of the malloc function.
* agent/command-ssh.c (ssh_identity_register): Use a separate malloc
for PI2.  Wipe PI2.

For whatever stupid reasons I once allocated only one memory area and
split that into PI and PI2.  This is actually a common pattern with
malloc but here we used a made up object size and do not take the
extra alignment required into account.  One of these not yet hit by
a (sig)bus PC/VAX hacker bugs.

Instead of trying to fix the alignment, it is better to use a second
calloc for the second struct.

GnuPG-bug-id: 2112
Signed-off-by: Werner Koch <>
Resolved conflicts:

(backport master commit ddf9dd135acd2b3635bb986f6dfc0e4e446d5fad)

3 years agogpg: Silence a compiler warning.
Werner Koch [Thu, 18 Sep 2014 13:08:51 +0000 (15:08 +0200)]
gpg: Silence a compiler warning.

* g10/parse-packet.c (enum_sig_subpkt): Replace hack.


GCC 5 failure reported by Kevin Locke <>

(backport from master commit 6a0c3fa19cfcdd590b96691e8a8ffb48fb5e0ec4)

3 years agogpg: Improve 'General key info' line of --card-status.
NIIBE Yutaka [Tue, 29 Sep 2015 04:45:20 +0000 (13:45 +0900)]
gpg: Improve 'General key info' line of --card-status.

* g10/keylist.c (print_pubkey_info): Print either "pub" or "sub".


This now prints "sub" if the first used card key is actually a subkey.

Signed-off-by: Werner Koch <>
GnuPG-bug-id: 2079

(backported from master 874ef16e70ab750db7b153f17a7e859a0db6a2f1)

3 years agossh: Fix fingerprint computation for 384 bit ECDSA keys.
Werner Koch [Tue, 22 Sep 2015 07:34:05 +0000 (09:34 +0200)]
ssh: Fix fingerprint computation for 384 bit ECDSA keys.

* common/ssh-utils.c (get_fingerprint): Fix hashed string.

That was an obvious c+p bug which should have been caught by a test

GnuPG-bug-id: 2075
Debian-bug-id: 795636

(backported from master 2167951b275bae51cf669c02547e2e7ea8fbe2ee)

3 years agopo: Update Japanese translation.
NIIBE Yutaka [Thu, 17 Sep 2015 08:07:29 +0000 (17:07 +0900)]
po: Update Japanese translation.

3 years agoscd: Fix ccid-driver timeout for OpenPGPcard v2.1.
NIIBE Yutaka [Thu, 17 Sep 2015 02:21:44 +0000 (11:21 +0900)]
scd: Fix ccid-driver timeout for OpenPGPcard v2.1.

* scd/ccid-driver.c (CCID_CMD_TIMEOUT): New.
(ccid_transceive_apdu_level, ccid_transceive): Use.


It is reported that key generation causes timeout with OpenPGPcard
v2.1.  Ideally, timeout value could be determined at run-time by
examining card's ATR.  Compile-time fixed value is OK for internal
CCID driver.

(cherry-picked from 2.1 6510df3a7cd2b5bf44fac1e4d50ee54b8c897daa)

3 years agopo: Update Japanese translation.
NIIBE Yutaka [Tue, 15 Sep 2015 06:14:50 +0000 (15:14 +0900)]
po: Update Japanese translation.

3 years agopo: Update Japanese Translation.
NIIBE Yutaka [Thu, 10 Sep 2015 02:03:31 +0000 (11:03 +0900)]
po: Update Japanese Translation.

3 years agogpgconf: Fix scdaemon reload.
NIIBE Yutaka [Thu, 10 Sep 2015 01:00:03 +0000 (10:00 +0900)]
gpgconf: Fix scdaemon reload.

* tools/gpgconf-comp.c (scdaemon_runtime_change): Add "scd bye".


In GnuPG 2.0.x, it doesn't require newer libassuan which has
ASSUAN_FORCE_CLOSE feature.  We need to send "scd bye" to let
the control finish from command loop.

3 years agopo: Update Dutch translation
Frans Spiesschaert [Wed, 9 Sep 2015 13:58:40 +0000 (15:58 +0200)]
po: Update Dutch translation


3 years agodoc: Allow uploading of a 2.0 manual
Werner Koch [Tue, 8 Sep 2015 15:39:46 +0000 (17:39 +0200)]
doc: Allow uploading of a 2.0 manual


3 years agoPost release updates.
Werner Koch [Tue, 8 Sep 2015 14:41:38 +0000 (16:41 +0200)]
Post release updates.


3 years agoRelease 2.0.29. gnupg-2.0.29
Werner Koch [Tue, 8 Sep 2015 13:59:00 +0000 (15:59 +0200)]
Release 2.0.29.

Signed-off-by: Werner Koch <>
3 years agopo: Auto-update.
Werner Koch [Tue, 8 Sep 2015 13:58:28 +0000 (15:58 +0200)]
po: Auto-update.


3 years agopo: Update German translation
Werner Koch [Tue, 8 Sep 2015 13:57:44 +0000 (15:57 +0200)]
po: Update German translation


3 years agopo: Update Russian translation.
Ineiev [Tue, 8 Sep 2015 13:54:38 +0000 (15:54 +0200)]
po: Update Russian translation.


3 years agogpg: Print a new FAILURE status after most commands.
Werner Koch [Tue, 8 Sep 2015 13:29:59 +0000 (15:29 +0200)]
gpg: Print a new FAILURE status after most commands.

* common/status.h (STATUS_FAILURE): New.
* g10/cpr.c (write_status_failure): New.
* g10/gpg.c (main): Call write_status_failure for all commands which
print an error message here.

This status line can be used similar to the error code returned by
commands send over the Assuan interface in gpgsm.  We don't emit them
in gpgsm because there we already have that Assuan interface to return
proper error code.  This change helps GPGME to return better error

(backported from master 9cdff09743c473a12359bfdb914578ede0e4e3e2)

Signed-off-by: Werner Koch <>
3 years agogpg: Avoid cluttering stdout with trustdb info in verbose mode.
Werner Koch [Fri, 8 May 2015 14:30:04 +0000 (16:30 +0200)]
gpg: Avoid cluttering stdout with trustdb info in verbose mode.

* g10/trustdb.c (validate_keys): Call dump_key_array only in debug

I guess that is a left-over from an early attempt to output
information on the trustdb for use by other tools.  Maybe related to
the former --list-trust-path command.  Sending it to stdout is
probably useful so we do this now only in debug mode.

Signed-off-by: Werner Koch <>
Backported to STABLE-BRANCH-2-0 from
b03a2647299a6c8764a2574590cbaccdff9e497d by dkg

3 years agogpg: Obsolete --no-sig-create-check.
Werner Koch [Mon, 31 Aug 2015 21:35:32 +0000 (23:35 +0200)]
gpg: Obsolete --no-sig-create-check.

* g10/gpg.c (opts): Make --no-sig-create-check a NOP.
* g10/options.h (struct opt): Remove field "no_sig_create_check".
* g10/sign.c (do_sign): Do not run the create check for Libgcrypt 1.7.

Signed-off-by: Werner Koch <>
3 years agog10: fix --card-status creating stub.
NIIBE Yutaka [Wed, 12 Aug 2015 01:23:40 +0000 (10:23 +0900)]
g10: fix --card-status creating stub.

* g10/getkey.c (get_seckeyblock_byfprint): Require exact match.

3 years agosm: Revert to use SHA-1 for CSR generation.
Werner Koch [Mon, 27 Jul 2015 09:28:31 +0000 (11:28 +0200)]
sm: Revert to use SHA-1 for CSR generation.

* sm/certreqgen.c (create_request): Revert to use SHA-1 but change to
set it only at one place.

Regression-due-to: bdf439035d123e4751e133ad42982673b0c86b75
Signed-off-by: Werner Koch <>
3 years agoDon't segfault if the first 'auto-key-locate' option is 'clear'.
Neal H. Walfield [Thu, 16 Jul 2015 07:57:27 +0000 (09:57 +0200)]
Don't segfault if the first 'auto-key-locate' option is 'clear'.

* g10/getkey.c (free_akl): If AKL is NULL, just return.

Backported from f2ee673c99825d5189631031ddec2dbf54dbd482.  Note:
unlike in 2.1, in 2.0 this bug is not (currently) triggered since
parse_auto_key_locate doesn't recognize "clear".

Signed-off-by: Neal H. Walfield <>.
Reported-by: Sami Farin.
GnuPG-bug-id: 2045

3 years agoscd: pinpad workaround for PC/SC implementations.
NIIBE Yutaka [Tue, 23 Jun 2015 01:10:15 +0000 (10:10 +0900)]
scd: pinpad workaround for PC/SC implementations.

* scd/adpu.c (pcsc_pinpad_verify, pcsc_pinpad_modify): Bigger buffer
for TPDU card reader.


(backport from 2.1 commit 5e1d2fe6555d06f9dcd2daac713b2edfbc0428a5)

GnuPG-bug-id: 2003, 2004

This is needed for PC/SC on Debian Jessie.  Note that it's not only
for Cherry ST-2000, but also, for any TPDU card readers.

3 years agoscd: Fix Cherry ST-2000 support for pinpad input.
NIIBE Yutaka [Mon, 22 Jun 2015 05:31:25 +0000 (14:31 +0900)]
scd: Fix Cherry ST-2000 support for pinpad input.

* scd/apdu.c (pcsc_vendor_specific_init): Set pinmax to 15.
* scd/ccid-driver.c (ccid_transceive_secure): Add zero for the
template of APDU.


(backport from 2.1 commit 444e9232aa9e00aacd939cbf7bdb881b550dfebe)

GnuPG-bug-id: 2003, 2004

3 years agogpg: Print PGP-2 fingerprint instead of all zeroes.
Werner Koch [Wed, 17 Jun 2015 06:37:02 +0000 (08:37 +0200)]
gpg: Print PGP-2 fingerprint instead of all zeroes.

* g10/keyid.c (fingerprint_from_pk): Allow PGP-2 fingerprints.
* g10/keylist.c (print_fingerprint): Print a warning after a PGP-2

Printing all zeroes for a PGP-2 (v3 key) fingerprint has the problem
that frontends (or the user) may use that fingerprint to lookup a key
and gpg will return all PGP2 keys.  They may then show a different
PGP-2 key than the one actually used for a signature.  This is worse
than displaying a weak fingerprint.

GnuPG-bug-id: 2000
Signed-off-by: Werner Koch <>
3 years agopo: Update Japanese Translation.
NIIBE Yutaka [Tue, 16 Jun 2015 03:52:19 +0000 (12:52 +0900)]
po: Update Japanese Translation.

3 years agog10: Fix a race condition initially creating trustdb.
NIIBE Yutaka [Thu, 28 May 2015 08:08:37 +0000 (17:08 +0900)]
g10: Fix a race condition initially creating trustdb.

* g10/tdbio.c (take_write_lock, release_write_lock): New.
(put_record_into_cache, tdbio_sync, tdbio_end_transaction): Use
new lock functions.
(tdbio_set_dbname): Fix the race.
(open_db): Don't call create_dotlock.


(backported from commit fe5c6edaed78839303d67e01e141cfc6b5de9aec)

GnuPG-bug-id: 1675

3 years agopo:Update Japanese translation.
NIIBE Yutaka [Mon, 15 Jun 2015 04:58:07 +0000 (13:58 +0900)]
po:Update Japanese translation.

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

4 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)

4 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)

4 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)

4 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)

4 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)

4 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)