g10: Make sure some functions are passed a primary key.

* g10/tofu.c (get_trust): Make sure the caller provides a primary key.
(tofu_register_signature): Likewise.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
This commit is contained in:
Neal H. Walfield 2016-09-06 22:40:59 +02:00
parent ee19eacd1d
commit 13ddc17ddb
1 changed files with 4 additions and 0 deletions

View File

@ -2011,6 +2011,8 @@ 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) == 0);
/* Make sure _tofu_GET_TRUST_ERROR isn't equal to any of the trust
levels. */
log_assert (_tofu_GET_TRUST_ERROR != TRUST_UNKNOWN
@ -2778,6 +2780,8 @@ tofu_register_signature (ctrl_t ctrl,
if (rc)
return rc;
log_assert (keyid_cmp (pk_keyid (pk), pk->main_keyid) == 0);
sig_digest = make_radix64_string (sig_digest_bin, sig_digest_bin_len);
fingerprint = hexfingerprint (pk, NULL, 0);