gnupg.git
6 years agocommon: Add func has_leading_keyword.
Werner Koch [Thu, 21 Feb 2013 19:25:12 +0000 (20:25 +0100)]
common: Add func has_leading_keyword.

* common/stringhelp.c (has_leading_keyword): New.

6 years agoRemove build hacks for FreeBSD.
Werner Koch [Wed, 20 Feb 2013 19:31:52 +0000 (20:31 +0100)]
Remove build hacks for FreeBSD.

* configure.ac [freebsd]: Do not add /usr/local to CPPFLAGS and
LDFLAGS.
--

Back in ~2000 we introduced a quick hack to make building of Libgcrypt
on FreeBSD easier by always adding -I/usr/local/include and
-L/usr/local/lib .  It turned out that this is a bad idea if one wants
to build with library version which is not installed in /usr/local.
The hack made was eventually (in 2003) copied from Libgcrypt to
GnuPG-2.

6 years agoagent: fix two bugs.
NIIBE Yutaka [Fri, 22 Feb 2013 03:55:11 +0000 (12:55 +0900)]
agent: fix two bugs.

* agent/command.c (cmd_keytocard): Decrement KEYDATALEN.
* agent/findkey.c (agent_public_key_from_file): Increment for ELEMS.

--
For ECDSA and ECDH, there are 6 elements.

6 years agogpg: fix keytocard and support ECC card for key attribute.
NIIBE Yutaka [Fri, 22 Feb 2013 02:00:27 +0000 (11:00 +0900)]
gpg: fix keytocard and support ECC card for key attribute.

* g10/call-agent.c (agent_keytocard): Supply PARM arg.
* g10/card-util.c (card_status): Support ECC.
(card_store_subkey): Don't assume RSA.

6 years agoUpdate .gitignore for non-VPATH builds.
Werner Koch [Tue, 12 Feb 2013 18:28:54 +0000 (19:28 +0100)]
Update .gitignore for non-VPATH builds.

--

6 years agogpg: Implement card_store_subkey again.
NIIBE Yutaka [Wed, 6 Feb 2013 05:01:23 +0000 (14:01 +0900)]
gpg: Implement card_store_subkey again.

* g10/call-agent.h (agent_keytocard): New.
* g10/call-agent.c (agent_keytocard): New.
* g10/card-util.c (replace_existing_key_p): Returns 1 when replace.
(card_generate_subkey): Check return value of replace_existing_key_p.
(card_store_subkey): Implement again using agent_keytocard.

6 years agoagent: Add KEYTOCARD command.
NIIBE Yutaka [Wed, 6 Feb 2013 05:00:05 +0000 (14:00 +0900)]
agent: Add KEYTOCARD command.

* agent/agent.h (divert_writekey, agent_card_writekey): New.
* agent/call-scd.c (inq_writekey_parms, agent_card_writekey): New.
* agent/command.c (cmd_keytocard, hlp_keytocard): New.
(register_commands): Add cmd_keytocard.
* agent/divert-scd.c (divert_writekey): New.

6 years agoJapanese: update po and doc.
NIIBE Yutaka [Tue, 12 Feb 2013 05:14:12 +0000 (14:14 +0900)]
Japanese: update po and doc.

* doc/help.ja.txt, po/ja.po: Updated.

6 years agoscd: Rename 'keypad' to 'pinpad'.
NIIBE Yutaka [Thu, 7 Feb 2013 01:07:51 +0000 (10:07 +0900)]
scd: Rename 'keypad' to 'pinpad'.

* NEWS: Mention scd changes.

* agent/divert-scd.c (getpin_cb): Change message.

* agent/call-scd.c (inq_needpin): Change the protocol to
POPUPPINPADPROMPT and DISMISSPINPADPROMPT.
* scd/command.c (pin_cb): Likewise.

* scd/apdu.c (struct reader_table_s): Rename member functions.
(check_pcsc_pinpad, pcsc_pinpad_verify, pcsc_pinpad_modify,
check_ccid_pinpad, ccid_pinpad_operation, apdu_check_pinpad
apdu_pinpad_verify, apdu_pinpad_modify): Rename.

* scd/apdu.h (SW_HOST_NO_PINPAD, apdu_check_pinpad)
(apdu_pinpad_verify, apdu_pinpad_modify): Rename.

* scd/iso7816.h (iso7816_check_pinpad): Rename.

* scd/iso7816.c (map_sw): Use SW_HOST_NO_PINPAD.
(iso7816_check_pinpad): Rename.
(iso7816_verify_kp, iso7816_change_reference_data_kp): Follow
the change.

* scd/ccid-driver.h (CCID_DRIVER_ERR_NO_PINPAD): Rename.
* scd/ccid-driver.c (ccid_transceive_secure): Use it.

* scd/app-dinsig.c (verify_pin): Follow the change.
* scd/app-nks.c (verify_pin): Follow the change.

* scd/app-openpgp.c (check_pinpad_request): Rename.
(parse_login_data, verify_a_chv, verify_chv3, do_change_pin): Follow
the change.

* scd/scdaemon.c (oDisablePinpad, oEnablePinpadVarlen): Rename.

* scd/scdaemon.h (opt): Rename to disable_pinpad,
enable_pinpad_varlen.

* tools/gpgconf-comp.c (gc_options_scdaemon): Rename to
disable-pinpad.

6 years agogpg: Add pinentry-mode feature.
Werner Koch [Thu, 7 Feb 2013 19:37:58 +0000 (20:37 +0100)]
gpg: Add pinentry-mode feature.

* g10/gpg.c: Include shareddefs.h.
(main): Add option --pinentry-mode.
* g10/options.h (struct opt): Add field pinentry_mode.
* g10/passphrase.c: Include shareddefs.h.
(have_static_passphrase): Take care of loopback pinentry_mode.
(read_passphrase_from_fd): Ditto.
(get_static_passphrase): New.
(passphrase_to_dek_ext): Factor some code out to ...
(emit_status_need_passphrase): new.
* g10/call-agent.c (start_agent): Send the pinentry mode.
(default_inq_cb): Take care of the PASSPHRASE inquiry.  Return a
proper error code.
(agent_pksign): Add args keyid, mainkeyid and pubkey_algo.
(agent_pkdecrypt): Ditto.
* g10/pubkey-enc.c (get_it): Pass new args.
* g10/sign.c (do_sign): Pass new args.

