5 years agoagent: Replace es_mopen by es_fopenmem for ssh.
Werner Koch [Sun, 23 Mar 2014 12:42:53 +0000 (13:42 +0100)]
agent: Replace es_mopen by es_fopenmem for ssh.

* agent/command-ssh.c (ssh_read_key_public_from_blob): Use
(ssh_handler_request_identities): Ditto.
(ssh_request_process): Ditto.

es_fopenmem is easier to understand than the more general function
es_mopen.  Thus we better use the former for clarity.

5 years agoagent: Put ssh key type as comment into sshcontrol.
Werner Koch [Sat, 22 Mar 2014 20:28:35 +0000 (21:28 +0100)]
agent: Put ssh key type as comment into sshcontrol.

* agent/command-ssh.c (ssh_key_type_spec): Add field name.
(ssh_key_types): Add human readable names.
(add_control_entry): Add arg SPEC and print key type as comment.
(ssh_identity_register): Add arg SPEC.
(ssh_handler_add_identity): Add var SPEC and pass ssh_receive_key.

5 years agoagent: Support the Ed25519 signature algorithm for ssh.
Werner Koch [Sat, 22 Mar 2014 20:12:46 +0000 (21:12 +0100)]
agent: Support the Ed25519 signature algorithm for ssh.

* agent/command-ssh.c (SPEC_FLAG_IS_EdDSA): New.
(ssh_key_types): Add entry for ssh-ed25519.
(ssh_identifier_from_curve_name): Move to the top.
(stream_read_skip): New.
(stream_read_blob): New.
(ssh_signature_encoder_rsa): Replace MPIS array by an s-exp and move
the s-exp parsing to here.
(ssh_signature_encoder_dsa): Ditto.
(ssh_signature_encoder_ecdsa): Ditto.
(ssh_signature_encoder_eddsa): New.
(sexp_key_construct): Rewrite.
(ssh_key_extract): Rename to ...
(ssh_key_to_blob): .. this and rewrite most of it.
(ssh_receive_key): Add case for EdDSA.
(ssh_convert_key_to_blob, key_secret_to_public): Remove.
(ssh_send_key_public): Rewrite.
(ssh_handler_request_identities): Simplify.
(data_sign): Add rename args.  Add new args HASH and HASHLEN.  Make
use of es_fopenmen and es_fclose_snatch.  Remove parsing into MPIs
which is now doe in the sgnature encoder functions.
(ssh_handler_sign_request): Take care of Ed25519.
(ssh_key_extract_comment): Rewrite using gcry_sexp_nth_string.

To make the code easier readable most of the Ed25591 work has been
done using a new explicit code path.  Warning: Libgcrypt 1.6.1 uses a
non optimized implementation for Ed25519 and timing attacks might be

While working on the code I realized that it could need more rework;
it is at some places quite baroque and more complicated than needed.
Given that we require Libgcrypt 1.6 anyway, we should make more use of
modern Libgcrypt functions.

5 years agoagent: Cleanups to prepare implementation of Ed25519.
Werner Koch [Sat, 22 Mar 2014 19:51:16 +0000 (20:51 +0100)]
agent: Cleanups to prepare implementation of Ed25519.

* agent/cvt-openpgp.c: Remove.
(convert_to_openpgp): Use gcry_sexp_extract_param.
* agent/findkey.c (is_eddsa): New.
(agent_is_dsa_key, agent_is_eddsa_key): Check whether ecc means EdDSA.
* agent/pksign.c (agent_pksign_do): Add args OVERRIDEDATA and

* common/ssh-utils.c (is_eddsa): New.
(get_fingerprint): Take care or EdDSA.

5 years agotools: Fix NULL deref in gpg-connect-agent.
Werner Koch [Tue, 18 Mar 2014 15:49:38 +0000 (16:49 +0100)]
tools: Fix NULL deref in gpg-connect-agent.

* tools/gpg-connect-agent.c (handle_inquire): Do not pass NULL to

5 years agodirmngr: Resurrect hosts in the HKP hosttable.
Werner Koch [Tue, 18 Mar 2014 10:07:05 +0000 (11:07 +0100)]
dirmngr: Resurrect hosts in the HKP hosttable.

* dirmngr/dirmngr.c (HOUSEKEEPING_INTERVAL): New.
(housekeeping_thread): New.
(handle_tick): Call new function.
* dirmngr/ks-engine-hkp.c (RESURRECT_INTERVAL): New.
(struct hostinfo_s): Add field died_at and set it along with the dead
(ks_hkp_print_hosttable): Print that info.
(ks_hkp_housekeeping): New.

The resurrection gives the host a chance to get back to life the next
time a new host is selected.

5 years agocommon: New function elapsed_time_string.
Werner Koch [Tue, 18 Mar 2014 10:02:50 +0000 (11:02 +0100)]
common: New function elapsed_time_string.

* common/gettime.c (elapsed_time_string): New.

5 years agogpg: Reject signatures made with MD5.
Werner Koch [Mon, 17 Mar 2014 16:54:36 +0000 (17:54 +0100)]
gpg: Reject signatures made with MD5.

* g10/gpg.c: Add option --allow-weak-digest-algos.
(main): Set option also in PGP2 mode.
* g10/options.h (struct opt): Add flags.allow_weak_digest_algos.
* g10/sig-check.c (do_check): Reject MD5 signatures.
* tests/openpgp/ Add allow_weak_digest_algos to gpg.conf.

5 years agogpg: Make --auto-key-locate work again with keyservers.
Werner Koch [Mon, 17 Mar 2014 14:39:33 +0000 (15:39 +0100)]
gpg: Make --auto-key-locate work again with keyservers.

* dirmngr/ks-engine-hkp.c (ks_hkp_get): Allow exact search mode.
* g10/keyserver.c (keyserver_import_name): Implement.
(keyserver_get): Use exact mode for name based import.
(keyserver_get): Add args R_FPR and R_FPRLEN.  Change all callers.

5 years agogpg: New mechanism "clear" for --auto-key-locate.
Werner Koch [Mon, 17 Mar 2014 14:36:15 +0000 (15:36 +0100)]
gpg: New mechanism "clear" for --auto-key-locate.

* g10/getkey.c (parse_auto_key_locate): Implement "clear".

5 years agogpg-connect-agent: Make it easier to connect to the dirmngr.
Werner Koch [Fri, 14 Mar 2014 18:25:58 +0000 (19:25 +0100)]
gpg-connect-agent: Make it easier to connect to the dirmngr.

* tools/gpg-connect-agent.c: Add options --dirmngr and

5 years agodirmngr: Make use of IPv4 and IPV6 more explicit.
Werner Koch [Fri, 14 Mar 2014 16:00:10 +0000 (17:00 +0100)]
dirmngr: Make use of IPv4 and IPV6 more explicit.

* common/http.c (connect_server): Handle the new flags.
* common/http.h (HTTP_FLAG_IGNORE_IPv4, HTTP_FLAG_IGNORE_IPv4): New.
* dirmngr/ks-engine-hkp.c (map_host): Add arg r_httpflags.
(make_host_part): Ditto.
(send_request): Add arg httpflags.
(ks_hkp_search, ks_hkp_get, ks_hkp_put): Handle httpflags.

5 years agodirmngr: Do not use brackets around legacy IP addresses.
Werner Koch [Fri, 14 Mar 2014 15:22:54 +0000 (16:22 +0100)]
dirmngr: Do not use brackets around legacy IP addresses.

* dirmngr/ks-engine-hkp.c (my_getnameinfo): Change args to take a
complete addrinfo.  Bracket only v6 addresses.  Change caller.

