diff options
author | Neal H. Walfield <[email protected]> | 2016-11-21 15:19:32 +0000 |
---|---|---|
committer | Neal H. Walfield <[email protected]> | 2016-11-21 15:39:53 +0000 |
commit | 91a0483c5db8ee4510981448a705981ee1cce199 (patch) | |
tree | 5583a2601a30186c2d9135cf5c82b33204577537 /g10/tofu.c | |
parent | build: Add repo-only maintainer script append-signature.sh. (diff) | |
download | gnupg-91a0483c5db8ee4510981448a705981ee1cce199.tar.gz gnupg-91a0483c5db8ee4510981448a705981ee1cce199.zip |
g10: Add a convenience function for checking if a key is a primary key
* 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]>
Diffstat (limited to 'g10/tofu.c')
-rw-r--r-- | g10/tofu.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/g10/tofu.c b/g10/tofu.c index 2c9d17cda..05d171d58 100644 --- a/g10/tofu.c +++ b/g10/tofu.c @@ -2186,7 +2186,7 @@ get_trust (ctrl_t ctrl, PKT_public_key *pk, if (opt.batch) may_ask = 0; - log_assert (keyid_cmp (pk_keyid (pk), pk_main_keyid (pk)) == 0); + log_assert (pk_is_primary (pk)); /* Make sure _tofu_GET_TRUST_ERROR isn't equal to any of the trust levels. */ @@ -3009,7 +3009,7 @@ tofu_register_signature (ctrl_t ctrl, if (rc) return rc; - log_assert (keyid_cmp (pk_keyid (pk), pk_main_keyid (pk)) == 0); + log_assert (pk_is_primary (pk)); sig_digest = make_radix64_string (sig_digest_bin, sig_digest_bin_len); fingerprint = hexfingerprint (pk, NULL, 0); @@ -3155,13 +3155,13 @@ tofu_register_encryption (ctrl_t ctrl, } if (/* We need the key block to find the primary key. */ - keyid_cmp (pk_keyid (pk), pk_main_keyid (pk)) != 0 + ! pk_is_primary (pk) /* We need the key block to find all user ids. */ || ! user_id_list) kb = get_pubkeyblock (pk->keyid); /* Make sure PK is a primary key. */ - if (keyid_cmp (pk_keyid (pk), pk_main_keyid (pk)) != 0) + if (! pk_is_primary (pk)) pk = kb->pkt->pkt.public_key; if (! user_id_list) @@ -3485,7 +3485,7 @@ tofu_set_policy (ctrl_t ctrl, kbnode_t kb, enum tofu_policy policy) if (DBG_TRUST) log_debug ("Setting TOFU policy for %s to %s\n", keystr (pk->keyid), tofu_policy_str (policy)); - if (keyid_cmp (pk_main_keyid (pk), pk_keyid (pk)) != 0) + if (! pk_is_primary (pk)) log_bug ("%s: Passed a subkey, but expecting a primary key.\n", __func__); fingerprint = hexfingerprint (pk, NULL, 0); @@ -3563,8 +3563,7 @@ tofu_get_policy (ctrl_t ctrl, PKT_public_key *pk, PKT_user_id *user_id, char *email; /* Make sure PK is a primary key. */ - log_assert (pk->main_keyid[0] == pk->keyid[0] - && pk->main_keyid[1] == pk->keyid[1]); + log_assert (pk_is_primary (pk)); dbs = opendbs (ctrl); if (! dbs) |