aboutsummaryrefslogtreecommitdiffstats
path: root/g10 (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* gpg,sm: Merge the two versions of check_special_filename.Werner Koch2016-11-292-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * sm/gpgsm.c (check_special_filename): Move to .. * common/sysutils.c (check_special_filename): here. Add arg NOTRANSLATE. (allow_special_filenames): New local var. (enable_special_filenames): New public functions. * sm/gpgsm.c (allow_special_filenames): Remove var. (main): Call enable_special_filenames instead of setting the var. (open_read, open_es_fread, open_es_fwrite): Call check_special_filename with 0 for NOTRANSLATE. * common/iobuf.c (special_names_enabled): Remove var. (iobuf_enable_special_filenames): Remove func. (check_special_filename): Remove func. (iobuf_is_pipe_filename): Call new version of the function with NOTRANSLATE set. (do_open): Ditto. * g10/gpg.c (main): Call enable_special_filenames instead of iobuf_enable_special_filenames. * g10/gpgv.c (main): Ditto. -- Note that we keep the iobuf.c:translate_file_handle because it is a bit different (for whatever reasons) than the translate function from sysutils. Signed-off-by: Werner Koch <[email protected]>
* g10: Fix memory leak.Justus Winter2016-11-291-4/+5
| | | | | | | * g10/decrypt.c (decrypt_messages): Properly decrease the reference count of the armor filters after pushing them. Signed-off-by: Justus Winter <[email protected]>
* Improve some comments.Neal H. Walfield2016-11-296-30/+51
|
* g10: Extend TOFU_STATS to always show the validityNeal H. Walfield2016-11-291-11/+19
| | | | | | | | | | | * doc/DETAILS (TOFU_STATS): Rename the VALIDITY field to SUMMARY. Add a new field called VALIDITY. * g10/tofu.c (write_stats_status): Update output accordingly. -- Signed-off-by: Neal H. Walfield <[email protected]> Change TOFU_STATS as discussed offline with Werner, Justus and Andre.
* g10: Fix iteration over getkey results.Justus Winter2016-11-281-1/+1
| | | | | | | | | * g10/getkey.c (getkey_next): Only ask 'lookup' for the exact match if our caller requested the key. Fixes a crash in 'lookup'. GnuPG-bug-id: 2848 Fixes-commit: 1d03cc77e1706f7da653153ad4b58c61e4fd2573 Signed-off-by: Justus Winter <[email protected]>
* g10: Avoid gratuitously loading a keyblock when it is already availableNeal H. Walfield2016-11-2311-50/+108
| | | | | | | | | | | * g10/trust.c (get_validity): Add new, optional parameter KB. Only load the keyblock if KB is NULL. Update callers. (get_validity): Likewise. * g10/trustdb.c (tdb_get_validity_core): Likewise. -- Signed-off-by: Neal H. Walfield <[email protected]> GnuPG-bug-id: 2812
* g10: Use es_fopen instead of open.Neal H. Walfield2016-11-221-11/+10
| | | | | | | | | | | * g10/tofu.c: Don't include <utime.h>, <fcntl.h> or <unistd.h>. (busy_handler): Replace use of open with es_fopen. -- Signed-off-by: Neal H. Walfield <[email protected]> Thanks for Werner for pointing this out: es_fopen is more portable than open.
* g10: If the set of UTKs changes, invalidate any changed policies.Neal H. Walfield2016-11-223-0/+159
| | | | | | | | | | | | | | | | * g10/trustdb.c (tdb_utks): New function. * g10/tofu.c (check_utks): New function. (initdb): Call it. * tests/openpgp/tofu.scm: Modify test to check the effective policy of keys whose effective policy changes when we change the set of UTKs. -- Signed-off-by: Neal H. Walfield <[email protected]> If the set of ultimately trusted keys changes, then it is possible that a binding's effective policy changes. To deal with this, we detect when the set of ultimately trusted keys changes and invalidate all cached policies.
* g10: Fix memory leak.Justus Winter2016-11-221-2/+0
| | | | | | | | * g10/tofu.c (tofu_notice_key_changed): Remove spurious duplicate call to 'hexfingerprint'. Fixes-commit: 037f9de09298a31026ea2ab5fbd4a599b11cc34f Signed-off-by: Justus Winter <[email protected]>
* g10: Cache the effective policy. Recompute it when required.Neal H. Walfield2016-11-218-351/+527
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * g10/tofu.c (initdb): Add column effective_policy to the bindings table. (record_binding): New parameters effective_policy and set_conflict. Save the effective policy. If SET_CONFLICT is set, then set conflict according to CONFLICT. Otherwise, preserve the current value of conflict. Update callers. (get_trust): Don't compute the effective policy here... (get_policy): ... do it here, if it was not cached. Take new parameters, PK, the public key, and NOW, the time that the operation started. Update callers. (show_statistics): New parameter PK. Pass it to get_policy. Update callers. (tofu_notice_key_changed): New function. * g10/gpgv.c (tofu_notice_key_changed): New stub. * g10/import.c (import_revoke_cert): Take additional argument CTRL. Pass it to keydb_update_keyblock. * g10/keydb.c (keydb_update_keyblock): Take additional argument CTRL. Update callers. [USE_TOFU]: Call tofu_notice_key_changed. * g10/test-stubs.c (tofu_notice_key_changed): New stub. * tests/openpgp/tofu.scm: Assume that manually setting a binding's policy to auto does not cause the tofu engine to forget about any conflict. -- Signed-off-by: Neal H. Walfield <[email protected]> We now store the computed policy in the tofu DB (in the effective_policy column of the bindings table) to avoid computing it every time, which is expensive. Further, policy is never overridden in case of a conflict. Instead, we detect a conflict if CONFLICT is not empty. This change is backwards compatible to existing DBs. The only minor incompatibility is that unresolved conflicts won't be automatically resolved in case we import a direct signature, or cross signatures.
* g10: Correctly parameterize ngettext.Neal H. Walfield2016-11-211-3/+6
| | | | | | * g10/tofu.c (ask_about_binding): Correctly parameterize ngettext. Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Don't use the same variable for multiple SQL compiled statementsNeal H. Walfield2016-11-211-4/+4
| | | | | | | | | | | | * g10/tofu.c (struct tofu_dbs_s): Remove unused field record_binding_update2. Replace register_insert with register_signature and register_encryption. (tofu_register_signature): Don't use dbs->s.register_insert, but dbs->s.register_signature. (tofu_register_encryption): Don't use dbs->s.register_insert, but dbs->s.register_encryption. Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Add a convenience function for checking if a key is a primary keyNeal H. Walfield2016-11-212-7/+13
| | | | | | | | | | | * g10/keydb.h (pk_is_primary): New function. * g10/tofu.c (get_trust): Use it. (tofu_register_signature): Likewise. (tofu_register_encryption): Likewise. (tofu_set_policy): Likewise. (tofu_get_policy): Likewise. Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Fix flags to open for lock of ToFU.NIIBE Yutaka2016-11-181-5/+2
| | | | | | | | | | | | * g10/tofu.c (busy_handler): Fix the flags and utime is not needed. -- The argument flags must include one of O_RDONLY, O_WRONLY, or O_RDWR. Adding O_TRUNC, the file is updated. So, utime is not needed. Fixes-commit: b2e1b17efa952afcf7aeec8b15e9d0088dba587a Signed-off-by: NIIBE Yutaka <[email protected]>
* g10: Fix creating a lock for ToFU.NIIBE Yutaka2016-11-181-1/+2
| | | | | | | | | | * g10/tofu.c (busy_handler): Add third argument which is mandatory for O_CREATE flag. -- Reported-by: Kristian Fiskerstrand Signed-off-by: NIIBE Yutaka <[email protected]>
* doc: Typo fixes.Werner Koch2016-11-171-1/+1
| | | | | | -- Reported-by: Nathan Musoke <[email protected]>
* common: Rename keybox_file_rename to gnupg_rename_file.Werner Koch2016-11-161-2/+2
| | | | | | | * kbx/keybox-util.c (keybox_file_rename): Rename to ... * common/sysutils.c (gnupg_rename_file): this. Change all callers. Signed-off-by: Werner Koch <[email protected]>
* gpg: New option --override-session-key-fd.Werner Koch2016-11-161-2/+43
| | | | | | | | | | | | | | | | | * g10/gpg.c (oOverrideSessionKeyFD): New. (opts): Add option --override-session-key-fd. (main): Handle that option. (read_sessionkey_from_fd): New. -- The override-session-key feature was designed to mitigate the effect of the British RIP act by allowing to keep the private key private and hand out only a session key. For that use case the leaking of the session key would not be a problem. However there are other use cases, for example fast re-decryption after an initial decryption, which would benefit from concealing the session key from other users. Signed-off-by: Werner Koch <[email protected]>
* gpgv: New option --enable-special-filenames.Werner Koch2016-11-151-0/+5
| | | | | | | | | | | | | | * g10/gpgv.c (oEnableSpecialFilenames): New. (opts): Add option --enable-special-filenames. (main): Implement that option. -- This is the same option we have in gpg. It allows to use commands like gpgv --enable-special-filenames -- '-&3' - <msg 3<msg.sig Signed-off-by: Werner Koch <[email protected]>
* gpg: Add new compliance mode "de-vs".Werner Koch2016-11-154-22/+52
| | | | | | | | | | | | | | | | | | | | * g10/options.h (CO_DE_VS): New. (GNUPG): Also allow CO_DE_VS. * g10/gpg.c (oDE_VS): New. (parse_compliance_option): Add "de-vs". (set_compliance_option): Set "de-vs". * g10/misc.c (compliance_option_string): Return a description string. (compliance_failure): Ditto. * g10/keygen.c (ask_algo): Take care of CO_DE_VS. (get_keysize_range): Ditto. (ask_curve): Add new field to CURVES and trun flags into bit flags. Allow only Brainpool curves in CO_DE_VS mode. -- As of now this compliance mode only restricts the set of algorithms and curves which can be created. Signed-off-by: Werner Koch <[email protected]>
* doc: Add comment to make clear that KBNODE is deprecated.Werner Koch2016-11-151-1/+1
| | | | | | | | | -- kbnode_t has replaced KBNODE for new code years ago, but that should be documented. No bulk changes please to keep git blame easy to read. Signed-off-by: Werner Koch <[email protected]>
* gpg: Use usual free semantics for packet structure free functions.Werner Koch2016-11-152-57/+76
| | | | | | | | | | | | | | | | | * g10/free-packet.c (free_attributes): Turn function into a nop for a NULL arg. (free_user_id): Ditto. (free_compressed): Ditto. (free_encrypted): Ditto. (free_plaintext): Ditto. (release_public_key_parts): Avoid extra check for NULL. * g10/getkey.c (get_best_pubkey_byname): Ditto. -- This change avoid surprises because it is common that function named like free and taking a pointer also have similar semantics. Signed-off-by: Werner Koch <[email protected]>
* g10: Optimize key iteration.Justus Winter2016-11-151-2/+2
| | | | | | | * g10/getkey.c (get_best_pubkey_byname): Use the node returned by 'getkey_next' instead of doing another lookup. Signed-off-by: Justus Winter <[email protected]>
* g10: Fix memory leak.Justus Winter2016-11-151-3/+14
| | | | | | | | | * g10/getkey.c (finish_lookup): Clarify that we do not return a reference. (lookup): Clarify the relation between RET_KEYBLOCK and RET_FOUND_KEY. Check arguments. Actually release the node if it is not returned. Signed-off-by: Justus Winter <[email protected]>
* g10: Fix iteration over getkey results.Justus Winter2016-11-151-0/+8
| | | | | | | | * g10/getkey.c (getkey_next): Fix invocation of 'lookup'. If we want to use RET_FOUND_KEY, RET_KEYBLOCK must be valid. Fixes-commit: 8ea72a776a88f3c851e812d258355be80caa1bc1 Signed-off-by: Justus Winter <[email protected]>
* g10: Fix use-after-free.Justus Winter2016-11-151-1/+9
| | | | | | | * g10/getkey.c (pubkey_cmp): Make a copy of the user id. (get_best_pubkey_byname): Free the user ids. Signed-off-by: Justus Winter <[email protected]>
* g10: Fix memory leak.NIIBE Yutaka2016-11-151-2/+1
| | | | | | | | | * g10/keyedit.c (menu_adduid): Don't copy 'sig'. -- Fixes-commit: 809d67e74014cb563efd965744fd11f87bbae743 Signed-off-by: NIIBE Yutaka <[email protected]>
* gpg: New option --compliance.Werner Koch2016-11-151-46/+119
| | | | | | | | | | | | * g10/gpg.c (oCompliance): New. (opts): Add "--compliance". (parse_tofu_policy): Use a generic description string for "help". (parse_compliance_option): New. (main): Add option oCompliance. Factor out code for compliance setting to ... (set_compliance_option): new. Signed-off-by: Werner Koch <[email protected]>
* g10: Fix memory leak.Justus Winter2016-11-151-0/+1
| | | | | | * g10/keyedit.c (menu_adduid): Deallocate 'sig'. Signed-off-by: Justus Winter <[email protected]>
* g10: Fix memory leak.Justus Winter2016-11-141-0/+2
| | | | | | | * g10/mainproc.c (check_sig_and_print): Free 'pk'. Fixes-commit: 37e3c897252babc203447be9d2f286a4507875ad Signed-off-by: Justus Winter <[email protected]>
* gpg,sm: Add STATUS_ERROR keydb_search and keydb_add-resource.Werner Koch2016-11-101-4/+14
| | | | | | | | | | | | | | | | * g10/keydb.c (keydb_add_resource): Make ANY_REGISTERED file-global. Write a STATUS_ERROR. (maybe_create_keyring_or_box): Check for non-accessible but existant file. (keydb_search): Write a STATUS_ERROR if no keyring has been registered but continue to return NOT_FOUND. * sm/keydb.c (keydb_add_resource): Rename ANY_PUBLIC to ANY_REGISTERED and make file-global. Write a STATUS_ERROR. (keydb_search): Write a STATUS_ERROR if no keyring has been registered but continue to return NOT_FOUND. Also add new arg CTRL and change all callers to pass it down. Signed-off-by: Werner Koch <[email protected]>
* gpg: Improve error message for --quick-gen-key.Werner Koch2016-11-101-1/+1
| | | | | | | | | * g10/keygen.c (parse_algo_usage_expire): Use a different error message for an unknown algorithm name. -- GnuPG-bug-id: 2832 Signed-off-by: Werner Koch <[email protected]>
* g10: Fix crash.Justus Winter2016-11-071-3/+4
| | | | | | | | | | | * g10/getkey.c (get_best_pubkey_byname): If 'get_pubkey_byname' does not return a getkey context, then it can return at most one key, therefore there is nothing to rank. Also, always initialize '*retctx' to be on the safe side. GnuPG-bug-id: 2828 Fixes: ab89164be02012f1bf159c971853b8610e966301 Signed-off-by: Justus Winter <[email protected]>
* Change all http://www.gnu.org in license notices to https://Werner Koch2016-11-0588-88/+88
| | | | --
* indent: Move comments inside the block.Werner Koch2016-11-041-48/+56
| | | | | | | | | | | | | | | | | | | | -- This fixes a few if (foo) /* A comment with several lines. */ { } Which has the problem that the block is visually not related to the "if" and might thus falsely be considered a standalone block. Also adds a asterisk on the left side of longer comments. Signed-off-by: Werner Koch <[email protected]>
* agent: Extend the PINENTRY_LAUNCHED inquiry and status.Werner Koch2016-11-031-0/+14
| | | | | | | | | * agent/call-pinentry.c (start_pinentry): Get flavor and version and pass it to agent_inq_pinentry_launched. * agent/command.c (agent_inq_pinentry_launched): Add arg EXTRA. * g10/server.c (gpg_proxy_pinentry_notify): Print a new diagnostic. Signed-off-by: Werner Koch <[email protected]>
* g10: Improve and unify key selection for -r and --locate-keys.Justus Winter2016-11-034-2/+214
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * g10/getkey.c (struct pubkey_cmp_cookie): New type. (key_is_ok, uid_is_ok, subkey_is_ok): New functions. (pubkey_cmp): Likewise. (get_best_pubkey_byname): Likewise. * g10/keydb.h (get_best_pubkey_byname): New prototype. * g10/keylist.c (locate_one): Use the new function. * g10/pkclist.c (find_and_check_key): Likewise. * tests/openpgp/Makefile.am (XTESTS): Add new test. (TEST_FILES): Add new files. * tests/openpgp/key-selection.scm: New file. * tests/openpgp/key-selection/0.asc: Likewise. * tests/openpgp/key-selection/1.asc: Likewise. * tests/openpgp/key-selection/2.asc: Likewise. * tests/openpgp/key-selection/3.asc: Likewise. * tests/openpgp/key-selection/4.asc: Likewise. -- When a name resembling a mail address is given to either --locate-keys or --recipient, rank the search results and use only the most relevant key. This also lets us query which key will be used for encryption using --locate-keys. However, note that --locate-keys may also return keys incapable of encryption, though it will prefer keys that have an encryption subkey. GnuPG-bug-id: 2359 Signed-off-by: Justus Winter <[email protected]>
* common: Improve compare_string_versions.Werner Koch2016-11-022-2/+2
| | | | | | | | | | | | | | | * common/stringhelp.c: Include limits.h. (compare_version_strings): Change semantics to behave like strcmp. Include the patch lebel in the comparison. Allow checking a single version string. * common/t-stringhelp.c (test_compare_version_strings): Adjust test vectors and a few new vectors. * g10/call-agent.c (warn_version_mismatch): Adjust to new sematics. * g10/call-dirmngr.c (warn_version_mismatch): Ditto. * sm/call-agent.c (warn_version_mismatch): Ditto. * sm/call-dirmngr.c (warn_version_mismatch): Ditto. Signed-off-by: Werner Koch <[email protected]>
* Spelling: correct spelling of "passphrase".Daniel Kahn Gillmor2016-11-021-2/+2
| | | | | | | | | | | There were several different variant spellings of "passphrase". This should fix them all for all English text. I did notice that po/it.po contains multiple instances of "passhprase", which also looks suspect to me, but i do not know Italian, so i did not try to correct it. Signed-off-by: Daniel Kahn Gillmor <[email protected]>
* g10,w32: Fix build on Windows.Justus Winter2016-11-021-4/+1
| | | | | | * g10/tofu.c (begin_transaction): Use the new 'gnupg_usleep'. Signed-off-by: Justus Winter <[email protected]>
* g10: Avoid gratuitious SQLite aborts and starving writers.Neal H. Walfield2016-10-311-16/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * g10/tofu.c: Include <time.h>, <utime.h>, <fcntl.h> and <unistd.h>. (tofu_dbs_s): Add fields want_lock_file and want_lock_file_ctime. (begin_transaction): Only yield if DBS->WANT_LOCK_FILE_CTIME has changed since we took the lock. Don't use gpgrt_yield to yield, but sleep for 100ms. After taking the batch lock, update DBS->WANT_LOCK_FILE_CTIME. Also take the batch lock the first time we take the real lock. When taking the real lock, use immediate not deferred mode to avoid gratuitious aborts. (end_transaction): When dropping the outermost real lock, drop the batch lock. (busy_handler): New function. (opendbs): Set the busy handler to it when opening the DB. Initialize CTRL->TOFU.DBS->WANT_LOCK_FILE. (tofu_closedbs): Free DBS->WANT_LOCK_FILE. -- Signed-off-by: Neal H. Walfield <[email protected]> By default, SQLite defers transactions until they are actually needed. A consequence of this is that if we have two readers and both decide to do a write, then one has to abort. To avoid this problem, we can make the outermost transaction an immediate transaction. This has the disadvantage that we only allow a single reader at a time, but at least we don't have gratuitous aborts anymore. A second problem is that SQLite apparently doesn't actually create a queue of waiters. The result is that doing a sched_yield between dropping and retaking the batch transaction is not enough to allow the other process to make progress. Instead, we need to wait a while (emperically: 100ms seems reasonable). To avoid waiting when there is no contention, we use a new file's timestamp to signal that there is a waiter.
* g10: Avoid reading in keys when possible.Neal H. Walfield2016-10-301-2/+16
| | | | | | | | | * g10/tofu.c (build_conflict_set): If CONFLICT_SET contains a single element, don't bother to check for cross sigs. Add parameter PK. Update callers. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Fix bit setting.Neal H. Walfield2016-10-301-4/+4
| | | | | | | | * g10/tofu.c (build_conflict_set): Fix bit setting. -- Signed-off-by: Neal H. Walfield <[email protected]> Fixes-commit: 1f1f56e606c1cb28eec68c60bd8bcb7ab30805de
* gpg: Enable the Issuer Fingerprint from rfc4880bisWerner Koch2016-10-282-12/+6
| | | | | | | | | | | | | | | | * g10/build-packet.c (build_sig_subpkt_from_sig): Always write the new Issuer Fingerprint sub-packet. * g10/mainproc.c (check_sig_and_print): Always consider that sub-packet. -- The specs for this sub-packet have been pushed to the OpenPGP WG's repo today. See-also: https://mailarchive.ietf.org/arch/msg/\ openpgp/GvPo2eSL9GW9WcGhOocY7KBa9FY Signed-off-by: Werner Koch <[email protected]>
* gpg: Verify multiple detached signatures with different hash algos.Werner Koch2016-10-271-5/+23
| | | | | | * g10/mainproc.c (proc_tree): Loose check. Enable all algos. Signed-off-by: Werner Koch <[email protected]>
* g10: Fix iteration over getkey results.Justus Winter2016-10-271-3/+6
| | | | | | | * g10/getkey.c (getkey_next): Return the public key in PK even if RET_KEYBLOCK is NULL. Signed-off-by: Justus Winter <[email protected]>
* Fix typos.Justus Winter2016-10-274-5/+5
| | | | | -- Signed-off-by: Justus Winter <[email protected]>
* g10: Assert preconditions.Justus Winter2016-10-271-0/+3
| | | | | | * g10/getkey.c (get_pubkey_byname): Assert preconditions. Signed-off-by: Justus Winter <[email protected]>
* gpg: Convey --quick option to dirmngr for --auto-key-retrieve.Werner Koch2016-10-2710-48/+59
| | | | | | | | | | | | | | | | | | * g10/call-dirmngr.c (gpg_dirmngr_ks_get): Add arg 'quick'. (gpg_dirmngr_wkd_get): Ditto. * g10/keyserver.c (keyserver_get): Add arg 'quick'. (keyserver_get_chunk): Add arg 'quick'. (keyserver_import_fprint): Ditto. Change callers to pass 0 for it. (keyserver_import_keyid): Ditto. (keyserver_import_wkd): Ditto. * g10/mainproc.c (check_sig_and_print): Call the 3 fucntions with QUICK set. -- Note that this option has not yet been implemented by dirmngr. Dirmngr will simply ignore it for now. Signed-off-by: Werner Koch <[email protected]>
* g10: Fix ECDH, clarifying the format.NIIBE Yutaka2016-10-271-18/+20
| | | | | | | | | | | * g10/ecdh.c (pk_ecdh_encrypt_with_shared_point): Returns error when it's short. Clarify the format. Handle other prefixes correctly. -- With the scdaemon's change, there is no case NBYTES < SECRET_X_SIZE. This fixes the break of ECDH with X25519. Signed-off-by: NIIBE Yutaka <[email protected]>