5 years agogpg: Print the actual used keyserver address.
Werner Koch [Fri, 14 Mar 2014 15:12:54 +0000 (16:12 +0100)]
gpg: Print the actual used keyserver address.

* dirmngr/ks-engine-hkp.c (ks_hkp_search, ks_hkp_get): Print SOURCE
status lines.
* g10/call-dirmngr.c (ks_status_parm_s): New.
(ks_search_parm_s): Add field stparm.
(ks_status_cb): New.
(ks_search_data_cb): Send source to the data callback.
(gpg_dirmngr_ks_search): Change callback prototope to include the
SPECIAL arg.  Adjust all users.  Use ks_status_cb.
(gpg_dirmngr_ks_get): Add arg r_source and use ks_status_cb.
* g10/keyserver.c (search_line_handler): Adjust callback and print
"data source" disgnostic.
(keyserver_get): Print data source diagnostic.

It has often been requested that the actually used IP of a keyservers
is shown in with gpg --recv-key and --search-key.  This is helpful if
the keyserver is actually a pool of keyservers.  This patch does this.

5 years agodirmngr: Default to a user socket name and enable autostart.
Werner Koch [Wed, 12 Mar 2014 18:33:30 +0000 (19:33 +0100)]
dirmngr: Default to a user socket name and enable autostart.

* common/homedir.c (dirmngr_socket_name): Rename to
(dirmngr_user_socket_name): New.
* common/asshelp.c (start_new_dirmngr): Handle sys and user dirmngr
* dirmngr/dirmngr.c (main): Ditto.
* dirmngr/server.c (cmd_getinfo): Ditto.
* sm/server.c (gpgsm_server): Ditto.
* dirmngr/dirmngr-client.c (start_dirmngr): Likewise.
* tools/gpgconf.c (main): Print "dirmngr-sys-socket" with --list-dirs.

* (USE_DIRMNGR_AUTO_START): Set by default.

5 years agogpg: Add option --dirmngr-program.
Werner Koch [Wed, 12 Mar 2014 17:24:52 +0000 (18:24 +0100)]
gpg: Add option --dirmngr-program.

* g10/gpg.c: Add option --dirmngr-program.
* g10/options.h (struct opt): Add field dirmngr_program.
* g10/call-dirmngr.c (create_context): Use new var.

* dirmngr/dirmngr.c: Include gc-opt-flags.h.
(main): Remove GC_OPT_FLAG_*.
* tools/gpgconf-comp.c (GC_OPT_FLAG_NO_CHANGE): Move macro to ...
* common/gc-opt-flags.h: here.

5 years agodirmngr: Detect dead keyservers and try another one.
Werner Koch [Wed, 12 Mar 2014 13:32:34 +0000 (14:32 +0100)]
dirmngr: Detect dead keyservers and try another one.

* dirmngr/ks-action.c (ks_action_resolve): Rename var for clarity.
(ks_action_search, ks_action_put): Ditto.
(ks_action_get): Consult only the first server which retruned some

* dirmngr/ks-engine-hkp.c (SEND_REQUEST_RETRIES): New.
(map_host): Add arg CTRL and call dirmngr_tick.
(make_host_part): Add arg CTRL.
(mark_host_dead): Allow the use of an URL.
(handle_send_request_error): New.
(ks_hkp_search, ks_hkp_get, ks_hkp_put): Mark host dead and retry on

5 years agoComment typo fixes
Werner Koch [Wed, 12 Mar 2014 13:27:50 +0000 (14:27 +0100)]
Comment typo fixes


5 years agohttp: Add a flag to the URL parser indicating a literal v6 address.
Werner Koch [Wed, 12 Mar 2014 13:26:41 +0000 (14:26 +0100)]
http: Add a flag to the URL parser indicating a literal v6 address.

* common/http.h (struct parsed_uri_t): Add field v6lit.
* common/http.c (do_parse_uri): Set v6lit.

5 years agoscd: writekey support of ECC.
NIIBE Yutaka [Wed, 12 Mar 2014 08:25:33 +0000 (17:25 +0900)]
scd: writekey support of ECC.

* scd/app-openpgp.c (CURVE_SEC_P256K1, get_algo_byte): New.
(store_fpr): Support ECC keys with varargs.
(get_ecc_key_parameters, get_curve_name): Support secp256k1.
(parse_ecc_curve): Likewise.
(build_ecdsa_privkey_template, rsa_writekey, ecdsa_writekey): New.
(ecdh_writekey): New.  Not implemented yet.
(do_writekey): Call rsa_writekey, ecdsa_writekey, or ecdh_writekey.
(do_genkey): Follow the change of store_fpr.

Signed-off-by: NIIBE Yutaka <>
5 years agodirmngr: Put brackets around IP addresses in the hosttable.
Werner Koch [Tue, 11 Mar 2014 17:02:29 +0000 (18:02 +0100)]
dirmngr: Put brackets around IP addresses in the hosttable.

* dirmngr/ks-engine-hkp.c (EAI_OVERFLOW): Provide a substitute.
(my_getnameinfo): New.
(map_host): Use it.

5 years agodirmngr: Add command option to mark hosts as dead or alive.
Werner Koch [Tue, 11 Mar 2014 15:19:41 +0000 (16:19 +0100)]
dirmngr: Add command option to mark hosts as dead or alive.

* dirmngr/server.c (cmd_killdirmngr): Factor some code out to ...
(check_owner_permission): here.
(cmd_keyserver): Add options --dead and --alive.
* dirmngr/ks-engine-hkp.c (host_in_pool_p): New.
(ks_hkp_mark_host): New.

Also removed the warning that the widnows part has not yet been done.
AFAICS, the current mingw supports the all used socket functions.

5 years agodirmngr: Make Assuan output of keyblocks easier readable
Werner Koch [Tue, 11 Mar 2014 13:27:58 +0000 (14:27 +0100)]
dirmngr: Make Assuan output of keyblocks easier readable

* dirmngr/server.c (data_line_cookie_write): Print shorter data lines
in verbose mode.

5 years agodirmngr: Fix HKP host selection code.
Werner Koch [Tue, 11 Mar 2014 13:26:39 +0000 (14:26 +0100)]
dirmngr: Fix HKP host selection code.

* dirmngr/server.c (cmd_keyserver): Add option --resolve and change
--print-hosttable to --hosttable.
* dirmngr/ks-action.c (ks_printf_help): New.
(ks_action_resolve): New.
* dirmngr/ks-engine-hkp.c (select_random_host): Fix selection.
(ks_hkp_print_hosttable): Print to assuan stream.
(map_host): Remove debug code.  Add arg FORCE_SELECT.  Return numeric
IP addr if it can't be resolved.
(make_host_part): Add arg FORCE_SELECT; change callers to pass false.
(ks_hkp_resolve): New.

The new options for the keyserver command are useful for debugging.
For example:

  $ tools/gpg-connect-agent -S /usr/local/var/run/gnupg/S.dirmngr \
          'keyserver hkp://' \
          'keyserver' \
          'keyserver --resolve --hosttable' /bye


  S #
  S # http://2001:41d0:1:e673::1:11371
  S # hosttable (idx, ipv4, ipv6, dead, name):
  S #   0
  S #   .   --> 10 11 12 1 5 8 7 4* 2 9 6 3
  S #   1 4
  S #   2 4 6
  S #   3 4 6
  S #   4 4
  S #   5 4
  S #   6 4
  S #   7 4
  S #   8 4 6
  S #   9 4 6
  S #  10 4
  S #  11   6   2001:4d88:1ffc:477::7
  S #  12   6   2a00:1280:8000:2:1:8:0:1
  S #  13
  S #   .   --> 23 28* 30 17 22 8 7 27 25 14 21 20 19 29 [...]
  S #  14 4
  S #  15 4
  S #  16 4
  S #  17 4
  S #  18 4
  S #  19 4
  S #  20 4
  S #  21 4
  S #  22 4
  S #  23   6   2001:1608:21:6:84:200:66:125
  S #  24   6
  S #  25   6
  S #  26   6
  S #  27   6
  S #  28   6   2001:41d0:1:e673::1
  S #  29   6
  S #  30   6   2403:4200:401:10::13
  S #  31   6