* g10/call-agent.c (struct default_inq_parm_s): New.  Change all
similar structs to reference this one.  Change all users and inquire
callback to use this struct, instead of NULL or some undefined but not
used structs.  This change will help to eventually get rid of global
variables.
--

This new features allows to use gpg without a Pinentry.  As a
prerequisite the agent must be configured to allow the loopback
pinentry mode (option --allow-loopback-pinentry).  For example

  gpg2 --pinentry-mode=loopback FILE.gpg

may be used to decrypt FILE.gpg while entering the passphrase on the
tty.  If batch is used, --passphrase et al. may be used, if
--command-fd is used, the passphrase may be provided by another
process.  Note that there are no try-again prompts in case of a bad
passphrase.

6 years agodoc: Fix description for NEED_PASSPHRASE status.
Werner Koch [Thu, 7 Feb 2013 19:18:31 +0000 (20:18 +0100)]
doc: Fix description for NEED_PASSPHRASE status.

--

6 years agoagent: Move a typedef to common and provide parse_pinentry_mode.
Werner Koch [Wed, 6 Feb 2013 11:49:52 +0000 (12:49 +0100)]
agent: Move a typedef to common and provide parse_pinentry_mode.

* common/agent-opt.c: New.
* common/shareddefs.h: New.
* common/Makefile.am: Add new files.
* agent/agent.h: Include shareddefs.h.
(pinentry_mode_t): Factor out to shareddefs.h.
* agent/command.c (option_handler): Use parse_pinentry_mode.

6 years agoagent: Return a better error code if no passphrase was given.
Werner Koch [Wed, 6 Feb 2013 11:42:07 +0000 (12:42 +0100)]
agent: Return a better error code if no passphrase was given.

* agent/protect.c (hash_passphrase): Handle an empty passphrase.
--

This is mostly useful in loopback pinentry-mode.

6 years agoscd: Fix check_keypad_request.
NIIBE Yutaka [Tue, 5 Feb 2013 05:59:29 +0000 (14:59 +0900)]
scd: Fix check_keypad_request.

* scd/app-openpgp.c (check_keypad_request): 0 means not to use pinpad.

6 years agoSCD: Add vendor specific initalization.
NIIBE Yutaka [Mon, 28 Jan 2013 02:46:40 +0000 (11:46 +0900)]
SCD: Add vendor specific initalization.

* scd/ccid-driver.c (ccid_vendor_specific_init): New.
(ccid_open_reader): Call ccid_vendor_specific_init.

6 years agoSCD: Support P=N format for login data.
NIIBE Yutaka [Sun, 13 Jan 2013 03:12:10 +0000 (12:12 +0900)]
SCD: Support P=N format for login data.

* scd/app-openpgp.c (parse_login_data): Support P=N format.

6 years agoSCD: Better interoperability.
NIIBE Yutaka [Fri, 11 Jan 2013 04:19:17 +0000 (13:19 +0900)]
SCD: Better interoperability.

* scd/apdu.c: Fill bTeoPrologue[2] field.
--
ccid-1.4.5 or older requires this field is filled by application.

6 years agoSCD: Defaults to use pinpad if the reader has the capability.
NIIBE Yutaka [Fri, 11 Jan 2013 01:41:38 +0000 (10:41 +0900)]
SCD: Defaults to use pinpad if the reader has the capability.

* scd/app-openpgp.c (struct app_local_s): Remove VARLEN.
(parse_login_data): "P=0" means to disable pinpad.
(check_keypad_request): Default is to use pinpad if available.

6 years agoSCD: handle keypad request on the card.
NIIBE Yutaka [Thu, 10 Jan 2013 06:58:43 +0000 (15:58 +0900)]
SCD: handle keypad request on the card.

* scd/app-openpgp.c: Add 2013.
(struct app_local_s): Add keypad structure.
(parse_login_data): Add parsing keypad request on the card.
(check_keypad_request): New.
(verify_a_chv, verify_chv3, do_change_pin): Call check_keypad_request
to determine use of keypad.

6 years agoSCD: Minor fix of ccid-driver.
NIIBE Yutaka [Thu, 10 Jan 2013 06:52:24 +0000 (15:52 +0900)]
SCD: Minor fix of ccid-driver.

* scd/ccid-driver.c (VENDOR_VEGA): Fix typo.

6 years agoSCD: Add support of Covadis VEGA_ALPHA reader.
NIIBE Yutaka [Thu, 10 Jan 2013 01:49:27 +0000 (10:49 +0900)]
SCD: Add support of Covadis VEGA_ALPHA reader.

* scd/ccid-driver.c: Add 2013.
(VENDER_VEGA, VEGA_ALPHA):New.
(ccid_transceive_secure): VEGA_ALPHA is same firmware as GEMPC_PINPAD.
Change bNumberMessage to 0x01, as it works better (was: 0xff).

6 years agoSCD: Support fixed length PIN input for keypad (PC/SC).
NIIBE Yutaka [Wed, 9 Jan 2013 07:40:41 +0000 (16:40 +0900)]
SCD: Support fixed length PIN input for keypad (PC/SC).

* scd/apdu.c (pcsc_keypad_verify): SUpport fixed length PIN input for
keypad.
(pcsc_keypad_modify): Likewise.
* scd/ccid-driver.c (ccid_transceive_secure): Clean up.

6 years agoSCD: Support fixed length PIN input for keypad.
NIIBE Yutaka [Wed, 9 Jan 2013 07:23:55 +0000 (16:23 +0900)]
SCD: Support fixed length PIN input for keypad.

* scd/iso7816.h (struct pininfo_s): Remove MODE and add FIXEDLEN.
* scd/app-dinsig.c (verify_pin): Initialize FIXEDLEN to unknown.
* scd/app-nks.c (verify_pin): Likewise.
* scd/app-openpgp.c (verify_a_chv, verify_chv3, do_change_pin):
Likewise.
* scd/apdu.c (check_pcsc_keypad): Add comment.
(pcsc_keypad_verify, pcsc_keypad_modify): PC/SC driver only support
readers with the feature of variable length input (yet).
(apdu_check_keypad): Set FIXEDLEN.
* scd/ccid-driver.c (ccid_transceive_secure): Add GEMPC_PINPAD
specific settings.
Support fixed length PIN input for keypad.

