aboutsummaryrefslogtreecommitdiffstats
path: root/g10/getkey.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2005-01-20 17:21:40 +0000
committerWerner Koch <[email protected]>2005-01-20 17:21:40 +0000
commitb2b2786be1047e921fe50263915a565252a802ed (patch)
treeed076a7824239cba29acb3e4d3cda91a8a3d9d41 /g10/getkey.c
parentMinor changes (diff)
downloadgnupg-b2b2786be1047e921fe50263915a565252a802ed.tar.gz
gnupg-b2b2786be1047e921fe50263915a565252a802ed.zip
* gpgv.c (tty_fprintf): New stub.
* card-util.c (card_status): Create asecret key stub on the fly and print more information about a card key. * import.c (pub_to_sec_keyblock, auto_create_card_key_stub): New. * getkey.c (get_seckeyblock_byfprint): New. * keylist.c (print_card_key_info): New.
Diffstat (limited to '')
-rw-r--r--g10/getkey.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/g10/getkey.c b/g10/getkey.c
index 9cc0cbb7d..824c9bb7a 100644
--- a/g10/getkey.c
+++ b/g10/getkey.c
@@ -1,6 +1,6 @@
/* getkey.c - Get a key from the database
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003,
- * 2004 Free Software Foundation, Inc.
+ * 2004, 2005 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -1139,13 +1139,41 @@ get_seckey_byfprint( PKT_secret_key *sk,
if (!rc && sk )
sk_from_block ( &ctx, sk, kb );
release_kbnode ( kb );
- get_pubkey_end( &ctx );
+ get_seckey_end( &ctx );
}
else
rc = G10ERR_GENERAL; /* Oops */
return rc;
}
+
+/* Search for a secret key with the given fingerprint and return the
+ complete keyblock which may have more than only this key. */
+int
+get_seckeyblock_byfprint (KBNODE *ret_keyblock, const byte *fprint,
+ size_t fprint_len )
+{
+ int rc;
+ struct getkey_ctx_s ctx;
+
+ if (fprint_len != 20 && fprint_len == 16)
+ return G10ERR_GENERAL; /* Oops */
+
+ memset (&ctx, 0, sizeof ctx);
+ ctx.not_allocated = 1;
+ ctx.kr_handle = keydb_new (1);
+ ctx.nitems = 1;
+ ctx.items[0].mode = (fprint_len==16
+ ? KEYDB_SEARCH_MODE_FPR16
+ : KEYDB_SEARCH_MODE_FPR20);
+ memcpy (ctx.items[0].u.fpr, fprint, fprint_len);
+ rc = lookup (&ctx, ret_keyblock, 1);
+ get_seckey_end (&ctx);
+
+ return rc;
+}
+
+
/************************************************
************* Merging stuff ********************