5 years agoList readline support in configure summary
Werner Koch [Tue, 11 Mar 2014 08:24:16 +0000 (09:24 +0100)]
List readline support in configure summary

* m4/readline.m4: Set gnupg_cv_have_readline.
* Add readline support to summary output.

Readline is an optional feature which is build if the readline
development files are available on the build systems.  Too often they
are missing on a (new) build machine which at least makes debugging
Backport useful code from fixes for bug 1447.

* Cehck for inet_ntop.
* m4/libcurl.m4: Provide a #define for the version of the curl

We do not have keyserver helpers anymore but this fixes may come handy

5 years agoagent: API change of agent_key_from_file.
NIIBE Yutaka [Tue, 4 Mar 2014 02:54:59 +0000 (11:54 +0900)]
agent: API change of agent_key_from_file.

* agent/findkey.c (agent_key_from_file): Always return S-expression.
* agent/command.c (cmd_passwd): Distinguish by SHADOW_INFO.
(cmd_export_key): Likewise.  Free SHADOW_INFO.
(cmd_keytocard): Likewise.  Release S_SKEY.
* agent/pkdecrypt.c (agent_pkdecrypt): Likewise.
* agent/pksign.c (agent_pksign_do): Likewise.  Use the S-expression to
know the key type.

Signed-off-by: NIIBE Yutaka <>
5 years agoBackport useful code from fixes for bug 1447.
Werner Koch [Fri, 7 Mar 2014 08:46:44 +0000 (09:46 +0100)]
Backport useful code from fixes for bug 1447.

* Cehck for inet_ntop.
* m4/libcurl.m4: Provide a #define for the version of the curl

We do not have keyserver helpers anymore but this fixes may come handy

5 years agoscd: acquire lock in new_reader_slot.
Werner Koch [Fri, 7 Mar 2014 08:46:44 +0000 (09:46 +0100)]
scd: acquire lock in new_reader_slot.

* scd/apdu.c (new_reader_slot): Acquire lock.
(open_ct_reader, open_pcsc_reader_direct, open_pcsc_reader_wrapped)
(open_ccid_reader, open_rapdu_reader): Release lock.
(lock_slot, trylock_slot, unlock_slot): Move more to the top.

Fixes a test case of:
   No libpcsclite1 installed.
   Run gpg-agent
   Run command "gpg-connect-agent learn /bye" with no card/token
   Sometimes it fails: ERR 100663356 Not supported <SCD>
   While it should be always: ERR 100663404 Card error <SCD>

(cherry picked from commit 4f557cb9c2ebe274d6aacc60a09cd919055d01ed)

Resolved conflicts:
scd/apdu.c: pth/npth changes. Move lock helpers to the top.
                    Take care of removed pcsc_no_service.

5 years agoComment fixes.
Werner Koch [Fri, 16 Nov 2012 09:35:33 +0000 (10:35 +0100)]
Comment fixes.


Reported-by: Daniel Kahn Gillmor
(cherry picked from commit 7db5c81e3a40b60e146f29c6744a33fd1b88c090)

5 years agoDo not require libiconv for Android.
Werner Koch [Fri, 7 Mar 2014 08:46:44 +0000 (09:46 +0100)]
Do not require libiconv for Android.

* (require_iconv): New.  Set to false for android.
(AM_ICONV): Run only if required.

5 years agodirmmgr: Use a portability wrapper for struct timeval.
Werner Koch [Fri, 7 Mar 2014 08:46:44 +0000 (09:46 +0100)]
dirmmgr: Use a portability wrapper for struct timeval.

* dirmngr/dirmngr_ldap.c [W32]: Include winber.h.
(my_ldap_timeval_t): New.

5 years agoSilence more warnings about unused vars and args.
Werner Koch [Fri, 7 Mar 2014 08:46:44 +0000 (09:46 +0100)]
Silence more warnings about unused vars and args.

* dirmngr/cdblib.c (cdb_init) [W32]: Remove unused var.
* dirmngr/dirmngr-client.c (start_dirmngr): s/int/assuan_fd_t/.
* dirmngr/dirmngr.c (w32_service_control): Mark unused args.
(call_real_main): New.
(main) [W32]: Use new function to match prototype.
(real_main) [W32]: Mark unused vars.
(handle_signal) [W32]: Do not build the function at all.
(handle_connections) [W32]: Do not define signo.
* dirmngr/ldap-wrapper-ce.c (outstream_reader_cb): Remove used vars.
* g10/tdbio.c (ftruncate) [DOSISH]: Define only if not yet defined.

5 years agodirmngr: Simplify strtok macro.
Werner Koch [Fri, 7 Mar 2014 08:46:44 +0000 (09:46 +0100)]
dirmngr: Simplify strtok macro.

* dirmngr/ldap-url.c (ldap_utf8_strtok): Remove unused r3d arg.
(ldap_str2charray): Remove lasts.

I have no clue why an utf8 version was planned to be used.  Do the
LDAP folks really assume that eventually non-ascii delimiters might be
used?  Simplified it to silence the warning about an used helper var.

5 years agoUse attribute __gnu_printf__ also in estream header files.
Werner Koch [Fri, 7 Mar 2014 08:46:44 +0000 (09:46 +0100)]
Use attribute __gnu_printf__ also in estream header files.

* common/estream-printf.h: Use attribute gnu_printf.
* common/estream.h: Ditto.

5 years agoUse attribute __gnu_printf__ with our estream-printf functions.
Werner Koch [Fri, 7 Mar 2014 08:46:44 +0000 (09:46 +0100)]
Use attribute __gnu_printf__ with our estream-printf functions.

* common/mischelp.h (JNLIB_GCC_A_PRINTF): Use __gnu_printf__

Our printf supports most of the GNU features and thus we can silence
the warnings from mingw.

5 years agow32: Silence warnings about unused vars.
Werner Koch [Fri, 7 Mar 2014 08:46:44 +0000 (09:46 +0100)]
w32: Silence warnings about unused vars.

* agent/gpg-agent.c (main) [W32]: Mark unused vars.
* sm/gpgsm.c (run_protect_tool) [W32]: Ditto.
* g10/trustdb.c (check_regexp) [DISABLE_REGEX]: Ditto.
* scd/scdaemon.c (main) [W32]: Ditto.
(handle_connections) [W32]: Ditto.
(handle_signal) [W32]: Do not build the function at all.
* scd/apdu.c (pcsc_send_apdu_direct): Ditto.
(connect_pcsc_card): s/long/pcsc_dword_t/.
(open_pcsc_reader_direct): Remove var listlen.

5 years agow32: Fix a potential problem in gpgconf's gettext.
Werner Koch [Fri, 7 Mar 2014 08:46:44 +0000 (09:46 +0100)]
w32: Fix a potential problem in gpgconf's gettext.

* tools/gpgconf-comp.c (my_dgettext) [USE_SIMPLE_GETTEXT]: Make sure
to return something even DOMAIN is not given.

5 years agoSilence several warnings when building under Windows.
Werner Koch [Fri, 7 Mar 2014 08:46:44 +0000 (09:46 +0100)]
Silence several warnings when building under Windows.