6 years agoSCD: API cleanup for keypad handling.
NIIBE Yutaka [Wed, 9 Jan 2013 05:10:08 +0000 (14:10 +0900)]
SCD: API cleanup for keypad handling.

* scd/iso7816.h (struct pininfo_s): Rename from iso7816_pininfo_s.
Change meaning of MODE.
(pininfo_t): Rename from iso7816_pininfo_t.
* scd/sc-copykeys.c: Include "iso7816.h".
* scd/scdaemon.c, scd/command.c: Likewise.
* scd/ccid-driver.c: Include "scdaemon.h" and "iso7816.h".
(ccid_transceive_secure): Follow the change of PININFO_T.
* scd/app.c: Include "apdu.h" after "iso7816.h".
* scd/iso7816.c (iso7816_check_keypad, iso7816_verify_kp)
(iso7816_change_reference_data_kp): Follow the change of API.
* scd/apdu.c (struct reader_table_s): Change API of CHECK_KEYPAD,
KEYPAD_VERIFY, KEYPAD_MODIFY to have arg of PININFO_T.
(check_pcsc_keypad, check_ccid_keypad): Likewise.
(apdu_check_keypad, apdu_keypad_verify, apdu_keypad_modify): Likewise.
(pcsc_keypad_verify, pcsc_keypad_modify, ct_send_apdu)
(pcsc_send_apdu_direct,  pcsc_send_apdu_wrapped, pcsc_send_apdu)
(send_apdu_ccid, ccid_keypad_operation, my_rapdu_send_apdu, send_apdu)
(send_le): Follow the change of API.
* scd/apdu.h (apdu_check_keypad, apdu_keypad_verify)
(apdu_keypad_modify): Change the API.
* scd/app-dinsig.c, scd/app-nks.c, scd/app-openpgp.c: Follow the
change.

6 years agoSCD: Clean up. Remove PADLEN for keypad input.
NIIBE Yutaka [Mon, 7 Jan 2013 05:20:55 +0000 (14:20 +0900)]
SCD: Clean up.  Remove PADLEN for keypad input.

* scd/apdu.c (struct pininfo_s): Use iso7816_pininfo_s.
(struct reader_table_s): Remove last arg from check_keypad method.
(check_pcsc_keypad, check_pcsc_keypad): Remove PIN_PADLEN.
(pcsc_keypad_verify, pcsc_keypad_modify): Don't check PIN_PADLEN.
(send_apdu_ccid, ccid_keypad_operation): Remove PIN_PADLEN.
(apdu_check_keypad, apdu_keypad_verify, apdu_keypad_modify):
Likewise.

* scd/apdu.h (apdu_check_keypad, apdu_keypad_verify)
(apdu_keypad_modify): Remove PIN_PADLEN.

* scd/ccid-driver.c (ccid_transceive_secure): Remove PIN_PADLEN.

* scd/ccid-driver.h (ccid_transceive_secure): Remove PIN_PADLEN.

* scd/iso7816.c (iso7816_check_keypad, iso7816_verify_kp)
(iso7816_change_reference_data_kp): Remove PADLEN.

* scd/iso7816.h (struct iso7816_pininfo_s): Remove PADLEN, PADCHAR.
--
In the OpenPGPcard specification, password comes with no padding.  In
GnuPG, we support keypad input for OpenPGPcard only.  Thus, it is
useless to try to support padding for keypad input.

6 years agoSCD: Add option enable-keypad-varlen and support for GEMPC_PINPAD.
NIIBE Yutaka [Wed, 9 Jan 2013 04:24:57 +0000 (13:24 +0900)]
SCD: Add option enable-keypad-varlen and support for GEMPC_PINPAD.

* scd/scdaemon.h (opt): Add enable_keypad_varlen.
* scd/scdaemon.c (cmd_and_opt_values): Add oEnableKeypadVarlen.
(opts, main): Add oEnableKeypadVarlen.
* scd/ccid-driver.c (GEMPC_PINPAD): New.
(ccid_transceive_secure): Add enable_varlen handling.
Enable GEMPC_PINPAD.
--
Note that GEMPC_PINPAD doesn't support variable length keypad input.
The feature of fixed length keypad input will be added soon.

6 years agoConvert doc/DETAILS to org-mode
Werner Koch [Wed, 30 Jan 2013 17:54:23 +0000 (18:54 +0100)]
Convert doc/DETAILS to org-mode

--
Also restructure the file and fix some obviously wrong things.

6 years agoRemove unused status codes
Werner Koch [Wed, 30 Jan 2013 17:51:56 +0000 (18:51 +0100)]
Remove unused status codes

* common/status.h (STATUS_BEGIN_STREAM, STATUS_END_STREAM)
(STATUS_SIEXPIRED): Remove unused codes.

6 years agogpg: Add status line PINENTRY_LAUNCHED.
Werner Koch [Wed, 30 Jan 2013 11:00:29 +0000 (12:00 +0100)]
gpg: Add status line PINENTRY_LAUNCHED.

* common/status.h (STATUS_PINENTRY_LAUNCHED): New.
* g10/server.c (server_local_s): Add field allow_pinentry_notify.
(option_handler): Add option "allow-pinentry-notify".
(gpg_proxy_pinentry_notify): New.
* g10/call-agent.c (default_inq_cb): Factor code out to the new
function.

6 years agoagent: Fix a bug of handling return code from npth_join.
NIIBE Yutaka [Fri, 25 Jan 2013 05:17:29 +0000 (14:17 +0900)]
agent: Fix a bug of handling return code from npth_join.

* agent/call-pinentry.c (agent_popup_message_stop): Fix npth_join
return code.
--
pth_join returns TRUE (1) on success.  But npth_join (and pthread_join)
returns 0 on success, returns error number on error.

6 years agogpg: Fix honoring --cert-digest-algo when recreating a cert
Christian Aistleitner [Sun, 14 Oct 2012 18:30:20 +0000 (20:30 +0200)]
gpg: Fix honoring --cert-digest-algo when recreating a cert

* g10/sign.c (update_keysig_packet): Override original signature's
digest algo in hashed data and for hash computation.

