aboutsummaryrefslogtreecommitdiffstats
path: root/g10/getkey.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2015-05-07 10:01:12 +0000
committerWerner Koch <[email protected]>2015-05-07 10:12:41 +0000
commit874ef16e70ab750db7b153f17a7e859a0db6a2f1 (patch)
tree6dd9d2fba7ba5be68ee547a6ae5699ae9e4e941f /g10/getkey.c
parentgpg: Fix regression not displaying the card serial number (diff)
downloadgnupg-874ef16e70ab750db7b153f17a7e859a0db6a2f1.tar.gz
gnupg-874ef16e70ab750db7b153f17a7e859a0db6a2f1.zip
gpg: Improve 'General key info' line of --card-status.
* g10/keylist.c (print_pubkey_info): Print either "pub" or "sub". * g10/getkey.c (get_pubkey_byfprint): Add optional arg R_KEYBLOCK. * g10/keyid.c (keyid_from_fingerprint): Adjust for change. * g10/revoke.c (gen_desig_revoke): Adjust for change. * g10/card-util.c (card_status): Simplify by using new arg. Align card-no string. * g10/card-util.c (card_status): Remove not used GnuPG-1 code. -- This now prints "sub" if the first used card key is actually a subkey. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to '')
-rw-r--r--g10/getkey.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/g10/getkey.c b/g10/getkey.c
index 20b37d80e..e450c5655 100644
--- a/g10/getkey.c
+++ b/g10/getkey.c
@@ -968,17 +968,26 @@ get_pubkey_byfpr (PKT_public_key *pk, const byte *fpr)
}
-/* Search for a key with the given fingerprint.
+/* Search for a key with the given fingerprint. The caller need to
+ * prove an allocated public key object at PK. If R_KEYBLOCK is not
+ * NULL the entire keyblock is stored there and the caller needs to
+ * call release_kbnode() on it. Note that this function does an exact
+ * search and thus the public key stored at PK may be a copy of a
+ * subkey.
+ *
* FIXME:
* We should replace this with the _byname function. This can be done
* by creating a userID conforming to the unified fingerprint style.
*/
int
-get_pubkey_byfprint (PKT_public_key * pk,
+get_pubkey_byfprint (PKT_public_key *pk, kbnode_t *r_keyblock,
const byte * fprint, size_t fprint_len)
{
int rc;
+ if (r_keyblock)
+ *r_keyblock = NULL;
+
if (fprint_len == 20 || fprint_len == 16)
{
struct getkey_ctx_s ctx;
@@ -994,7 +1003,14 @@ get_pubkey_byfprint (PKT_public_key * pk,
memcpy (ctx.items[0].u.fpr, fprint, fprint_len);
rc = lookup (&ctx, &kb, 0);
if (!rc && pk)
- pk_from_block (&ctx, pk, kb);
+ {
+ pk_from_block (&ctx, pk, kb);
+ if (r_keyblock)
+ {
+ *r_keyblock = kb;
+ kb = NULL;
+ }
+ }
release_kbnode (kb);
get_pubkey_end (&ctx);
}