aboutsummaryrefslogtreecommitdiffstats
path: root/g10/trustdb.c
diff options
context:
space:
mode:
authorDaniel Kahn Gillmor <[email protected]>2020-02-26 17:53:22 +0000
committerWerner Koch <[email protected]>2020-03-18 12:50:52 +0000
commit810ea2cc684480c6aadceb2a10dd00f3fa67f2fb (patch)
treef981383126c8d06b107f0bf548afe8e35d70d3bf /g10/trustdb.c
parentgpg: Fix key expiration and usage for keys created at the Epoch. (diff)
downloadgnupg-810ea2cc684480c6aadceb2a10dd00f3fa67f2fb.tar.gz
gnupg-810ea2cc684480c6aadceb2a10dd00f3fa67f2fb.zip
gpg: Update --trusted-key to accept fingerprint as well as long key id.
* g10/trustdb.c (tdb_register_trusted_key): accept fingerprint as well as long key ID. * doc/gpg.texi: document that --trusted-key can accept a fingerprint. -- GnuPG-bug-id: 4855 Signed-off-by: Daniel Kahn Gillmor <[email protected]> Fixed uses or return and kept the old string to avoid breaking translations. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'g10/trustdb.c')
-rw-r--r--g10/trustdb.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/g10/trustdb.c b/g10/trustdb.c
index 64e6ec349..00a53e0ea 100644
--- a/g10/trustdb.c
+++ b/g10/trustdb.c
@@ -205,22 +205,34 @@ tdb_register_trusted_keyid (u32 *keyid)
user_utk_list = k;
}
+
void
-tdb_register_trusted_key( const char *string )
+tdb_register_trusted_key (const char *string)
{
gpg_error_t err;
KEYDB_SEARCH_DESC desc;
+ u32 kid[2];
err = classify_user_id (string, &desc, 1);
- if (err || desc.mode != KEYDB_SEARCH_MODE_LONG_KID )
+ if (!err)
{
- log_error(_("'%s' is not a valid long keyID\n"), string );
- return;
+ if (desc.mode == KEYDB_SEARCH_MODE_LONG_KID)
+ {
+ register_trusted_keyid (desc.u.kid);
+ return;
+ }
+ if (desc.mode == KEYDB_SEARCH_MODE_FPR && desc.fprlen == 20)
+ {
+ kid[0] = buf32_to_u32 (desc.u.fpr+12);
+ kid[1] = buf32_to_u32 (desc.u.fpr+16);
+ register_trusted_keyid (kid);
+ return;
+ }
}
-
- register_trusted_keyid(desc.u.kid);
+ log_error (_("'%s' is not a valid long keyID\n"), string );
}
+
/*
* Helper to add a key to the global list of ultimately trusted keys.
* Returns: true = inserted, false = already in list.