6 years agoFix spurious cruft from configure summary output.
Werner Koch [Mon, 7 Jan 2013 08:58:35 +0000 (09:58 +0100)]
Fix spurious cruft from configure summary output.

* configure.ac (build_scdaemon_extra): Remove $tmp cruft.

6 years agoSCD: Hold lock for pinpad input.
NIIBE Yutaka [Fri, 11 Jan 2013 02:18:39 +0000 (11:18 +0900)]
SCD: Hold lock for pinpad input.

* scd/apdu.c (apdu_check_keypad, apdu_keypad_verify)
(apdu_keypad_modify): Hold lock to serialize communication.

6 years agoSCD: Support not-so-smart card readers.
NIIBE Yutaka [Tue, 8 Jan 2013 06:22:31 +0000 (15:22 +0900)]
SCD: Support not-so-smart card readers.

* scd/ccid-driver.c (struct ccid_driver_s): Add auto_voltage,
auto_param, and auto_pps.
(parse_ccid_descriptor): Set auto_voltage, auto_param, and auto_pps.
Support non-autoconf readers.
(update_param_by_atr): New.
(ccid_get_atr): Use 5V for PowerOn when auto_voltage is not supported.
Use 0x10 when nonnull_nad for SetParameters.
Call update_param_by_atr for parsing ATR, and use param for
SetParameters.
Send PPS if reader requires it and card is negotiable.
When bNadValue in the return values of SetParameters == 0,
clear handle->nonnull_nad flag.
--
This change is to support more card readers by the internal driver.
Tested with 08e6:3478 Gemplus PinPad Smart Card Reader.

6 years agoUpdate Japanese Translation.
NIIBE Yutaka [Mon, 7 Jan 2013 01:41:21 +0000 (10:41 +0900)]
Update Japanese Translation.

* po/ja.po: Fix wrong translations for designated revocation.
Reported by Hideki Saito.

Conflicts:
po/ja.po

6 years agoUpdate Japanese Translation.
NIIBE Yutaka [Sat, 5 Jan 2013 07:38:11 +0000 (16:38 +0900)]
Update Japanese Translation.

* po/ja.po: Fix fuzzy translations.

6 years agoUpdate Japanese Translation.
NIIBE Yutaka [Thu, 3 Jan 2013 03:03:19 +0000 (12:03 +0900)]
Update Japanese Translation.

* po/ja.po: Update with POT.

6 years agoUpdate Japanese Translation.
NIIBE Yutaka [Thu, 3 Jan 2013 02:57:44 +0000 (11:57 +0900)]
Update Japanese Translation.

* po/ja.po: Start from the new one of 2.0.

6 years agogpg: Import only packets which are allowed in a keyblock.
Werner Koch [Thu, 20 Dec 2012 08:43:41 +0000 (09:43 +0100)]
gpg: Import only packets which are allowed in a keyblock.

* g10/import.c (valid_keyblock_packet): New.
(read_block): Store only valid packets.
--

A corrupted key, which for example included a mangled public key
encrypted packet, used to corrupt the keyring.  This change skips all
packets which are not allowed in a keyblock.

GnuPG-bug-id: 1455

(cherry-picked from commit f795a0d59e197455f8723c300eebf59e09853efa)

6 years agogpg: Make commit 2b3cb2ee actually work
Werner Koch [Wed, 19 Dec 2012 10:47:23 +0000 (11:47 +0100)]
gpg: Make commit 2b3cb2ee actually work

* g10/sign.c (update_keysig_packet): Use digest_algo.

(cherry-picked from commit d23ec86095714d388acac14b515445fe69f019e9)

6 years agogpg: Suppress "public key already present" in quiet mode.
Werner Koch [Wed, 19 Dec 2012 10:21:26 +0000 (11:21 +0100)]
gpg: Suppress "public key already present" in quiet mode.

* g10/pkclist.c (find_and_check_key, build_pk_list): Print a
diagnostic only in non-quiet mode.

6 years agofaq: Add a section on copyright assignments
Werner Koch [Wed, 19 Dec 2012 10:05:05 +0000 (11:05 +0100)]
faq: Add a section on copyright assignments

--

6 years agoState that disclaimers are not anymore needed for translations.
Werner Koch [Tue, 18 Dec 2012 18:54:23 +0000 (19:54 +0100)]
State that disclaimers are not anymore needed for translations.

--

6 years agocommon: Add meta option ignore-invalid-option.
Werner Koch [Tue, 18 Dec 2012 17:06:41 +0000 (18:06 +0100)]
common: Add meta option ignore-invalid-option.

* common/argparse.c (iio_item_def_s, IIO_ITEM_DEF): New.
(initialize): Init field IIO_LIST.
(ignore_invalid_option_p): New.
(ignore_invalid_option_add): New.
(ignore_invalid_option_clear): New.
(optfile_parse): Implement meta option.
--

This option is currently of no use.  However, as soon as it has been
deployed in all stable versions of GnuPG, it will allow the use of the
same configuration file with an old and a new version of GnuPG.  For
example: If a new version implements the option "foobar", and a user
uses it in gpg.conf, an old version of gpg would bail out with the
error "invalid option".  To avoid that the following line can be put
above that option in gpg.conf

  ignore-invalid-option foobar

This meta option may be given several times or several option names
may be given as arguments (space delimited).  Note that this option is
not available on the command line.

6 years agoutf8conv.c: Add hacks for Android.
Werner Koch [Mon, 12 Nov 2012 14:38:51 +0000 (15:38 +0100)]
utf8conv.c: Add hacks for Android.

* common/utf8conv.c [HAVE_ANDROID_SYSTEM]: Do not include iconv.h.
(iconv_open, iconv_close, load_libiconv) [HAVE_ANDROID_SYSTEM]: New
dummy functions.
(set_native_charset) [HAVE_ANDROID_SYSTEM]: Force use of "utf-8".
(jnlib_iconv_open) [HAVE_ANDROID_SYSTEM]: Act the same as under W32.
(jnlib_iconv) [HAVE_ANDROID_SYSTEM]: Ditto.
(jnlib_iconv_close) [HAVE_ANDROID_SYSTEM]: Ditto.
--

Co-authored-by: Hans of Guardian <hans@guardianproject.info>
6 years agoSCD: Fix the process of writing key or generating key.
NIIBE Yutaka [Thu, 13 Dec 2012 04:36:23 +0000 (13:36 +0900)]
SCD: Fix the process of writing key or generating key.