* agent/call-scd.c (start_scd): Replace int by assuan_fd_t.
(start_pinentry): Ditto.
* common/asshelp.c (start_new_gpg_agent): Replace int by assuan_fd_t.
* common/dotlock.c (GNUPG_MAJOR_VERSION): Include stringhelp.h for
prototypes on Windows and some other platforms.
* common/logging.c (fun_writer): Declare addrbuf only if needed.
* g10/decrypt.c (decrypt_message_fd) [W32]: Return not_implemented.
* g10/encrypt.c (encrypt_crypt) [W32]: Return error if used in server
* g10/dearmor.c (dearmor_file, enarmor_file): Replace GNUPG_INVALID_FD
by -1 as temporary hack for Windows.
* g10/export.c (do_export): Ditto.
* g10/revoke.c (gen_desig_revoke, gen_revoke): Ditto.
* g10/sign.c (sign_file, clearsign_file, sign_symencrypt_file): Ditto.
* g10/server.c (cmd_verify, gpg_server) [W32]: Return an error.

The gpg server mode is not actual working and thus we can avoid the
warnings by explicitly disabling the mode.  We keep it working under
Unix, though.

5 years agow32: Include winsock2.h to silence warnings.
Werner Koch [Fri, 7 Mar 2014 08:46:44 +0000 (09:46 +0100)]
w32: Include winsock2.h to silence warnings.

5 years agogl: Avoid warning about shadowing an arg.
Werner Koch [Fri, 7 Mar 2014 08:46:44 +0000 (09:46 +0100)]
gl: Avoid warning about shadowing an arg.

* gl/setenv.c (KNOWN_VALUE): s/value/_v/.

5 years agocommon: Fix build problem with Sun Studio compiler.
Werner Koch [Fri, 15 Nov 2013 08:08:58 +0000 (09:08 +0100)]
common: Fix build problem with Sun Studio compiler.

* common/estream.c (ESTREAM_MUTEX_UNLOCK): Use int dummy dummy

GnuPG-bug-id: 1566
Signed-off-by: Werner Koch <>
(cherry picked from commit 571bcd4662a351cfa55bbf1a79ed1bc26da5780f)

Reolved conflicts:

Warning: estream.c still uses pth_mutex_* which is definitely wrong.
         Needs to be investigated.

5 years agogpg: Do not require a trustdb with --always-trust.
Werner Koch [Fri, 11 Oct 2013 07:25:58 +0000 (09:25 +0200)]
gpg: Do not require a trustdb with --always-trust.

* g10/tdbio.c (tdbio_set_dbname): Add arg R_NOFILE.
* g10/trustdb.c (trustdb_args): Add field no_trustdb.
(init_trustdb): Set that field.
(revalidation_mark):  Take care of a nonexistent trustdb file.
(read_trust_options): Ditto.
(tdb_get_ownertrust): Ditto.
(tdb_get_min_ownertrust): Ditto.
(tdb_update_ownertrust): Ditto.
(update_min_ownertrust): Ditto.
(tdb_clear_ownertrusts): Ditto.
(tdb_cache_disabled_value): Ditto.
(tdb_check_trustdb_stale): Ditto.
(tdb_get_validity_core): Ditto.
* g10/gpg.c (main): Do not create a trustdb with most commands for
trust-model always.

This slightly changes the semantics of most commands in that they
won't create a trustdb if --trust-model=always is used.  It just does
not make sense to create a trustdb if there is no need for it.

Signed-off-by: Werner Koch <>
(cherry picked from commit 1a0eeaacd1bf09fe5125dbc3f56016bc20f3512e)

Resolved conflicts:
g10/trustdb.c: Manually apply changes due to changed
                       function names.

Note that this also includes the fix for clear_ownertrust, see
GnuPG-bug-id: 1622.

5 years agogpg: Print a "not found" message for an unknown key in --key-edit.
Werner Koch [Fri, 4 Oct 2013 16:34:56 +0000 (18:34 +0200)]
gpg: Print a "not found" message for an unknown key in --key-edit.

* g10/keyedit.c (keyedit_menu): Print message.

GnuPG-bug-id: 1420
Signed-off-by: Werner Koch <>
(cherry picked from commit 0bf54e60d31389812d05c3fd29bece876204561d)

Resolved conflicts:
g10/keyedit.c: Fix white spaces

5 years agogpg: Protect against rogue keyservers sending secret keys.
Werner Koch [Fri, 4 Oct 2013 11:44:39 +0000 (13:44 +0200)]
gpg: Protect against rogue keyservers sending secret keys.

* g10/options.h (IMPORT_NO_SECKEY): New.
* g10/keyserver.c (keyserver_spawn, keyserver_import_cert): Set new
* g10/import.c (import_secret_one): Deny import if flag is set.

By modifying a keyserver or a DNS record to send a secret key, an
attacker could trick a user into signing using a different key and
user id.  The trust model should protect against such rogue keys but
we better make sure that secret keys are never received from remote

Suggested-by: Stefan Tomanek
Signed-off-by: Werner Koch <>
(cherry picked from commit e7abed3448c1c1a4e756c12f95b665b517d22ebe)

Resolved conflicts:

5 years agoagent: Fix UPDATESTARTUPTTY for ssh.
Werner Koch [Mon, 19 Aug 2013 09:44:59 +0000 (11:44 +0200)]
agent: Fix UPDATESTARTUPTTY for ssh.

* agent/command-ssh.c (setup_ssh_env): Fix env setting.

gniibe reported this to gnupg-devel on 2012-07-04:

  (2) UPDATESTARTUPTTY doesn't work to switch TTY for pinentry for


  Current implementation:

      In the function start_command_handler_ssh, the logic puts
      priority on ctrl->session_env which is initialized by
      agent_init_default_ctrl.  There are always GPG_TTY and TERM
      defined, because lines around 968 in gpg-agent.c, it says:

   /* Make sure that we have a default ttyname. */

      While UPDATESTARTUPTTY updates opt.startup_env, it doesn't
      affect at all.

  Here is a patch to point the issue.  Tested and works for me.

Signed-off-by: Werner Koch <>
(cherry picked from commit 9f5578c29adba6d4f7d3650121d07322c2f8d254)

5 years agogpgv: Init Libgcrypt to avoid syslog warning.
Werner Koch [Mon, 19 Aug 2013 09:22:11 +0000 (11:22 +0200)]
gpgv: Init Libgcrypt to avoid syslog warning.

* g10/gpgv.c (main): Check libgcrypt version and disable secure

GnuPG-bug-id: 1376
Signed-off-by: Werner Koch <>
(cherry picked from commit 3966eb244518d5612385d35a5149f7164a9fb707)

Resolved conflicts:

5 years agoImprove libcurl detection.
Werner Koch [Tue, 6 Aug 2013 08:31:54 +0000 (10:31 +0200)]
Improve libcurl detection.

* m4/libcurl.m4: Do not use AC_PATH_PROG if --with-libcurl as been
given.  Suggested by John Marshall.

GnuPG-bug-id: 1510
(cherry picked from commit 110b52fffa77b339e6d59eba939408f7e87e7138)

5 years agogpg: Remove legacy keyserver examples from the template conf file.
Werner Koch [Tue, 6 Aug 2013 08:04:12 +0000 (10:04 +0200)]
gpg: Remove legacy keyserver examples from the template conf file.

* g10/options.skel: Update.

(cherry picked from commit f3c5cc8bcd37e38b5d65db6a50466e22d03d1f0c)

5 years agow32: Define WINVER only if needed.
Werner Koch [Fri, 7 Mar 2014 08:46:44 +0000 (09:46 +0100)]
w32: Define WINVER only if needed.

* common/sysutils.c (WINVER): Define only if less that 5.0.

5 years agow32: Remove unused code.
Werner Koch [Thu, 1 Aug 2013 12:02:50 +0000 (14:02 +0200)]
w32: Remove unused code.

* jnlib/w32-reg.c (write_w32_registry_string): Remove.

5 years agoagent: Make --allow-mark-trusted the default.
Werner Koch [Wed, 3 Jul 2013 13:20:25 +0000 (15:20 +0200)]
agent: Make --allow-mark-trusted the default.

* agent/gpg-agent.c (opts, main): Add option --no-allow-mark-trusted.
Put this option into the gpgconf-list.
(main): Enable opt.allow_mark_trusted by default.
* tools/gpgconf-comp.c (gc_options_gpg_agent): Replace
allow-mark-trusted by no-allow-mark-trusted.

* agent/trustlist.c (agent_marktrusted): Always set the "relax" flag.


These changes have been in effect for the Gpg4win Windows version
since 2011-01-24 and thus first released with Gpg4win 2.1.0.  Given
the current state of PKIX it does not make any sense to lure the Unix
user into false security by making it harder to trust self-signed or
CAcert certificates.

Signed-off-by: Werner Koch <>
(cherry picked from commit 90b419f3e9d05e509348d047e05fcc79e87be6cf)

Resolved conflicts:

5 years agossh: Add support for Putty.
Werner Koch [Fri, 7 Mar 2014 08:46:44 +0000 (09:46 +0100)]
ssh: Add support for Putty.

* agent/gpg-agent.c [W32]: Include Several Windows header.
(opts): Change help text for enable-ssh-support.
(opts, main): Add option --enable-putty-support
(putty_support, PUTTY_IPC_MAGIC, PUTTY_IPC_MAXLEN): New for W32.
(agent_init_default_ctrl): Add and asssert call.
(putty_message_proc, putty_message_thread): New.
(handle_connections) [W32]: Start putty message thread.
* common/sysutils.c (w32_get_user_sid): New for W32 only
* tools/gpgconf-comp.c (gc_options_gpg_agent): Add
--enable-ssh-support and --enable-putty-support.  Make the
configuration group visible at basic level.
* agent/command-ssh.c (serve_mmapped_ssh_request): New for W32 only.

This patch enables support for Putty.  It has been tested with Putty
0.62 using an Unix created ssh key copied to the private-keys-v1.d
directory on Windows and with a manually crafted sshcontrol file.  It
also works with a smartcard key.

May thanks to gniibe who implemented a proxy in Python to test the
putty/gpg-agent communication.

Signed-off-by: Werner Koch <>
(cherry picked from commit 9f32499f99a0817f63f7a73b09bdcebe60d4775d)

Resolved conflicts:
agent/gpg-agent.c: Convert from pth to npth.

5 years agoagent: Fix binary vs. text mode problem in ssh.
Werner Koch [Wed, 3 Jul 2013 11:10:29 +0000 (13:10 +0200)]
agent: Fix binary vs. text mode problem in ssh.

* agent/command-ssh.c (file_to_buffer)
(ssh_handler_request_identities): Open streams in binary mode.
(start_command_handler_ssh): Factor some code out to ..
(setup_ssh_env): new function.

This is for now a theoretical fix because there is no ssh client yet
which uses the GnuPG style IPC.  OpenSSL for Cygwin uses only a quite
similar one.  gniibe suggested to implement that IPC style in
Libassuan so that a Cygwin version of OpenSSL may be used with GnuPG.

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

Also fixed one typo.

5 years agoFix syntax error for building on APPLE.
Werner Koch [Thu, 25 Apr 2013 11:00:16 +0000 (12:00 +0100)]
Fix syntax error for building on APPLE.

* scd/pcsc-wrapper.c [__APPLE__]: Fix syntax error.

For W32 and probably for Cygwin we don't need the wrapper, thus the
problems does not exhibit itself.

(cherry picked from commit 8ddf604659b93754ffa6dea295678a8adc293f90)

5 years agoIgnore obsolete option --disable-keypad.
Werner Koch [Thu, 18 Apr 2013 12:40:43 +0000 (14:40 +0200)]
Ignore obsolete option --disable-keypad.

* scd/scdaemon.c (opts): Ignore --disable-keypad.

The renaming of --disable-keypad to --disable-pinpad might mess up
configuration files managed with a GUI.  The GUI does not not anymore
know about the old option and would allow the user to switch
"disable-pinpad" on.  However, a "disable-keypad" might still linger
in the conf file with gpgconf not knowing about it.  Thus the conf
file would always be rejected and manual intervention would be
required.  Ignoring the old option nicely solves the problem.

(cherry picked from commit e24e92d7e244edd578c0c1f0fba6e0070cb5f104)

5 years agoAllow marking options as ignored.
Werner Koch [Thu, 18 Apr 2013 12:40:43 +0000 (14:40 +0200)]
Allow marking options as ignored.

* jnlib/argparse.h (ARGPARSE_OPT_IGNORE): New.
(ARGPARSE_TYPE_MASK): New, for internal use.
(ARGPARSE_ignore): New.
* jnlib/argparse.c (optfile_parse, arg_parse): Replace remaining
constants by macros.
(optfile_parse): Implement ARGPARSE_OPT_IGNORE.
(arg_parse): Exclide ignore options from --dump-options.

In addition to the ignore-invalid-option (commit 41d56433) it is often
useful to mark options in a configuration which as NOP.  For example
options which have no more function at all but can be expected to be
found in existing conf files.  Such an option (or command) may now be
given as

  ARGPARSE_ignore (300, "obsolete-option")

The 300 is merely used as a non-valid single option name much like
group names or the 500+n values used for long options.

Signed-off-by: Werner Koch <>
(cherry picked from commit 54c54e2824aab5716a187bbbf6dff8860d6a6056)

Resolved conflicts:
common/argparse.c: Fixed.

5 years agocommon: Fix recent commit 55656208.
Werner Koch [Thu, 6 Mar 2014 14:28:42 +0000 (15:28 +0100)]
common: Fix recent commit 55656208.

* common/membuf.c (get_membuf_shrink): Fix use of LEN.

Oops, what a stupid bug.

5 years agoFix g10/trust.c.
NIIBE Yutaka [Thu, 6 Mar 2014 07:23:10 +0000 (16:23 +0900)]
Fix g10/trust.c.

* g10/trust.c (register_trusted_keyid, register_trusted_key)
(update_ownertrust): Call functions with tdb_.

Signed-off-by: NIIBE Yutaka <>
5 years agocommon: Replace all macros in strusage() returned strings.
Werner Koch [Wed, 26 Feb 2014 15:50:59 +0000 (16:50 +0100)]
common: Replace all macros in strusage() returned strings.

* common/argparse.c (writechar): Remove.
(writestrings): Simplify.
(strusage): Use map_static_macro_string.

5 years agocommon: New function map_static_macro_string.
Werner Koch [Wed, 26 Feb 2014 15:18:45 +0000 (16:18 +0100)]
common: New function map_static_macro_string.

* common/mapstrings.c: New.
* common/t-mapstrings.c: New.
* common/t-support.h (DIM, DIMof): Define if not defined.
* common/ Add new files.

5 years agocommon: New function get_membuf_shrink.
Werner Koch [Wed, 26 Feb 2014 15:16:30 +0000 (16:16 +0100)]
common: New function get_membuf_shrink.

* common/membuf.c (get_membuf_shrink): New.

5 years agoagent: Fixed unresolved symbol under Windows.
Werner Koch [Wed, 19 Feb 2014 10:03:31 +0000 (11:03 +0100)]
agent: Fixed unresolved symbol under Windows.

* agent/gpg-agent.c (main): s/ttyname/gnupg_ttyname/.

