aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* gpg: add --passphrase-env VARNAME to read passphrase from environmentdkg/passphrase-envDaniel Kahn Gillmor2018-09-234-1/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * g10/keydb.h: declare set_passphrase_from_environment_variable() * g10/passphrase.c: set_passphrase_from_environment_variable() new function * g10/gpg.c: add new --passphrase-env argument, handle it. -- There are problems or difficulties (to varying degrees) with all of the techniques available for sending a passphrase directly to the GnuPG process when --pinentry-mode=loopback: * Passphrases on the command line often leak into the process table. * Passphrases in a file often leak into the disk. * Using an extra file descriptor to send a passphrase works well on platforms that make it easy to allocate and use extra file descriptors, but is pretty awkward on platforms that don't facilitate this. So this patch adds a new form of passphrase-passing, using an environment variable. In POSIX shell, this looks like (for example): mypass="IUuKctdEhH8' gpg --batch --pinentry-mode=loopback\ --passphrase-env=mypass --decrypt < message.txt Hopefully, this is easier to use than --passphrase-fd on platforms or language toolkits that don't facilitate file descriptor manipulation. Signed-off-by: Daniel Kahn Gillmor <[email protected]>
* g10: Fix memory leak for --card-status.NIIBE Yutaka2018-09-181-4/+3
| | | | | | * g10/card-util.c (card_status): Release memory of serial number. Signed-off-by: NIIBE Yutaka <[email protected]>
* g10: Fix another memory leak.NIIBE Yutaka2018-09-131-4/+3
| | | | | | | | | | | | * g10/skclist.c (enum_secret_keys): Use SK_LIST instead of pubkey_t. -- The use of pubkey_t was wrong. The use is just a list of keys, not with keyblock. With SK_LIST, release_sk_list releases memory by free_public_key. Signed-off-by: NIIBE Yutaka <[email protected]>
* g10: Fix memory leak (more).NIIBE Yutaka2018-09-131-5/+9
| | | | | | | | * g10/skclist.c (enum_secret_keys): Free SERIALNO on update. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* g10: Fix memory leak in enum_secret_keys.NIIBE Yutaka2018-09-131-2/+10
| | | | | | | | | | | * g10/skclist.c (enum_secret_keys): Don't forget to call free_public_key in the error return paths. -- Reported-by: Philippe Antoine GnuPG-bug-id: 4140 Signed-off-by: NIIBE Yutaka <[email protected]>
* Revert "dirmngr: hkp: Avoid potential race condition when some hosts die."NIIBE Yutaka2018-09-111-10/+13
| | | | | | | | This reverts commit 04b56eff118ec34432c368b87e724bce1ac683f9. -- Now the access to hosttable is serialized correctly.
* dirmngr: Serialize access to hosttable.NIIBE Yutaka2018-09-113-8/+64
| | | | | | | | | | | | | * dirmngr/dirmngr.h (ks_hkp_init): New. * dirmngr/dirmngr.c (main): Call ks_hkp_init. * dirmngr/ks-engine-hkp.c (ks_hkp_init): New. (ks_hkp_mark_host): Serialize access to hosttable. (ks_hkp_print_hosttable, make_host_part): Likewise. (ks_hkp_housekeeping, ks_hkp_reload): Likewise. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* common: Use iobuf_get_noeof to avoid undefined behaviors.NIIBE Yutaka2018-09-101-3/+3
| | | | | | | | | | | | | * common/iobuf.c (block_filter): Use iobuf_get_noeof. -- When singed integer has negative value, left shift computation is undefined in C. GnuPG-bug-id: 4093 Reported-by: Philippe Antoine Signed-off-by: NIIBE Yutaka <[email protected]>
* agent: Fix error code check from npth_mutex_init.NIIBE Yutaka2018-09-101-2/+6
| | | | | | | | | | | | | * agent/call-pinentry.c (initialize_module_call_pinentry): It's an error when npth_mutex_init returns non-zero. -- Actually, initialize_module_call_pinentry is only called once from main. So, this bug had no harm and having the static variable INITIALIZED is not needed. Signed-off-by: NIIBE Yutaka <[email protected]>
* dirmngr: Emit SOURCE status also on NO_DATA.Werner Koch2018-09-072-5/+20
| | | | | | | | | | | | | | | * dirmngr/ks-engine-hkp.c (ks_hkp_search): Send SOURCE status also on NO DATA error. (ks_hkp_get): Ditto. * g10/call-dirmngr.c (gpg_dirmngr_ks_search): Print "data source" info also on error. (gpg_dirmngr_ks_get): Ditto. -- If a keyserver does not return any data it can be useful to know which keyserver out of the pool answered. Signed-off-by: Werner Koch <[email protected]>
* dirmngr: hkp: Avoid potential race condition when some hosts die.Daniel Kahn Gillmor2018-09-071-13/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * dirmngr/ks-engine-hkp.c (select_random_host): Use atomic pass through the host table instead of risking out-of-bounds write. -- Multiple threads may write to hosttable[x]->dead while select_random_host() is running. For example, a housekeeping thread might clear the ->dead bit on some entries, or another connection to dirmngr might manually mark a host as alive. If one or more hosts are resurrected between the two loops over a given table in select_random_host(), then the allocation of tbl might not be large enough, resulting in a write past the end of tbl on the second loop. This change collapses the two loops into a single loop to avoid this discrepancy: each host's "dead" bit is now only checked once. As Werner points out, this isn't currently strictly necessary, since npth will not switch threads unless a blocking system call is made, and no blocking system call is made in these two loops. However, in a subsequent change in this series, we will call a function in this loop, and that function may sometimes write(2), or call other functions, which may themselves block. Keeping this as a single-pass loop avoids the need to keep track of what might block and what might not. GnuPG-bug-id: 2836 Signed-off-by: Daniel Kahn Gillmor <[email protected]>
* g10: Fix memory leak.NIIBE Yutaka2018-09-071-0/+2
| | | | | | | | | | * g10/import.c (read_block): Call free_packet to skip the packet. -- Reported-by: Philippe Antoine GnuPG-bug-id: 3916 Signed-off-by: NIIBE Yutaka <[email protected]>
* gpgscm: Suppress warnings for GCC > 6.NIIBE Yutaka2018-09-061-15/+14
| | | | | | | | | | | | | | | | | * tests/gpgscm/scheme.c (CASE): Use unused attribute for GCC > 6. (FALLTHROUGH): New for fallthrough. (Eval_Cycle): Use FALLTHROUGH. Remove not-needed comment of fallthrough. -- Since GCC combines C preprocessor macro expansion, the fallthrough comment doesn't work well to suppress warnings for -Wimplicit-fallthrough, near the macro CASE. To handle this problem, we use GCC's extension of unused label and fallthrough attributes. Signed-off-by: NIIBE Yutaka <[email protected]>
* Fix use of strncpy, which is actually good to use memcpy.NIIBE Yutaka2018-09-062-2/+2
| | | | | | | * common/ssh-utils.c (get_fingerprint): Use memcpy. * g10/build-packet.c (string_to_notation): Use memcpy. Signed-off-by: NIIBE Yutaka <[email protected]>
* artwork: State license of the logoWerner Koch2018-08-301-0/+8
| | | | --
* gpg: Explain error message in key generation with --batchWerner Koch2018-08-291-1/+3
| | | | | | | | * g10/keygen.c (generate_keypair): Show more info. -- GnuPG-bug-id: 3912 Signed-off-by: Werner Koch <[email protected]>
* doc: Minor additions to the gpg man pageWerner Koch2018-08-291-4/+10
| | | | | | | | | -- Includes a fix for GnuPG-bug-id: 3906 Signed-off-by: Werner Koch <[email protected]>
* gpg: Remove unused function get_pubkeys.Werner Koch2018-08-292-274/+4
| | | | | | | | * g10/getkey.c (get_pubkeys): Remove. (pubkey_free): Remove and use code directly ... (pubkeys_free): ... here. Signed-off-by: Werner Koch <[email protected]>
* doc: Show how to list envvars send to gpg-agent.Werner Koch2018-08-291-0/+9
| | | | | | | -- GnuPG-bug: 3353 Signed-off-by: Werner Koch <[email protected]>
* gpg: New option --known-notation.Werner Koch2018-08-294-7/+64
| | | | | | | | | | | | | | * g10/gpg.c (oKnownNotation): New const. (opts): Add option --known-notation. (main): Set option. * g10/parse-packet.c (known_notations_list): New local var. (register_known_notation): New. (can_handle_critical_notation): Rewrite to handle the new feature. Also print the name of unknown notations in verbose mode. -- GnuPG-bug-id: 4060 Signed-off-by: Werner Koch <[email protected]>
* gpg: Refresh expired keys originating from the WKD.Werner Koch2018-08-282-17/+99
| | | | | | | | | | | | | | | | | | | | | | | | * g10/getkey.c (getkey_ctx_s): New field found_via_akl. (get_pubkey_byname): Set it. (only_expired_enc_subkeys): New. (get_best_pubkey_byname): Add support to refresh expired keys from the WKD. -- A little drawback of that code is that if the WKD has no update for an expired key each access of the key will trigger a WKD lookup (unless cached by the dirmngr). To avoid this we need to record the last time we have checked for an update but that would in turn require that we update the keyring for each check. We defer this until we have a better key database which allows for fast updates of meta data. Testing the code is currently a bit cumbersome because it requires to update a key in the WKD several times. Eventually we we need a network emulation layer to provide sample data for the regression tests. GnuPG-bug-id: 2917 Signed-off-by: Werner Koch <[email protected]>
* gpg: Remove unused arg from a function.Werner Koch2018-08-284-5/+5
| | | | | | | * g10/getkey.c (get_best_pubkey_byname): Remove unused arg 'no_akl'. Change both callers. Signed-off-by: Werner Koch <[email protected]>
* gpg: Prepare for longer card fingerprints.Werner Koch2018-08-274-76/+89
| | | | | | | | | | | | | | | | | | | | | | * g10/call-agent.h (agent_card_info_s): Rename the "*valid" fields to "*len". * g10/call-agent.c (unhexify_fpr): Change to take a FPRLEN and to return the actual length. (agent_release_card_info): Adjust for these changes. * g10/card-util.c (print_sha1_fpr): Rename to print_shax_fpr and add arg FPRLEN. Change all callers to pass the length. (print_sha1_fpr_colon): Rename to print_shax_fpr_colon and add arg FPRLEN. Change all callers to pass the length. (fpr_is_zero): Add arg FPRLEN. (fpr_is_ff): Ditto. (show_card_key_info): Use the new functions. * g10/skclist.c (enum_secret_keys): Use MAX_FINGERPRINT_LEN. -- This is not needed right now but we should get rid of all hard coded fingerprint lengths. Thus this change. Signed-off-by: Werner Koch <[email protected]>
* g10: Fix enum_secret_keys for card keys.NIIBE Yutaka2018-08-271-3/+8
| | | | | | | * g10/skclist.c (enum_secret_keys): Since "KEY-FPR" returns fingerprint in binary, change it to hex string. Signed-off-by: NIIBE Yutaka <[email protected]>
* g10: Prefer to available card keys for decryption.NIIBE Yutaka2018-08-271-9/+57
| | | | | | | * g10/skclist.c (enum_secret_keys): Add logic to prefer decryption keys on cards. Signed-off-by: NIIBE Yutaka <[email protected]>
* g10: Move enum_secret_keys to skclist.c.NIIBE Yutaka2018-08-272-197/+198
| | | | | | | | | | | | | * g10/getkey.c (enum_secret_keys): Move to... * g10/skclist.c (enum_secret_keys): ... here. -- The function enum_secret_keys is not used by gpgv.c, but it is in getkey.c. Extending enum_secret_keys will require change of gpgv.c, so moving the function to the file for gpg is better. Signed-off-by: NIIBE Yutaka <[email protected]>
* g10: Fix comment of enum_secret_keys.NIIBE Yutaka2018-08-271-2/+0
| | | | | | | | | * g10/getkey.c (enum_secret_keys): Fix comment for usage of enum_secret_keys, following the previous change. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* g10: Enumerated keys for decryption should be unique.NIIBE Yutaka2018-08-272-2/+25
| | | | | | | | | | | * g10/getkey.c (enum_secret_keys): Collecting keys in the context, check duplicate to make sure returning only unique keys. * g10/pubkey-enc.c (get_session_key): Now, it's the responsibility of enum_secret_keys to free keys. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* g10: Change decryption key selection for public key encryption.NIIBE Yutaka2018-08-275-179/+155
| | | | | | | | | | | | | | | | | | | | | | | | | | * g10/mainproc.c (struct mainproc_context): It's now pubkey_enc_list. (do_proc_packets): Remove the first arg CTRL. Fix call of proc_pubkey_enc. (release_list): Handle pubkey_enc_list. (proc_pubkey_enc): Remove the first arg CTRL. Simply put the packet to pubkey_enc_list. (print_pkenc_list): Remove the last arg FAILED. (proc_encrypted): Only call print_pkenc_list once. Handle DEK here. (proc_packets, proc_signature_packets, proc_signature_packets_by_fd) (proc_encryption_packets): Fix call of do_proc_packets. * g10/packet.h (struct pubkey_enc_list): Define. * g10/pubkey-enc.c (get_it): Change the second argument K. (get_session_key): Select session key by LIST, using enum_secret_keys. * g10/gpgv.c (get_session_key): Change the second argument K. * g10/test-stubs.c (get_session_key): Likewise. -- Collect all PKT_PUBKEY_ENC packets, and then, process the PKT_ENCRYPTED* packet. Signed-off-by: NIIBE Yutaka <[email protected]>
* g10: Fix undefined behavior when EOF in parsing packet for S2K.NIIBE Yutaka2018-08-101-2/+2
| | | | | | | | | | | | | | | * g10/parse-packet.c (parse_symkeyenc): Use iobuf_get_noeof. (parse_key): Likewise. -- When EOF comes at parsing s2k.count, it is possible the value will be (unsigned long)-1. Then, the result of S2K_DECODE_COUNT will be undefined. This patch fixes undefined behavior. Reported-by: Philippe Antoine GnuPG-bug-id: 4093 Signed-off-by: NIIBE Yutaka <[email protected]>
* gpg: Set a limit for a WKD import of 256 KiB.Werner Koch2018-07-271-1/+9
| | | | | | | | | | | | * g10/call-dirmngr.c (MAX_WKD_RESULT_LENGTH): New. (gpg_dirmngr_wkd_get): Use it. -- WKD should return only a single key with just one UID. For key rollover 2 keys may be send. A total of 256 KiB seems to be a generous limit here. Signed-off-by: Werner Koch <[email protected]>
* dirmngr: Validate SRV records in WKD queries.Werner Koch2018-07-271-0/+12
| | | | | | | | | | | | * dirmngr/server.c (proc_wkd_get): Check the returned SRV record names to mitigate rogue DNS servers. -- I am not sure wether this really is very useful because the security relies on a trustworthy DNS system anyway. However, that check is easy enough to do. Signed-off-by: Werner Koch <[email protected]>
* common: New function to validate domain names.Werner Koch2018-07-273-2/+93
| | | | | | | * common/mbox-util.c (is_valid_domain_name): New. * common/t-mbox-util.c (run_dns_test): New test. Signed-off-by: Werner Koch <[email protected]>
* scd: Add support for Trustica Cryptoucan.Jiří Keresteš2018-07-263-3/+13
|
* Register DCO for Jiri Kerestes.NIIBE Yutaka2018-07-261-0/+3
| | | | --
* dirmngr: Print a WARNING status for DNS config problems.Werner Koch2018-07-2516-93/+196
| | | | | | | | | | | | | | | | | | | | | * dirmngr/dirmngr-status.h: New. * dirmngr/dirmngr.h: Include dirmngr-status.h and move some prototypes to that file. * dirmngr/t-support.c: New. * dirmngr/Makefile.am (dirmngr_SOURCES): Add dirmngr-status.h. (t_common_src): Add t-support.c. * dirmngr/server.c (dirmngr_status_printf): Bypass if CTRL is NULL. * dirmngr/dns-stuff.c: Include dirmngr-status.h. (libdns_init): Print WARNING status line. Change call callers to take and pass a CTRL argument. * g10/call-dirmngr.c (ks_status_cb): Print info for new WARNING status. -- To test this you can change RESOLV_CONF_NAME in dns-stuff.c and run gpg --recv-key -v SOMETHING. Signed-off-by: Werner Koch <[email protected]>
* gpg: Use 128 MiB as default AEAD chunk size.Werner Koch2018-07-242-7/+20
| | | | | | | | | * g10/gpg.c (oDebugAllowLargeChunks): New. (opts): New option --debug-allow-large-chunks. (main): Implement that option. -- Signed-off-by: Werner Koch <[email protected]>
* Register DCO fo Michael Haubenwallner.NIIBE Yutaka2018-07-171-0/+3
| | | | --
* doc: Add NEWS about the 2.2.9 releaseWerner Koch2018-07-121-0/+41
| | | | --
* gpg: Remove multiple subkey bindings during export-clean.Werner Koch2018-07-091-5/+84
| | | | | | | | | * g10/key-clean.c (clean_one_subkey_dupsigs): New. (clean_all_subkeys): Call it. -- GnuPG-bug-id: 3804 Signed-off-by: Werner Koch <[email protected]>
* gpg: Let export-clean remove expired subkeys.Werner Koch2018-07-094-12/+125
| | | | | | | | | | | | | | | * g10/key-clean.h (KEY_CLEAN_NONE, KEY_CLEAN_INVALID) (KEY_CLEAN_ENCR, KEY_CLEAN_AUTHENCR, KEY_CLEAN_ALL): New. * g10/key-clean.c (clean_one_subkey): New. (clean_all_subkeys): Add arg CLEAN_LEVEL. * g10/import.c (import_one): Call clean_all_subkeys with KEY_CLEAN_NONE. * g10/export.c (do_export_stream): Call clean_all_subkeys depedning on the export clean options. -- GnuPG-bug-id: 3622 Signed-off-by: Werner Koch <[email protected]>
* gpg: Split key cleaning function for clarity.Werner Koch2018-07-094-16/+54
| | | | | | | | | | | | * g10/key-clean.c (clean_key): Rename to clean_all_uids and split subkey cleaning into ... (clean_all_subkeys): new. Call that always after the former clean_key invocations. -- Note that the clean_all_subkeys function will later be extended. Signed-off-by: Werner Koch <[email protected]>
* gpg: Move key cleaning functions to a separate file.Werner Koch2018-07-0610-429/+495
| | | | | | | | | | | | | | | * g10/trust.c (mark_usable_uid_certs, clean_sigs_from_uid) (clean_uid_from_key, clean_one_uid, clean_key): Move to ... * g10/key-clean.c: new file. * g10/key-clean.h: New. * g10/Makefile.am (gpg_sources): Add new files. * g10/export.c, g10/import.c, g10/keyedit.c, g10/trustdb.c: Include new header. * g10/trustdb.h (struct key_item, is_in_klist): Move to ... * g10/keydb.h: here. -- Signed-off-by: Werner Koch <[email protected]>
* po: Add flag options for xgettext.Werner Koch2018-07-052-2/+57
| | | | | | | | * po/Makevars (XGETTEXT_OPTIONS): Add --flag options. -- GnuPG-bug-id: 4053, 4054 Signed-off-by: Werner Koch <[email protected]>
* gpg: Prepare for signatures with ISSUER_FPR but without ISSUER.Werner Koch2018-07-056-8/+60
| | | | | | | | | | | | | | | | | | * g10/getkey.c (get_pubkey_for_sig): New. (get_pubkeyblock_for_sig): New. * g10/mainproc.c (issuer_fpr_raw): Give global scope. (check_sig_and_print): Use get_pubkeyblock_for_sig. * g10/pkclist.c (check_signatures_trust): Use get_pubkey_for_sig. * g10/sig-check.c (check_signature2): Ditto. (check_signature_over_key_or_uid): Ditto. -- GnuPG-bug-id: 4046 The whole getkey stuff is still a mess with way to much duplication and missing caching of already fetched data. Signed-off-by: Werner Koch <[email protected]>
* doc: Typo fix in a comment.Werner Koch2018-07-051-1/+1
| | | | --
* gpg: Ignore too large user ids during import.Werner Koch2018-07-041-1/+30
| | | | | | | | | | | | * g10/import.c (read_block): Add special treatment for bad user ids and comment packets. -- See GnuPG-bug-id: 4022 for an example of a bogus user id. Signed-off-by: Werner Koch <[email protected]>
* indent: Fix indentation of read_block in g10/import.cWerner Koch2018-07-041-66/+67
| | | | | | -- Signed-off-by: Werner Koch <[email protected]>
* gpg: Extra check for sign usage when verifying a data signature.Werner Koch2018-07-041-2/+11
| | | | | | | | | | | * g10/sig-check.c (check_signature_end_simple): Check sign usage. -- Without this patch the signature verification fails only due to the missing back signature. This check better explains what went wrong. GnuPG-bug-id: 4014 Signed-off-by: Werner Koch <[email protected]>
* g10: Fix memory leak for PKT_signature.NIIBE Yutaka2018-07-033-3/+3
| | | | | | | | | | | | * g10/getkey.c (buf_to_sig): Free by free_seckey_enc. * g10/gpgcompose.c (signature): Likewise. * g10/sign.c (write_signature_packets): Likewise. -- Reported-by: Philippe Antoine GnuPG-bug-id: 4047 Signed-off-by: NIIBE Yutaka <[email protected]>