* scd/app-openpgp.c (store_fpr): Flush KEY-FPR and KEY-TIME.

6 years agossh: Support ECDSA keys.
Werner Koch [Wed, 12 Dec 2012 17:47:21 +0000 (18:47 +0100)]
ssh: Support ECDSA keys.

* agent/command-ssh.c (SPEC_FLAG_IS_ECDSA): New.
(struct ssh_key_type_spec): Add fields CURVE_NAME and HASH_ALGO.
(ssh_key_types): Add types ecdsa-sha2-nistp{256,384,521}.
(ssh_signature_encoder_t): Add arg spec and adjust all callers.
(ssh_signature_encoder_ecdsa): New.
(sexp_key_construct, sexp_key_extract, ssh_receive_key)
(ssh_convert_key_to_blob): Support ecdsa.
(ssh_identifier_from_curve_name): New.
(ssh_send_key_public): Retrieve and pass the curve_name.
(key_secret_to_public): Ditto.
(data_sign): Add arg SPEC and change callers to pass it.
(ssh_handler_sign_request): Get the hash algo from SPEC.
* common/ssh-utils.c (get_fingerprint): Support ecdsa.

* agent/protect.c (protect_info): Add flag ECC_HACK.
(agent_protect): Allow the use of the "curve" parameter.
* agent/t-protect.c (test_agent_protect): Add a test case for ecdsa.

* agent/command-ssh.c (ssh_key_grip): Print a better error code.
--

The 3 standard curves are now supported in gpg-agent's ssh-agent
protocol implementation.  I tested this with all 3 curves and keys
generated by OpenSSH 5.9p1.

Using existing non-ssh generated keys will likely fail for now. To fix
this, the code should first undergo some more cleanup; then the fixes
are pretty straightforward.  And yes, the data structures are way too
complicated.

6 years agossh: Rewrite a function for better maintainability
Werner Koch [Tue, 11 Dec 2012 13:50:34 +0000 (14:50 +0100)]
ssh: Rewrite a function for better maintainability

* agent/command-ssh.c (ssh_signature_encoder_dsa): Rewrite.
--

Using es_fopenmem instead of a preallocated buffer is safer and easier
to read.

6 years agossh: Improve key lookup for many keys.
Werner Koch [Mon, 10 Dec 2012 17:27:23 +0000 (18:27 +0100)]
ssh: Improve key lookup for many keys.

* agent/command-ssh.c: Remove dirent.h.
(control_file_s): Add struct item.
(rewind_control_file): New.
(search_control_file): Factor code out to ...
(read_control_file_item): New.
(ssh_handler_request_identities): Change to iterate over entries in
sshcontrol.
--

Formerly we scanned the private key directory for matches of entries
in sshcontrol.  This patch changes it to scan the sshcontrol file and
thus considers only keys configured there.  The rationale for this is
that it is common to have only a few ssh keys but many private keys.
Even if that assumption does not hold true, the scanning of the
sshcontrol file is faster than reading the directory and only then
scanning the ssh control for each directory entry.

6 years agossh: Cleanup sshcontrol file access code.
Werner Koch [Mon, 10 Dec 2012 15:39:12 +0000 (16:39 +0100)]
ssh: Cleanup sshcontrol file access code.

* agent/command-ssh.c (SSH_CONTROL_FILE_NAME): New macro to replace
the direct use of the string.
(struct control_file_s, control_file_t): New.
(open_control_file, close_control_file): New.  Use them instead of
using fopen/fclose directly.

6 years agoagent: Add envvar "gnupg_SSH_AUTH_SOCK_by"
Werner Koch [Mon, 10 Dec 2012 13:45:26 +0000 (14:45 +0100)]
agent: Add envvar "gnupg_SSH_AUTH_SOCK_by"

* agent/gpg-agent.c (main): Pass new envar gnupg_SSH_AUTH_SOCK_by to
an invoked process.
--

This environment variable is useful for debugging if
--use-standard-socket is used (which is the default since 2.1).
Commonly you should have this in your init script (e.g. ~/.bashrc):

    unset GPG_AGENT_INFO
    unset SSH_AGENT_PID
    SSH_AUTH_SOCK="${HOME}/.gnupg/S.gpg-agent.ssh"
    export SSH_AUTH_SOCK

The problem is that gpg-agent won't be able to override the
SSH_AUTH_SOCK envvar if gpg-agent has been invoked as

  gpg-agent --enable-ssh-support --daemon /bin/bash

To fix this you should instead use this code in the init script:

  unset GPG_AGENT_INFO
  unset SSH_AGENT_PID
  if [ ${gnupg_SSH_AUTH_SOCK_by:-0} -ne $$ ]; then
    export SSH_AUTH_SOCK="${HOME}/.gnupg/S.gpg-agent.ssh"
  fi

This will work in all cases and thus allows to start gpg-agent for
testing purposes with a different homedir and use this gpg-agent as an
ssh-agent.  Example:

  GNUPGHOME=$(pwd) gpg-agent --enable-ssh-support --daemon /bin/bash

gnupg_SSH_AUTH_SOCK_by is set to the PID of the exec-ed process and
thus will work safely if called recursively.

6 years agoconfig: Update npth.m4.
Werner Koch [Mon, 10 Dec 2012 08:40:40 +0000 (09:40 +0100)]
config: Update npth.m4.

* m4/npth.m4: Take from current npth master.

6 years agoRevert SCD changes of 2010-05-03.
NIIBE Yutaka [Tue, 4 Dec 2012 05:37:56 +0000 (14:37 +0900)]
Revert SCD changes of 2010-05-03.

* scd/apdu.c (pcsc_no_service): Remove.
(open_pcsc_reader_direct, open_pcsc_reader_wrapped): Remove
pcsc_no_service support.
(apdu_open_reader): Remove R_NO_SERVICE.
* scd/apdu.h (apdu_open_reader): Remove R_NO_SERVICE.
* scd/command.c (reader_disabled): Remove.
(get_current_reader): Follow the change of R_NO_SERVICE.
(open_card, cmd_serialno, scd_command_handler): Remove reader_disabled
support.
* scd/sc-copykeys.c (main): Follow the change of R_NO_SERVICE.
--
Daemon should handle all possible cases.  Even if such a difficult
case like reader_disabled, it should not exit.

