summaryrefslogtreecommitdiffstats
path: root/g10/keyid.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>1998-07-21 14:53:38 +0200
committerWerner Koch <wk@gnupg.org>1998-07-21 14:53:38 +0200
commit1a80de41a5f5e753c427872f8ab6ee5a844ea761 (patch)
tree8d5312c6f56c54dc6092556b8569b16b22e4d8fe /g10/keyid.c
parentsync (diff)
downloadgnupg2-1a80de41a5f5e753c427872f8ab6ee5a844ea761.tar.xz
gnupg2-1a80de41a5f5e753c427872f8ab6ee5a844ea761.zip
changed trustdb design
Diffstat (limited to 'g10/keyid.c')
-rw-r--r--g10/keyid.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/g10/keyid.c b/g10/keyid.c
index 2e5c6aad6..de0319fe3 100644
--- a/g10/keyid.c
+++ b/g10/keyid.c
@@ -189,6 +189,43 @@ keyid_from_pk( PKT_public_key *pk, u32 *keyid )
}
+/****************
+ * Get the keyid from the fingerprint. This function is simple for most
+ * keys, but has to do a keylookup for old stayle keys.
+ */
+u32
+keyid_from_fingerprint( const byte *fprint, size_t fprint_len, u32 *keyid )
+{
+ u32 dummy_keyid[2];
+
+ if( !keyid )
+ keyid = dummy_keyid;
+
+ if( fprint_len != 20 ) {
+ /* This is special as we have to lookup the key first */
+ PKT_public_key pk;
+ int rc;
+
+ memset( &pk, 0, sizeof pk );
+ rc = get_pubkey_byfprint( &pk, fprint, fprint_len );
+ if( rc ) {
+ log_error("Oops: keyid_from_fingerprint: no pubkey\n");
+ keyid[0] = 0;
+ keyid[1] = 0;
+ }
+ else
+ keyid_from_pk( &pk, keyid );
+ }
+ else {
+ const byte *dp = fprint;
+ keyid[0] = dp[12] << 24 | dp[13] << 16 | dp[14] << 8 | dp[15] ;
+ keyid[1] = dp[16] << 24 | dp[17] << 16 | dp[18] << 8 | dp[19] ;
+ }
+
+ return keyid[1];
+}
+
+
u32
keyid_from_sig( PKT_signature *sig, u32 *keyid )
{