This was not triggered by the latest mingw runtime but that has other
problems and thus I reverted to the same we used for gpg4win 2.1 which
is Debian Wheezy.

5 years agocommon: Require an installed libiconv.
Werner Koch [Tue, 18 Feb 2014 14:20:49 +0000 (15:20 +0100)]
common: Require an installed libiconv.

* common/utf8conv.c: Remove dynload.h.
(load_libiconv): Remove.  Remove all calls to it.

The iconv functions are standard feature on most systems and in any
case libiconv can be used to provide the functions.  The old code used
to dlopen iconv.dll on Windows.  This goes back to GnuPG-1 which was
designed as a one-binary program without any hard dependencies.
GnuPG2 however demands a lot of libraries anyway and thus there is no
more need for the fragile code to load a possible wrong version of
iconv.dll at runtime.

5 years agogpg: Silent more compiler warnings due to some configure options.
Werner Koch [Mon, 10 Feb 2014 22:12:28 +0000 (23:12 +0100)]
gpg: Silent more compiler warnings due to some configure options.

* g10/keygen.c (generate_keypair, gen_card_key)
(gen_card_key_with_backup) [!ENABLE_CARD_SUPPORT]: Mark unused args.

5 years agotests: Avoid segv if dns cert lookup is not configured.
Werner Koch [Mon, 10 Feb 2014 19:14:14 +0000 (20:14 +0100)]
tests: Avoid segv if dns cert lookup is not configured.

* common/dns-cert.c (get_dns_cert) [!USE_DNS_CERT]: Reset return args.

5 years agogpg: Cleanup compiler warnings due to some configure options.
Werner Koch [Mon, 10 Feb 2014 18:48:42 +0000 (19:48 +0100)]
gpg: Cleanup compiler warnings due to some configure options.

* g10/photoid.c (show_photos) [DISABLE_PHOTO_VIEWER]: Mark args as
* tools/gpgconf-comp.c (my_dgettext): Mark DOMAIN as unused if NLS is
not configured.

5 years agogpg: Allow building without any trust model support.
Werner Koch [Mon, 10 Feb 2014 16:05:54 +0000 (17:05 +0100)]
gpg: Allow building without any trust model support.

* Add option --disable-trust-models
(NO_TRUST_MODELS): New ac_define and am_conditional.
* g10/ (trust_source): New.
(gpg2_SOURCES): Factor some files out to above.  Add trust.c.
* g10/gpg.c [NO_TRUST_MODELS]: Disable options --export-ownertrust,
--import-ownertrust, --update-trustdb, --check-trustdb, --fix-trustdb,
--list-trustdb, --trustdb-name, --auto-check-trustdb,
--no-auto-check-trustdb, and --force-ownertrust.
(parse_trust_model) [NO_TRUST_MODELS]: Do not build.
(main) [NO_TRUST_MODELS]: Set trust_model to always and exclude all
trustdb related option code.
* g10/keyedit.c (cmds) [NO_TRUST_MODELS]: Remove menu items "trust",
"enable", and "disable".
* g10/keylist.c (public_key_list) [NO_TRUST_MODELS]: Do not print
"tru" record.

* g10/trust.c: New.
* g10/trustdb.c (struct key_item): Move to trustdb.h.
(register_trusted_keyid): Rename to tdb_register_trusted_keyid.
(register_trusted_key): Rename to tdb_register_trusted_key.
(trust_letter, uid_trust_string_fixed, trust_value_to_string)
(string_to_trust_value, get_ownertrust_with_min, get_ownertrust_info)
(get_ownertrust_string, get_validity_info, get_validity_string)
(clean_sigs_from_uid, clean_uid_from_key, clean_key): Move to trust.c.
(mark_usable_uid_certs): Move to trust.c and make global.
(is_in_klist): Move as inline to trustdb.h.
(trustdb_check_or_update): Rename to tdb_check_or_update
(revalidation_mark): Rename to tdb_revalidation_mark.
(get_ownertrust): Rename to tdb_get_ownertrust.
(get_min_ownertrust): Rename to tdb_get_min_ownertrust.
(update_ownertrust): Rename to tdb_update_ownertrust.
(clear_ownertrusts): Rename to tdb_clear_ownertrusts.
(cache_disabled_value): Rename to tdb_cache_disabled_value.
(check_trustdb_stale): Rename to tdb_check_trustdb_stale.
(get_validity): Rename to tdb_get_validity_core, add arg MAIN_PK and
factor some code out to ...
* trust.c (get_validity):
(check_or_update_trustdb): New wrapper.
(revalidation_mark): New wrapper.
(get_ownertrust): New wrapper.
(get_ownertrust_with_min): New wrapper.
(update_ownertrust): New wrapper.
(clear_ownertrusts): New wrapper.
(cache_disabled_value): New wrapper.
(check_trustdb_stale): New wrapper.

* tests/openpgp/ (opt_always): New.  Use in all tests instead
of --always-trust.

5 years agotests: Handle disabled algorithms.
Werner Koch [Mon, 10 Feb 2014 09:41:48 +0000 (10:41 +0100)]
tests: Handle disabled algorithms.

* tests/openpgp/mds.test: Skip disabled algorithms.
* tests/openpgp/signencrypt-dsa.test: Ditto.
* tests/openpgp/sigs-dsa.test: Ditto.

5 years agoSilence annoying ABI change warning.
Werner Koch [Wed, 27 Nov 2013 17:38:20 +0000 (18:38 +0100)]
Silence annoying ABI change warning.

* [GCC]: Pass -Wno-psabi for gcc >= 4.6.  Avoid some gcc
option tests for gcc >= 4.6
Signed-off-by: Werner Koch <>
(cherry picked from commit d04399a6a8b36a7fea92c304aa7309956a2e352b)

Resolved Conflicts: merged.

5 years agoAllow disabling of card support.
Werner Koch [Fri, 7 Feb 2014 12:46:36 +0000 (13:46 +0100)]
Allow disabling of card support.

* Add option --disable-card-support.  Also add
am_conditional and do not build scd if card support is enabled.

5 years agogpg: List only available algos in --gen-key.
Werner Koch [Fri, 7 Feb 2014 12:45:11 +0000 (13:45 +0100)]
gpg: List only available algos in --gen-key.

* g10/keygen.c (ask_algo, ask_curve): Take care of GPG_USE_<algo>.

5 years agogpg: Change --print-mds to output enabled OpenPGP algos.
Werner Koch [Fri, 7 Feb 2014 12:43:39 +0000 (13:43 +0100)]
gpg: Change --print-mds to output enabled OpenPGP algos.

* g10/gpg.c (print_mds): Use opengpg_md_test_algo.  Test also for MD5

5 years agogpg: Avoid compiler warnings for disabled algos.
Werner Koch [Fri, 7 Feb 2014 08:24:52 +0000 (09:24 +0100)]
gpg: Avoid compiler warnings for disabled algos.

* g10/misc.c (map_cipher_openpgp_to_gcry): Add case for disabled algo.
(openpgp_pk_test_algo2): Ditto.
(map_md_openpgp_to_gcry): Ditto.

5 years agogpg: Change format for the key size in --list-key and --edit-key.
Werner Koch [Wed, 5 Feb 2014 09:37:59 +0000 (10:37 +0100)]
gpg: Change format for the key size in --list-key and --edit-key.

* g10/gpg.c (oLegacyListMode, opts, main): Add --legacy-list-mode.
* g10/options.h (struct opt): Add field legacy_list_mode.
* g10/keydb.h (PUBKEY_STRING_SIZE): New.
* g10/keyid.c (pubkey_string): New.
* g10/import.c (import_one, import_secret_one): Use pubkey_string.
* g10/keylist.c (print_seckey_info): Ditto.
(print_pubkey_info, print_card_key_info): Ditto.
(list_keyblock_print): Ditto.
* g10/mainproc.c (list_node): Ditto.
* g10/pkclist.c (do_edit_ownertrust, build_pk_list): Ditto.
* g10/keyedit.c (show_key_with_all_names): Ditto.  Also change the
(show_basic_key_info): Ditto.
* common/openpgp-oid.c (openpgp_curve_to_oid): Also allow "ed25519".
(openpgp_oid_to_curve): Downcase "ed25519"

For ECC it seems to be better to show the name of the curve and not
just the size of the prime field.  The curve name does not anymore fit
into the "<size><letter>" descriptor (e.g. "2048R") and a fixed length
format does not work either.  Thus the new format uses

   "rsa2048"    - RSA with 2048 bit
   "elg1024"    - Elgamal with 1024 bit
   "ed25519"    - ECC using the curve Ed25519.
   "E_1.2.3.4"  - ECC using the unsupported curve with OID "".

unless --legacy-list-mode is given.  In does not anymore line up
nicely in columns thus I expect further changes to this new format.

Signed-off-by: Werner Koch <>
5 years agogpg: Add configure options to disable algorithms
Werner Koch [Fri, 31 Jan 2014 21:47:11 +0000 (22:47 +0100)]
gpg: Add configure options to disable algorithms

* acinclude.m4 (GNUPG_GPG_DISABLE_ALGO): New.
* Add --enable-gpg-* options to disable non MUS
* g10/misc.c (map_cipher_openpgp_to_gcry): Implement these options.
(openpgp_pk_test_algo2): Ditto.
(map_md_openpgp_to_gcry): Ditto.
(openpgp_cipher_test_algo, openpgp_md_test_algo): Simplify.

We have a similar feature in GnuPG-1.  Although we don't shrink the
size of the gpg binary by disabling algorithms (they are implemented
in Libgcrypt), this feature may still be useful for inerop testing.

5 years agogpg: Improve --version algo info output.
Werner Koch [Fri, 31 Jan 2014 14:55:04 +0000 (15:55 +0100)]
gpg: Improve --version algo info output.

* g10/misc.c (openpgp_pk_algo_name): Return a different string for
each ECC algorithm.
* g10/gpg.c (build_list_pk_test_algo): New wrapper to cope with the
different algo type enums.
(build_list_pk_algo_name): Ditto.
(build_list_cipher_test_algo): Ditto.
(build_list_cipher_algo_name): Ditto.
(build_list_md_test_algo): Ditto.
(build_list_md_algo_name): Ditto.
(my_strusage): Use them.
(list_config): Ditto. Add "pubkeyname".
(build_list): Add letter==1 hack.

5 years agogpg: Start using OpenPGP digest algo ids.
Werner Koch [Fri, 31 Jan 2014 14:33:03 +0000 (15:33 +0100)]
gpg: Start using OpenPGP digest algo ids.

* g10/misc.c (print_pubkey_algo_note): Use enum typedef for the arg.
(print_cipher_algo_note): Ditto.
(print_digest_algo_note): Ditto.
(map_md_openpgp_to_gcry): New.
(openpgp_md_test_algo): Rewrite.
(openpgp_md_algo_name): Rewrite to do without Libgcrypt.
* g10/cpr.c (write_status_begin_signing): Remove hardwired list of
algo ranges.

5 years agogpg: Use only OpenPGP cipher algo ids.
Werner Koch [Fri, 31 Jan 2014 13:35:49 +0000 (14:35 +0100)]
gpg: Use only OpenPGP cipher algo ids.

* g10/misc.c (map_cipher_openpgp_to_gcry): Use explicit mapping and
use enums for the arg and return value.
(map_cipher_gcry_to_openpgp): Ditto.
(openpgp_cipher_blocklen): Use constant macros.
(openpgp_cipher_test_algo): Use mapping function and prepare to
disable algorithms.
(openpgp_cipher_algo_name): Do not use Libgcrypt.

* g10/ecdh.c (pk_ecdh_encrypt_with_shared_point): Replace

* common/openpgpdefs.h (cipher_algo_t): Remove unused

Signed-off-by: Werner Koch <>
5 years agogpg: Use only OpenPGP public key algo ids and add the EdDSA algo id.
Werner Koch [Thu, 30 Jan 2014 17:48:37 +0000 (18:48 +0100)]
gpg: Use only OpenPGP public key algo ids and add the EdDSA algo id.

* common/sexputil.c (get_pk_algo_from_canon_sexp): Change to return a
* g10/keygen.c (check_keygrip): Adjust for change.
* sm/certreqgen-ui.c (check_keygrip): Likewise.

* agent/pksign.c (do_encode_dsa): Remove bogus map_pk_openpgp_to_gcry.

* g10/misc.c (map_pk_openpgp_to_gcry): Remove.
(openpgp_pk_test_algo): Change to a wrapper for openpgp_pk_test_algo2.
(openpgp_pk_test_algo2): Rewrite.
(openpgp_pk_algo_usage, pubkey_nbits): Add support for EdDSA.
(openpgp_pk_algo_name): Rewrite to remove need for gcry calls.
(pubkey_get_npkey, pubkey_get_nskey): Ditto.
(pubkey_get_nsig, pubkey_get_nenc): Ditto.
* g10/keygen.c(do_create_from_keygrip):  Support EdDSA.
(common_gen, gen_ecc, ask_keysize, generate_keypair): Ditto.
* g10/build-packet.c (do_key): Ditto.
* g10/export.c (transfer_format_to_openpgp): Ditto.
* g10/getkey.c (cache_public_key): Ditto.
* g10/import.c (transfer_secret_keys): Ditto.
* g10/keylist.c (list_keyblock_print, list_keyblock_colon): Ditto.
* g10/mainproc.c (proc_pubkey_enc): Ditto.
* g10/parse-packet.c (parse_key): Ditto,
* g10/sign.c (hash_for, sign_file, make_keysig_packet): Ditto.
* g10/keyserver.c (print_keyrec): Use openpgp_pk_algo_name.
* g10/pkglue.c (pk_verify, pk_encrypt, pk_check_secret_key): Use only
OpenPGP algo ids and support EdDSA.
* g10/pubkey-enc.c (get_it): Use only OpenPGP algo ids.
* g10/seskey.c (encode_md_value): Ditto.

This patch separates Libgcrypt and OpenPGP public key algorithms ids
and in most cases completely removes the Libgcrypt ones.  This is
useful because for Libgcrypt we specify the algorithm in the
S-expressions and the public key ids are not anymore needed.

This patch also adds some support for PUBKEY_ALGO_EDDSA which will
eventually be used instead of merging EdDSA with ECDSA.  As of now an
experimental algorithm id is used but the plan is to write an I-D so
that we can get a new id from the IETF.  Note that EdDSA (Ed25519)
does not yet work and that more changes are required.

The ECC support is still broken right now.  Needs to be fixed.

Signed-off-by: Werner Koch <>
5 years agogpg: Remove cipher.h and put algo ids into a common file.
Werner Koch [Wed, 29 Jan 2014 19:35:05 +0000 (20:35 +0100)]
gpg: Remove cipher.h and put algo ids into a common file.

* common/openpgpdefs.h (cipher_algo_t, pubkey_algo_t, digest_algo_t)
(compress_algo_t): New.
* agent/gpg-agent.c: Remove ../g10/cipher.h. Add openpgpdefs.h.
* g10/cipher.h (DEK): Move to ...
* g10/dek.h: new file.
* g10/cipher.h (is_RSA, is_ELGAMAL, is_DSA)
* g10/packet.h: here.
* g10/cipher.h: Remove.  Remove from all files.
* g10/filter.h, g10/packet.h:  Include dek.h.
* g10/ (common_source): Remove cipher.h.  Add dek.h.