6 years agoDon't keep opening unavailable card reader.
NIIBE Yutaka [Thu, 22 Nov 2012 07:04:51 +0000 (16:04 +0900)]
Don't keep opening unavailable card reader.

* scd/command.c (update_reader_status_file): Don't call
get_current_reader.

--
This fix has a impact that the insertion of a card reader will not be
detected upon the insertion, but will be deferred until user tries to
access his card.

6 years agoRefresh sample keys
David Shaw [Fri, 30 Nov 2012 17:47:49 +0000 (12:47 -0500)]
Refresh sample keys

6 years agoAdjust awk to not add trailing whitespace.
David Shaw [Fri, 30 Nov 2012 17:43:34 +0000 (12:43 -0500)]
Adjust awk to not add trailing whitespace.

* mksamplekeys: Tweak awk script to not add trailing whitespace to
  blank lines (makes git pre-commit hook unhappy)

6 years agoThe keyserver search menu should honor --keyid-format
David Shaw [Thu, 29 Nov 2012 17:00:46 +0000 (12:00 -0500)]
The keyserver search menu should honor --keyid-format

* keyserver.c (print_keyrec): Honor --keyid-format when getting back
  full fingerprints from the keyserver (the comment in the code was
  correct, the code was not).

6 years agoFix printing of ECC algo names in hkp keyserver listings.
Werner Koch [Tue, 27 Nov 2012 15:51:09 +0000 (16:51 +0100)]
Fix printing of ECC algo names in hkp keyserver listings.

* g10/keyserver.c (print_keyrec): Map OpenPGP algorithm ids.

6 years agoCheck for inet_addr() in -lnsl.
Ben Kibbey [Thu, 22 Nov 2012 22:17:33 +0000 (17:17 -0500)]
Check for inet_addr() in -lnsl.

* configure.ac: Check for inet_addr() in libnsl.

--
OpenSolaris/OpenIndiana requires this.

6 years agoDo not use a broken ttyname.
Werner Koch [Tue, 20 Nov 2012 18:01:13 +0000 (19:01 +0100)]
Do not use a broken ttyname.

* configure.ac (HAVE_BROKEN_TTYNAME): New ac_define set for Android
systems.
* common/util.h (gnupg_ttyname): New macro.  Change all callers of
ttyname to use this macro instead.
(ttyname) [W32]: Rename to _gnupg_ttyname and use also if
HAVE_BROKEN_TTYNAME is defined.
* common/simple-pwquery.c (agent_send_all_options): Keep on using
ttyname unless HAVE_BROKEN_TTYNAME is set.  This is because this file
may be used standalone.

6 years agoFix non-portable use of chmod in autogen.sh.
Werner Koch [Fri, 16 Nov 2012 09:36:53 +0000 (10:36 +0100)]
Fix non-portable use of chmod in autogen.sh.

* autogen.sh: Remove option -c from chmod.

6 years agoImprove parsing of the GIT revision number.
Werner Koch [Fri, 16 Nov 2012 09:35:33 +0000 (10:35 +0100)]
Improve parsing of the GIT revision number.

* configure.ac (mmm4_revision): Use git rev-parse.

6 years agoAdd an OpenPGP card vendor.
Werner Koch [Thu, 15 Nov 2012 13:34:20 +0000 (14:34 +0100)]
Add an OpenPGP card vendor.

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

6 years agoFix description of validity flag 'n'.
Werner Koch [Sat, 10 Nov 2012 10:34:21 +0000 (11:34 +0100)]
Fix description of validity flag 'n'.

--
Thanks to Hauke Laging for spotting this.

6 years agoagent: Use wipememory instead of memset in one place.
Werner Koch [Tue, 6 Nov 2012 17:51:47 +0000 (18:51 +0100)]
agent: Use wipememory instead of memset in one place.

* agent/command.c (clear_outbuf): Use wipememory.  Suggested by Ben
Kibbey.

6 years agoAllow decryption with card keys > 3072 bits
Werner Koch [Tue, 6 Nov 2012 11:02:25 +0000 (12:02 +0100)]
Allow decryption with card keys > 3072 bits

* scd/command.c (MAXLEN_SETDATA): New.
(cmd_setdata): Add option --append.
* agent/call-scd.c (agent_card_pkdecrypt): Use new option for long
data.

* scd/app-openpgp.c (struct app_local_s): Add field manufacturer.
(app_select_openpgp): Store manufacturer.
(do_decipher): Print a note for broken cards.

--

Please note that I was not able to run a full test because I only have
broken cards (S/N < 346) available.

6 years agoagent: Fix wrong use of gcry_sexp_build_array
NIIBE Yutaka [Wed, 31 Oct 2012 07:09:06 +0000 (16:09 +0900)]
agent: Fix wrong use of gcry_sexp_build_array

* findkey.c (agent_public_key_from_file): Fix use of
gcry_sexp_build_array.

--
A test case leading to a segv in Libgcrypt is

  gpg-connect-agent \
    "READKEY 9277C5875C8AFFCB727661C18BE4E0A0DEED9260" /bye

The keygrip was created by "monkeysphere s", which has a comment.

gcry_sexp_build_array expects pointers to the arguments which is quite
surprising.  Probably ARG_NEXT was accidentally implemented wrongly.
Anyway, we can't do anything about it and thus need to fix the check
the users of this function.

Some-comments-by: Werner Koch <wk@gnupg.org>
6 years agoSCD: Upon error, open_pcsc_reader_wrapped does same as _direct.
NIIBE Yutaka [Wed, 31 Oct 2012 02:05:55 +0000 (11:05 +0900)]
SCD: Upon error, open_pcsc_reader_wrapped does same as _direct.

* scd/apdu.c (PCSC_E_NO_SERVICE): New.
(open_pcsc_reader_direct): Use PCSC_E_NO_SERVICE.
(open_pcsc_reader_wrapped): Set pcsc_no_service.

7 years agoUpdate and enable French translation
Werner Koch [Fri, 24 Aug 2012 15:42:36 +0000 (17:42 +0200)]
Update and enable French translation

* po/fr.po: Update.
* po/LINGUAS: Enable fr.

7 years agoAdd POT file to .gitignore
Werner Koch [Fri, 24 Aug 2012 15:41:21 +0000 (17:41 +0200)]
Add POT file to .gitignore

--

7 years agoUpdate German translation
Werner Koch [Fri, 24 Aug 2012 08:20:16 +0000 (10:20 +0200)]
Update German translation

--
Actually only updates due to typo fixes in the English source.

7 years agoFix typos spotted during translations
David Prévot [Wed, 22 Aug 2012 16:54:38 +0000 (12:54 -0400)]
Fix typos spotted during translations

* agent/genkey.c: s/to to/to/
* sm/*.c: s/failed to allocated/failed to allocate/
* sm/certlist.c, ./dirmngr/validate.c: s/should have not/should not have/
* g10/seskey.c: missing closing parenthesis
* dirmngr/crlcache.c: s/may has/may have/

Consistency fix:

* g10/gpg.c, kbx/kbxutil.c, sm/gpgsm.c: uppercase after Syntax
* dirmngr/dirmngr_ldap: no period in Syntax
* dirmngr/dirmngr-client.c: infinitive for option description:
s/certificates are expected/expect certificates/

7 years agoActually show translators comments in PO files
David Prévot [Wed, 22 Aug 2012 16:54:37 +0000 (12:54 -0400)]
Actually show translators comments in PO files

--

7 years agoKeep previous msgids of translated messages
David Prévot [Wed, 22 Aug 2012 16:54:36 +0000 (12:54 -0400)]
Keep previous msgids of translated messages

* po/Makefile.in.in: Use --previous with msgmerge.

7 years agoFix build system for Android by disabling tests since its x-compiled
Hans-Christoph Steiner [Fri, 17 Aug 2012 02:43:15 +0000 (22:43 -0400)]
Fix build system for Android by disabling tests since its x-compiled

* configure.ac (HAVE_ANDROID_SYSTEM, RUN_TESTS): New.
(AH_BOTTOM) [__ANDROID__]: Do not re-define ttyname.
* Makefile.am: Depend tests on new RUN_TESTS conditional.

7 years agoFix left over use of jnlib on some platforms
Werner Koch [Fri, 24 Aug 2012 07:29:56 +0000 (09:29 +0200)]
Fix left over use of jnlib on some platforms

* tools/watchgnupg.c: Take mischelp.h from common/ and not jnlib/.

--

Also fixed in some comments.

7 years agoFix incorrect description of --delete-secret-key
Werner Koch [Thu, 9 Aug 2012 12:45:18 +0000 (14:45 +0200)]
Fix incorrect description of --delete-secret-key

--

This is bug#1429.

7 years agoscd: handle reader/token removal.
NIIBE Yutaka [Sun, 24 Jun 2012 01:45:49 +0000 (10:45 +0900)]
scd: handle reader/token removal.

* scd/apdu.c (pcsc_error_to_sw): PCSC_E_UNKNOWN_READER means
SW_HOST_NO_READER.

7 years agoChange all quotes in strings and comments to the new GNU standard.
Werner Koch [Tue, 5 Jun 2012 17:29:22 +0000 (19:29 +0200)]
Change all quotes in strings and comments to the new GNU standard.

The asymmetric quotes used by GNU in the past (`...') don't render
nicely on modern systems.  We now use two \x27 characters ('...').

The proper solution would be to use the correct Unicode symmetric
quotes here.  However this has the disadvantage that the system
requires Unicode support.  We don't want that today.  If Unicode is
available a generated po file can be used to output proper quotes.  A
simple sed script like the one used for en@quote is sufficient to
change them.

The changes have been done by applying

  sed -i "s/\`\([^'\`]*\)'/'\1'/g"

to most files and fixing obvious problems by hand.  The msgid strings in
the po files were fixed with a similar command.

7 years agoPrint the hash algorithm in colon mode key listing.
Werner Koch [Thu, 24 May 2012 08:13:39 +0000 (10:13 +0200)]
Print the hash algorithm in colon mode key listing.

* g10/keylist.c (list_keyblock_colon): Print digest_algo.

7 years agoFix type conflict warning.
Werner Koch [Thu, 24 May 2012 08:11:49 +0000 (10:11 +0200)]
Fix type conflict warning.

* g10/keylist.c: Change min_cert_level to a byte.

7 years agoSwitch to the new automagic beta numbering scheme.
Werner Koch [Fri, 11 May 2012 08:20:29 +0000 (10:20 +0200)]
Switch to the new automagic beta numbering scheme.

* configure.ac: Add all the require m4 magic.
--

This also removes the hack to allow custom version numbers which are
not considered a development version.  A custom version number can be
done anyway by simply setting the version to it and tag the release
with it.

7 years agoAdd tweaks for the not anymore patented IDEA algorithm.
Werner Koch [Tue, 8 May 2012 16:18:32 +0000 (18:18 +0200)]
Add tweaks for the not anymore patented IDEA algorithm.

* g10/keygen.c (keygen_set_std_prefs): Include IDEA only in PGP2
compatibility mode.
* g10/misc.c (idea_cipher_warn): Remove.  Also remove all callers.
* common/status.h (STATUS_RSA_OR_IDEA): Remove.  Do not emit this
status anymore.
--

To keep the number of actually used algorithms low, we want to support
IDEA only in a basically read-only way (unless --pgp2 is used during
key generation).  It does not make sense to suggest the use of this
old 64 bit blocksize algorithm.  However, there is old data available
where it might be helpful to have IDEA available.

7 years agoAlways require libksba.
Werner Koch [Tue, 8 May 2012 12:33:34 +0000 (14:33 +0200)]
Always require libksba.

--
The extra test for libksba and possible trouble building GnuPG without
ksba is not anymore worth the trouble.

7 years agopo: Update de.po.
Werner Koch [Tue, 8 May 2012 13:18:26 +0000 (15:18 +0200)]
po: Update de.po.

* po/de.po: Update.

7 years agocommon: Remove generated files only during maintainer-clean.
Werner Koch [Tue, 8 May 2012 13:14:58 +0000 (15:14 +0200)]
common: Remove generated files only during maintainer-clean.

* common/Makefile.am (CLEANFILES): Rename to MAINTAINERCLEANFILES.
--

In general this is not required because automake does this for files
in BUILT_SOURCES anyway.  However, having them in CLEANFILES is wrong.
This is bug#1398.

7 years agoagent: Fix deadlock in trustlist due to the switch to npth.
Werner Koch [Mon, 30 Apr 2012 12:37:36 +0000 (14:37 +0200)]
agent: Fix deadlock in trustlist due to the switch to npth.

* agent/trustlist.c (clear_trusttable): New.
(agent_reload_trustlist): Use new function.
(read_trustfiles): Require to be called with lock held.
(agent_istrusted): Factor all code out to ...
(istrusted_internal): new.  Add ALREADY_LOCKED arg.  Make sure the
table islocked.  Do not print TRUSTLISTFLAG stati if called internally.
(agent_marktrusted): Replace calls to agent_reload_trustlist by
explicit code.
--

In contrast to pth, npth does not use recursive mutexes by default.
However, the code in trustlist.c assumed recursive locks and thus we
had to rework it.

7 years agomake DNS and URI fields work in gpgsm --gen-key.
NIIBE Yutaka [Thu, 26 Apr 2012 08:23:39 +0000 (10:23 +0200)]
make DNS and URI fields work in gpgsm --gen-key.

* sm/certreqgen-ui.c (gpgsm_gencertreq_tty): Actually set mb_uri and
mb_dns.avoid buffer strncpy-induced buffer overrun

7 years agoavoid buffer strncpy-induced buffer overrun
Jim Meyering [Wed, 25 Apr 2012 15:42:53 +0000 (17:42 +0200)]
avoid buffer strncpy-induced buffer overrun

* dirmngr/crlcache.c (open_dir): Ensure that both this_update
and next_update member strings are NUL-terminated.

7 years agoremove doubled words in a comment
Jim Meyering [Wed, 25 Apr 2012 15:40:48 +0000 (17:40 +0200)]
remove doubled words in a comment

7 years agoChange license for some files in common to LGPLv3+/GPLv2+.
Werner Koch [Fri, 20 Apr 2012 13:43:06 +0000 (15:43 +0200)]
Change license for some files in common to LGPLv3+/GPLv2+.

Having the LGPL on the common GnuPG code helps to share code
between GnuPG and related projects (like GPGME and Libassuan).  This
is good for interoperability and to reduces bugs.

* common/asshelp.c, common/asshelp.h, common/asshelp2.c, common/b64dec.c
* common/b64enc.c, common/convert.c, common/dns-cert.c
* common/dns-cert.h common/exechelp-posix.c, common/exechelp-w32.c
* common/exechelp-w32ce.c, common/exechelp.h, common/get-passphrase.c
* common/get-passphrase.h, common/gettime.c, common/gpgrlhelp.c
* common/helpfile.c, common/homedir.c, common/http.c, common/http.h
* common/i18n.c, common/init.c, common/init.h, common/iobuf.c
* common/iobuf.h, common/localename.c, common/membuf.c, common/membuf.h
* common/miscellaneous.c, common/openpgp-oid.c, common/openpgpdefs.h
* common/percent.c, common/pka.c, common/pka.h, common/session-env.c
* common/session-env.h, common/sexp-parse.h, common/sexputil.c
* common/signal.c, common/srv.c, common/srv.h, common/ssh-utils.c
* common/ssh-utils.h, common/sysutils.c, common/sysutils.h
* common/tlv.c, common/tlv.h, common/ttyio.c, common/ttyio.h
* common/userids.c, common/userids.h, common/xasprintf.c: Change
license to LGPLv3+/GPLv2+/

7 years agofaq: Replace --list-ownerturst by --export-ownertrust.
Werner Koch [Tue, 17 Apr 2012 07:55:44 +0000 (09:55 +0200)]
faq: Replace --list-ownerturst by --export-ownertrust.

--

7 years agoFix killing PID -1.
Ben Kibbey [Tue, 10 Apr 2012 00:52:22 +0000 (20:52 -0400)]
Fix killing PID -1.

When the KILLSCD command had been sent a race condition would occur
causing PID -1 getting killed, which on Linux seems to terminate all
applications for the current user.

7 years agoDo not mix test result with progress lines.
Werner Koch [Thu, 5 Apr 2012 18:32:42 +0000 (20:32 +0200)]
Do not mix test result with progress lines.

This makes parsing of the results easier.  Fixes bug#1400.

* tests/openpgp/defs.inc (progress_cancel, progress_end)
(progress_new): New.
* tests/openpgp/conventional-mdc.test: Use progress functions
* tests/openpgp/conventional.test: Ditto.
* tests/openpgp/encrypt-dsa.test: Ditto.
* tests/openpgp/encrypt.test: Ditto.
* tests/openpgp/sigs.test: Ditto.
--
The new output style is now:

      > MD5 SHA1 RIPEMD160 SHA256 SHA384 SHA512 SHA224 <
  PASS: sigs.test

or if the test fails:

      > MD5 SHA1
  sigs.test: ooops
  FAIL: sigs.test

7 years agoMention status messages in the documentation.
Ben Kibbey [Wed, 4 Apr 2012 00:53:23 +0000 (20:53 -0400)]
Mention status messages in the documentation.

Note INQUIRE_MAXLEN.

7 years agoDocument PASSWD --preset.
Ben Kibbey [Wed, 4 Apr 2012 00:53:22 +0000 (20:53 -0400)]
Document PASSWD --preset.

7 years agoDocument GENKEY options.
Ben Kibbey [Wed, 4 Apr 2012 00:53:21 +0000 (20:53 -0400)]
Document GENKEY options.

7 years agoDocument PRESET_PASSPHRASE.
Ben Kibbey [Wed, 4 Apr 2012 00:53:20 +0000 (20:53 -0400)]
Document PRESET_PASSPHRASE.

7 years agoDocument CLEAR_PASSPHRASE.
Ben Kibbey [Wed, 4 Apr 2012 00:53:19 +0000 (20:53 -0400)]
Document CLEAR_PASSPHRASE.

And describe the --mode=normal option.

7 years agoFix timegm regression test.
Werner Koch [Tue, 27 Mar 2012 17:46:20 +0000 (19:46 +0200)]
Fix timegm regression test.

* common/t-timestuff.c (test_timegm): Change test to use January and
not February or December+1.  Bug spotted by Daniel Kahn Gillmor.