mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
* packet.h, build-packet.c (hash_public_key): Remove function ...
* keydb.h, keyid.c (hash_public_key, do_fingerprint_md): ... and make a new one here that shares code with the fingerprint calculations. This removes some duplicated functionality, and is also around 14% faster. (Every bit helps). * import.c (import_one): No longer need the Elgamal import warning. * getkey.c (get_pubkey_fast): This one is sort of obscure. get_pubkey_fast returns the primary key when requesting a subkey, so if a user has a key signed by a subkey (we don't do this, but used to), AND that key is not self-signed, AND the algorithm of the subkey in question is not present in GnuPG, AND the algorithm of the primary key that owns the subkey in question is present in GnuPG, then we will try and verify the subkey signature using the primary key algorithm and hit a BUG(). The fix is to not return a hit if the keyid is not the primary. All other users of get_pubkey_fast already expect a primary only.
This commit is contained in:
parent
888a6c2980
commit
db5ab5e730
7 changed files with 108 additions and 143 deletions
17
g10/getkey.c
17
g10/getkey.c
|
@ -374,13 +374,15 @@ get_pubkey( PKT_public_key *pk, u32 *keyid )
|
|||
|
||||
/* Get a public key and store it into the allocated pk. This function
|
||||
differs from get_pubkey() in that it does not do a check of the key
|
||||
to avoid recursion. It should be used only in very certain cases. */
|
||||
to avoid recursion. It should be used only in very certain cases.
|
||||
It will only retrieve primary keys. */
|
||||
int
|
||||
get_pubkey_fast (PKT_public_key *pk, u32 *keyid)
|
||||
{
|
||||
int rc = 0;
|
||||
KEYDB_HANDLE hd;
|
||||
KBNODE keyblock;
|
||||
u32 pkid[2];
|
||||
|
||||
assert (pk);
|
||||
#if MAX_PK_CACHE_ENTRIES
|
||||
|
@ -413,20 +415,25 @@ get_pubkey_fast (PKT_public_key *pk, u32 *keyid)
|
|||
log_error ("keydb_get_keyblock failed: %s\n", g10_errstr(rc));
|
||||
return G10ERR_NO_PUBKEY;
|
||||
}
|
||||
|
||||
|
||||
assert ( keyblock->pkt->pkttype == PKT_PUBLIC_KEY
|
||||
|| keyblock->pkt->pkttype == PKT_PUBLIC_SUBKEY );
|
||||
copy_public_key (pk, keyblock->pkt->pkt.public_key );
|
||||
|
||||
keyid_from_pk(keyblock->pkt->pkt.public_key,pkid);
|
||||
if(keyid[0]==pkid[0] && keyid[1]==pkid[1])
|
||||
copy_public_key (pk, keyblock->pkt->pkt.public_key );
|
||||
else
|
||||
rc=G10ERR_NO_PUBKEY;
|
||||
|
||||
release_kbnode (keyblock);
|
||||
|
||||
/* Not caching key here since it won't have all of the fields
|
||||
properly set. */
|
||||
|
||||
return 0;
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
KBNODE
|
||||
get_pubkeyblock( u32 *keyid )
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue