aboutsummaryrefslogtreecommitdiffstats
path: root/g10/tofu.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* g10: If an sqlite operation fails, map the error code to GPG_ERR_GENERALNeal H. Walfield2016-10-131-2/+17
| | | | | | | | | | | | | | * g10/tofu.c (get_policy): If an sqlite operation fails, map the error code to GPG_ERR_GENERAL. (ask_about_binding): Likewise. (build_conflict_set): Likewise. (get_trust): Likewise. (show_statistics): Likewise. (tofu_register_signature): Likewise. (tofu_register_encryption): Likewise. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: When changing a TOFU binding's policy, update the conflict infoNeal H. Walfield2016-10-121-17/+16
| | | | | | | | * g10/tofu.c (record_binding): Take an additional argument, CONFLICT. Set the binding's conflict accordingly. Update callers. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Make a singular string singular.Neal H. Walfield2016-10-121-1/+1
| | | | | | | * g10/tofu.c (ask_about_binding): Make the singular string singular. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Correctly determine whether a binding has a conflict.Neal H. Walfield2016-10-121-1/+1
| | | | | | | | * g10/tofu.c (build_conflict_set): A binding has a conflict is conflict is *not* NULL, not if it is NULL. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Fix a column's type in TOFU DB.Neal H. Walfield2016-10-121-1/+1
| | | | | | | | | | | * g10/tofu.c (initdb): Change policy from a boolean to an integer. -- Signed-off-by: Neal H. Walfield <[email protected]> Reported-by: Daniel Kahn Gillmor <[email protected]> Note: sqlite ignores type information so this change has no real impact.
* Revert "g10: Fix singular term."Werner Koch2016-10-071-1/+1
| | | | | | | | | | | | | | -- This reverts commit b0d2526bc4e5c663eeffe04500420c70cee98712. The number of format elements may not change in ngettext. The entire construct is anyway wrong because ngettext is passed a different value than what is used in the printf. We need to rework the use of most strings in tofu.c. Signed-off-by: Werner Koch <[email protected]>
* g10: Fix singular term.Justus Winter2016-10-061-1/+1
| | | | | | * g10/tofu.c (ask_about_binding): Fix singular message. Signed-off-by: Justus Winter <[email protected]>
* g10: Use appropriate variant of 'abs'.Justus Winter2016-10-061-6/+6
| | | | | | * g10/tofu.c (ask_about_binding): Use 'labs' instead of 'abs'. Signed-off-by: Justus Winter <[email protected]>
* g10: Fix memory leak.Justus Winter2016-09-191-0/+1
| | | | | | * g10/tofu.c (build_conflict_set): Free 'kb_all'. Signed-off-by: Justus Winter <[email protected]>
* Fix more spellingDaniel Kahn Gillmor2016-09-171-1/+1
| | | | | | | | | | | | | | | | | | | * NEWS, acinclude.m4, agent/command-ssh.c, agent/command.c, agent/gpg-agent.c, agent/keyformat.txt, agent/protect-tool.c, common/asshelp.c, common/b64enc.c, common/recsel.c, doc/DETAILS, doc/HACKING, doc/Notes, doc/TRANSLATE, doc/dirmngr.texi, doc/faq.org, doc/gpg-agent.texi, doc/gpg.texi, doc/gpgsm.texi, doc/instguide.texi, g10/armor.c, g10/gpg.c, g10/keyedit.c, g10/mainproc.c, g10/pkclist.c, g10/tofu.c, g13/sh-cmd.c, g13/sh-dmcrypt.c, kbx/keybox-init.c, m4/pkg.m4, sm/call-dirmngr.c, sm/gpgsm.c, tests/Makefile.am, tests/gpgscm/Manual.txt, tests/gpgscm/scheme.c, tests/openpgp/gpgv-forged-keyring.scm, tests/openpgp/multisig.test, tests/openpgp/verify.scm, tests/pkits/README, tools/applygnupgdefaults, tools/gpg-connect-agent.c, tools/mime-maker.c, tools/mime-parser.c: minor spelling cleanup. Signed-off-by: Daniel Kahn Gillmor <[email protected]>
* g10: On failure, propagate the return code.Neal H. Walfield2016-09-161-0/+1
| | | | | | | * g10/tofu.c (tofu_register_encryption): If get_trust fails, set RC. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Improve some comments and a string.Neal H. Walfield2016-09-161-9/+13
| | | | | -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Don't ignore failure. On failure, rollback.Neal H. Walfield2016-09-161-3/+15
| | | | | | | | * g10/tofu.c (tofu_set_policy): If record_binding fails, fail. If the function fails, rollback the transaction. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Load the key block if the supplied user id list is NULL.Neal H. Walfield2016-09-161-1/+1
| | | | | | | | * g10/tofu.c (tofu_register_encryption): Load the key block if USER_ID_LIST is NULL. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Use the accessor functions for accessing and comparing key idsNeal H. Walfield2016-09-161-7/+8
| | | | | | | | | | * g10/tofu.c (get_trust): Use the pk_main_keyid accessor function. (tofu_register_signature): Likewise. (tofu_register_encryption): Likewise. (tofu_set_policy): Likewise and also use pk_keyid and keyid_cmp. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Fix whitespace.Neal H. Walfield2016-09-141-1/+1
| | | | | | | * g10/tofu.c (show_statistics): Fix whitespace. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Correctly compute the euclidean distance.Neal H. Walfield2016-09-141-8/+10
| | | | | | | | | * g10/tofu.c (write_stats_status): Correctly compute the euclidean distance. (show_statistics): Likewise. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Change the default TOFU policy for UTKs to good.Neal H. Walfield2016-09-141-2/+2
| | | | | | | | * g10/tofu.c (get_trust): Change the default TOFU policy for UTKs to good. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Add missing static qualifier.Neal H. Walfield2016-09-141-1/+1
| | | | | | | * g10/tofu.c (cross_sigs): Add missing static qualifier. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Default to the "good" TOFU policy for keys signed by a UTK.Neal H. Walfield2016-09-141-0/+97
| | | | | | | | | * g10/tofu.c (signed_by_utk): New function. (get_trust): If a key is signed by an ultimately trusted key, then set any bindings to good. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Use the time a signature was seen, not the embedded time, for statsNeal H. Walfield2016-09-071-4/+3
| | | | | | | | * g10/tofu.c (ask_about_binding): Use the time that a signature was seen, not allegedly generated, when generating statistics. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Check for a new binding a bit later.Neal H. Walfield2016-09-071-9/+9
| | | | | | | | | * g10/tofu.c (build_conflict_set): Check for the current key after looking for conflicts and removing any '!'. -- Signed-off-by: Neal H. Walfield <[email protected]> Fixes-commit: 1f1f56e6
* g10: Change TOFU code to respect --faked-system-time.Neal H. Walfield2016-09-071-22/+36
| | | | | | | | | | | | | | | * g10/tofu.c (record_binding): New parameter now. Update callers. Don't use SQLite's strftime('%s','now') to get the current time, use NOW. (ask_about_binding): Likewise. (get_trust): New parameter now. Update callers. (show_statistics): Likewise. (tofu_register_signature): Don't use SQLite's strftime('%s','now') to get the current time, use gnupg_get_time(). (tofu_register_encryption): Likewise. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Use the correct conversion function.Neal H. Walfield2016-09-071-8/+8
| | | | | | | | | * g10/tofu.c (show_statistics): Use string_to_ulong, not string_to_long. -- Signed-off-by: Neal H. Walfield <[email protected]> Fixes-commit: 875ac921
* g10: Add missing sqrtu32.h and sqrtu32.c.Neal H. Walfield2016-09-071-3/+1
| | | | | | -- Signed-off-by: Neal H. Walfield <[email protected]> Fixes-commit: 875ac92.
* gpg: Fix format string issues in tofu.Werner Koch2016-09-071-21/+13
| | | | | | | * g10/tofu.c (write_stats_status): Use ulong for MESSSAGES. Fix format strings. Simplify by using the new write_status_printf. Signed-off-by: Werner Koch <[email protected]>
* g10: Temporary hack to repalce missing sqrtu32.Werner Koch2016-09-071-1/+3
| | | | | | -- Signed-off-by: Werner Koch <[email protected]>
* g10: Make sure some functions are passed a primary key.Neal H. Walfield2016-09-061-0/+4
| | | | | | | | * g10/tofu.c (get_trust): Make sure the caller provides a primary key. (tofu_register_signature): Likewise. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Tweak TOFU's verbosity.Neal H. Walfield2016-09-061-46/+32
| | | | | | | | * g10/tofu.c (time_ago_str): Only show the most significant unit. * g10/tofu.c (show_statistics): Tweak the output. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Only show the TOFU warning once per key.Neal H. Walfield2016-09-061-37/+55
| | | | | | | | | | | * g10/tofu.c (show_statistics): Return whether to call show_warning. Move the warning from here... (show_warning): ... to this new function. (tofu_get_validity): If show_statistics returns a non-zero value, call show_warning. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Record and show statistics for encrypted messages when using TOFUNeal H. Walfield2016-09-061-221/+428
| | | | | | | | | | | | | | | | | | | | | | * g10/tofu.c: Include "sqrtu32.h". (struct tofu_dbs_s.s): Rename get_trust_gather_other_keys to get_trust_gather_signature_stats. Add new field get_trust_gather_encryption_stats. (initdb): Create the encryptions table. (ask_about_binding): Show the encryption statistics too. (tofu_register): Rename from this... (tofu_register_signature): ... to this and update callers. (tofu_register_encryption): New function. (write_stats_status): Add parameters encryption_count, encryption_first_done and encryption_most_recent. Update callers. Compute the trust using the euclidean distance of the signature and signature count. Compare with twice the threshold. Include encryption count information in the TFS and TOFU_STATS lines. (show_statistics): Also get information about the encrypted messages. * g10/trustdb.c (tdb_get_validity_core): Use it. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Simplify the binding statistics shown for a TOFU conflict.Neal H. Walfield2016-09-061-76/+81
| | | | | | | * g10/tofu.c (ask_about_binding): Simplify binding statistics. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Refactor cross sig check code.Neal H. Walfield2016-09-051-309/+434
| | | | | | | | | | | | | | | | | | * g10/tofu.c (BINDING_NEW): New enum value. (BINDING_CONFLICT): Likewise. (BINDING_EXPIRED): Likewise. (BINDING_REVOKED): Likewise. (ask_about_binding): Move cross sig check from here... (get_trust): ... and the conflict set building from here... (build_conflict_set): ... to this new function. (format_conflict_msg_part1): Replace parameter conflict with conflict_set. Drop parameter fingerprint. Update callers. (ask_about_binding): Drop unused parameter conflict and redundant parameter bindings_with_this_email_count. Rename parameter bindings_with_this_email to conflict_set. Update callers. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: End transaction earlier.Neal H. Walfield2016-09-011-2/+1
| | | | | | | * g10/tofu.c (ask_about_binding): End the transaction earlier. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Don't consider cross-signed keys to be in conflict.Neal H. Walfield2016-09-011-4/+158
| | | | | | | | | | | | | | | | * g10/tofu.c (cross_sigs): New function. (ask_about_binding): If apparently conflicting keys are cross signed, then don't mark them as conflicting. -- Signed-off-by: Neal H. Walfield <[email protected]> If two keys are cross signed, then the same person (probably) controlled them both. In this case, don't raise a TOFU conflict. This usually occurs when someone transitions to a new key. When that person rotates to a third key, she will typically only cross sign it with the second key. As such, we check this transitively to avoid declaring a conflict between the 1st and 3rd key.
* g10: Fix typo.Neal H. Walfield2016-09-011-1/+1
| | | | | -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: When asking about a TOFU binding conflict, default to unknown.Neal H. Walfield2016-09-011-1/+9
| | | | | | | * g10/tofu.c (ask_about_binding): Default to unknown. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Improve text.Neal H. Walfield2016-09-011-5/+5
| | | | | | | | * g10/tofu.c (show_statistics): Improve the text (key and user id, not just key). -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Remove unused parameter.Neal H. Walfield2016-09-011-10/+5
| | | | | | | | * g10/tofu.c (show_statistics): Remove unused parameter sig_exclude. Update callers. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Be careful to not be in a transaction during long operationsNeal H. Walfield2016-09-011-18/+75
| | | | | | | | | | | | | | | | | | * g10/tofu.c (begin_transaction): New parameter only_batch. If set, only start a batch transaction if there is none and one has been requested. Update callers. (tofu_suspend_batch_transaction): New function. (tofu_resume_batch_transaction): Likewise. (ask_about_binding): Take a ctrl_t, not a tofu_dbs_t. Update callers. Gather statistics within a transaction. Suspend any batch transaction when getting user input. (get_trust): Take a ctrl_t, not a tofu_dbs_t. Update callers. Enclose in a transaction. (tofu_get_validity): Use a batch transaction, not a normal transaction. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: On a TOFU conflict, show whether the uids are expired or revokedNeal H. Walfield2016-08-311-1/+106
| | | | | | | | | | | * g10/tofu.c (struct signature_stats): Add fields is_expired and is_revoked. (signature_stats_prepend): Clear *stats when allocating it. (ask_about_binding): Also show whether the user ids are expired or revoked. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Always trust ultimately trusted keys.Neal H. Walfield2016-08-311-21/+21
| | | | | | | | * g10/tofu.c (get_trust): Always return TRUST_ULTIMATE for ultimately trusted keys. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Fix error detection.Neal H. Walfield2016-08-311-1/+1
| | | | | | | | | | * g10/tofu.c: first_seen == 0 is not an error. -- Signed-off-by: Neal H. Walfield <[email protected]> Fixes-commit: 0f1f02ac Regression-due-to: 45bb9a2a
* g10: Update a key's TOFU policy in a transaction.Neal H. Walfield2016-08-311-0/+4
| | | | | | | | * g10/tofu.c (tofu_set_policy): Do the update in a transaction. * g10/gpg.c (main): Do a TOFU policy update in a batch transaction. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Fix the show old policy functionality when changing a TOFU policy.Neal H. Walfield2016-08-311-23/+24
| | | | | | | * g10/tofu.c (record_binding): Fix the show old policy functionality. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Drop unused argument.Neal H. Walfield2016-08-311-6/+3
| | | | | | | * g10/tofu.c (begin_transaction): Remove unused option only_batch. -- Signed-off-by: Neal H. Walfield <[email protected]>
* gpg: Move state local to tofu.c to a private structure.Neal H. Walfield2016-08-311-16/+18
| | | | | | | | | * g10/gpg.h (struct server_control_s.tofu): Move fields in_transaction and batch_update_started from here... * g10/tofu.c (struct tofu_dbs_s): ... to here. -- Signed-off-by: Neal H. Walfield <[email protected]>
* gpg: Avoid name spaces clash with future sqlite versions (2).Neal H. Walfield2016-08-311-23/+23
| | | | | | | | | | | | * g10/gpgsql.h (gpgsql_arg_type): Rename SQLITE_ARG_END to GPGSQL_ARG_END, SQLITE_ARG_INT to GPGSQL_ARG_INT, SQLITE_ARG_LONG_LONG to GPGSQL_ARG_LONG_LONG, SQLITE_ARG_STRING to GPGSQL_ARG_STRING, and SQLITE_ARG_BLOB to GPGSQL_ARG_BLOB. -- This commit completes the work started in b1ba460. Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Improve TOFU batch update code.Neal H. Walfield2016-08-301-45/+63
| | | | | | | | | | | | | | | | | | | | | * g10/gpg.h (tofu): Rename field batch_update_ref to batch_updated_wanted. * g10/tofu.c (struct tofu_dbs_s): Rename field batch_update to in_batch_transaction. (begin_transaction): Only end an extant batch transaction if we are not in a normal transaction. When ending a batch transaction, really end it. Update ctrl->tofu.batch_update_started when starting a batch transaction. (end_transaction): Only release a batch transaction if ONLY_BATCH is true. When releasing a batch transaction, assert that there is no open normal transaction. Only allow DBS to be NULL if ONLY_BATCH is true. (tofu_begin_batch_update): Don't update ctrl->tofu.batch_update_started. (opendbs): Call end_transaction unconditionally. -- Signed-off-by: Neal H. Walfield <[email protected]>
* g10: Improve TOFU debugging output and some comments.Neal H. Walfield2016-08-301-21/+23
| | | | | -- Signed-off-by: Neal H. Walfield <[email protected]>