Signed-off-by: Werner Koch <>
5 years agoinclude: Remove this directory.
Werner Koch [Wed, 29 Jan 2014 16:39:22 +0000 (17:39 +0100)]
include: Remove this directory.

* include/cipher.h: Move to ...
* g10/cipher.h: here.
* agent/gpg-agent.c: Adjust header file name.

* include/host2net.h: Move to ...
* common/host2net.h: here.  Change license to LGPLv3/GPLv2.  Adjust
notices to reflect that only me worked on that file.

* include/types.h: Remove.
* common/types.h: Include inttypes.h.  Add byte typedef and comments
for __riscos__.
* common/iobuf.h: Adjust header file name.

* include/_regex.h: Remove this unused file.

* include/ Remove.
* (SUBDIRS): Remove "include".
* (AC_CONFIG_FILES): Remove include/Makefile.
* include/ChangeLog-2011: Move to ...
* common/ChangeLog-2011.include: here.
* common/ (EXTRA_DIST): Add file.

* include/zlib-riscos.h: Move this repo only file to ...
* g10/zlib-riscos.h: here.

* include/: Remove.

include/ was a leftover from GnuPG 1.x times.

Signed-off-by: Werner Koch <>
5 years agogpg: Add another card vendor id.
Werner Koch [Wed, 29 Jan 2014 14:19:20 +0000 (15:19 +0100)]
gpg: Add another card vendor id.


5 years agoRemove unused u64 type definitions.
Werner Koch [Thu, 9 Jan 2014 18:14:09 +0000 (19:14 +0100)]
Remove unused u64 type definitions.

* Remove check for uint64 and UINT64_C.
* include/types.h: Remove u64 stuff.
* common/types.h: Ditto.

There have been relicts from GnuPG-1.

Signed-off-by: Werner Koch <>
5 years agoagent: Not remove SSH socket when already running.
NIIBE Yutaka [Thu, 16 Jan 2014 01:00:17 +0000 (10:00 +0900)]
agent: Not remove SSH socket when already running.

* agent/gpg-agent.c (main): Defer setting of socket_name_ssh to avoid
removal of the socket when it will die in create_server_socket for

Signed-off-by: NIIBE Yutaka <>
5 years agoagent: Fix agent_is_eddsa_key.
NIIBE Yutaka [Thu, 16 Jan 2014 00:07:11 +0000 (09:07 +0900)]
agent: Fix agent_is_eddsa_key.

* agent/findkey.c (agent_is_eddsa_key): Implemented.

Signed-off-by: NIIBE Yutaka <>
5 years agoAdd secp256k1.
NIIBE Yutaka [Wed, 15 Jan 2014 06:00:24 +0000 (15:00 +0900)]
Add secp256k1.

* common/openpgp-oid.c (openpgp_curve_to_oid): Add secp256k1.
(openpgp_oid_to_curve): Likewise.

* g10/keygen.c (ask_curve): Add secp256k1.

Signed-off-by: NIIBE Yutaka <>
5 years agospeedo: Add support for gpgex.
Werner Koch [Thu, 9 Jan 2014 18:14:09 +0000 (19:14 +0100)]
speedo: Add support for gpgex.

Speedo is now able to build gpgex for Windows.  Building gpa for
Windows does not yet work due to a bunch of other dependencies.

5 years agospeedo: Minor improvements.
Werner Koch [Thu, 9 Jan 2014 18:14:09 +0000 (19:14 +0100)]
speedo: Minor improvements.


5 years Add rule for 64 bit windows.
Werner Koch [Thu, 9 Jan 2014 18:14:09 +0000 (19:14 +0100)] Add rule for 64 bit windows.

5 years agoTurn into a generic script.
Werner Koch [Thu, 9 Jan 2014 18:14:09 +0000 (19:14 +0100)]
Turn into a generic script.

* Revamp.
* autogen.rc: New.
* (EXTRA_DIST): Add autogen.rc.

Signed-off-by: Werner Koch <>
5 years agoRename scripts/ to build-aux/
Werner Koch [Thu, 9 Jan 2014 18:14:09 +0000 (19:14 +0100)]
Rename scripts/ to build-aux/

* scripts/: Rename to build-aux/
* Adjust accordingly.
* (AC_CONFIG_AUX_DIR): Change to build-aux.

5 years agoImprove the speedo make script.
Werner Koch [Thu, 9 Jan 2014 18:14:09 +0000 (19:14 +0100)]
Improve the speedo make script.

* scripts/gpg-w32-dev/README: Remove
* scripts/gpg-w32-dev/GNUmakefile, scripts/gpg-w32-dev/
Merge into ..
* scripts/ this.

Speedo may now be used to build from GIT or tarballs and has a couple
of other improvements as well.  For best results the files
of all source package should be updated to the one used in gnupg.

Signed-off-by: Werner Koch <>
5 years Add envvar AUTOGEN_SH_SILENT
Werner Koch [Thu, 9 Jan 2014 18:14:09 +0000 (19:14 +0100)] Add envvar AUTOGEN_SH_SILENT


5 years agogpgsplit: Allow building without zlib support.
Werner Koch [Thu, 9 Jan 2014 18:05:07 +0000 (19:05 +0100)]
gpgsplit: Allow building without zlib support.

* tools/gpgsplit.c [!HAVE_ZLIB]: Do not include zlib.h.
(handle_zlib): Build only if HAVE_ZLIB is defined.
(write_part): Support zlib and zip only if HAVE_ZLIB is defined.

Signed-off-by: Werner Koch <>
5 years agow32: Fix backslash quoting in registry name.
Werner Koch [Thu, 9 Jan 2014 16:51:46 +0000 (17:51 +0100)]
w32: Fix backslash quoting in registry name.

* (GNUPG_REGISTRY_DIR): Double backslashes.

5 years agoFix test for zlib.
Werner Koch [Thu, 9 Jan 2014 14:36:35 +0000 (15:36 +0100)]
Fix test for zlib.

* (HAVE_ZLIB): Define only if found.

5 years agoAdd --enable-silent-rules stuff.
Werner Koch [Wed, 8 Jan 2014 15:47:46 +0000 (16:47 +0100)]
Add --enable-silent-rules stuff.


5 years agoAdd i686-w64-mingw32 as w32 toolchain to
Werner Koch [Wed, 8 Jan 2014 16:03:21 +0000 (17:03 +0100)]
Add i686-w64-mingw32 as w32 toolchain to


5 years agow32: Add macro for the registry key.
Werner Koch [Wed, 8 Jan 2014 10:47:07 +0000 (11:47 +0100)]
w32: Add macro for the registry key.

* (GNUPG_REGISTRY_DIR) [W32]: New ac-define.
* common/homedir.c (default_homedir): Use it.
* common/logging.c (do_logv): Use it.

5 years agogpg: Change --show-session-key to print the session key earlier.
Werner Koch [Wed, 11 Dec 2013 09:20:15 +0000 (10:20 +0100)]
gpg: Change --show-session-key to print the session key earlier.

* g10/cpr.c (write_status_strings): New.
(write_status_text): Replace code by a call to write_status_strings.
* g10/mainproc.c (proc_encrypted): Remove show_session_key code.
* g10/decrypt-data.c (decrypt_data): Add new show_session_key code.

This feature can be used to return the session key for just a part of
a file.  For example to downloading just the first 32k of a huge file,
decrypting that incomplete part and while ignoring all the errors
break out the session key.  The session key may then be used on the
server to decrypt the entire file without the need to have the private
key on the server.

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