summaryrefslogtreecommitdiff
path: root/g10/keyring.c
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2022-09-16 07:45:15 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2022-09-16 07:45:15 +0900
commit028733bb89982a39cf1341937417c9d76f39b2ef (patch)
tree2caf8ab0f478b616b6cd7c79e7611c77187b699b /g10/keyring.c
parent1d9fa478efd45c53acf357cca67d974cf8e8f699 (diff)
downloadgpg2-028733bb89982a39cf1341937417c9d76f39b2ef.tar.gz
gpg2-028733bb89982a39cf1341937417c9d76f39b2ef.tar.bz2
gpg2-028733bb89982a39cf1341937417c9d76f39b2ef.zip
Imported Upstream version 2.3.0upstream/2.3.0
Diffstat (limited to 'g10/keyring.c')
-rw-r--r--g10/keyring.c33
1 files changed, 14 insertions, 19 deletions
diff --git a/g10/keyring.c b/g10/keyring.c
index 8c31ccc..e044cab 100644
--- a/g10/keyring.c
+++ b/g10/keyring.c
@@ -598,7 +598,7 @@ keyring_insert_keyblock (KEYRING_HANDLE hd, KBNODE kb)
/* Close this one otherwise we will lose the position for
* a next search. Fixme: it would be better to adjust the position
- * after the write opertions.
+ * after the write operations.
*/
iobuf_close (hd->current.iobuf);
hd->current.iobuf = NULL;
@@ -638,7 +638,7 @@ keyring_delete_keyblock (KEYRING_HANDLE hd)
/* close this one otherwise we will lose the position for
* a next search. Fixme: it would be better to adjust the position
- * after the write opertions.
+ * after the write operations.
*/
iobuf_close (hd->current.iobuf);
hd->current.iobuf = NULL;
@@ -998,8 +998,6 @@ keyring_search (KEYRING_HANDLE hd, KEYDB_SEARCH_DESC *desc,
case KEYDB_SEARCH_MODE_LONG_KID:
need_keyid = 1;
break;
- case KEYDB_SEARCH_MODE_FPR16:
- case KEYDB_SEARCH_MODE_FPR20:
case KEYDB_SEARCH_MODE_FPR:
need_fpr = 1;
break;
@@ -1137,11 +1135,12 @@ keyring_search (KEYRING_HANDLE hd, KEYDB_SEARCH_DESC *desc,
pk = pkt.pkt.public_key;
++pk_no;
- if (need_fpr) {
- fingerprint_from_pk (pk, afp, &an);
- while (an < 20) /* fill up to 20 bytes */
- afp[an++] = 0;
- }
+ if (need_fpr)
+ {
+ fingerprint_from_pk (pk, afp, &an);
+ while (an < 32) /* fill up to 32 bytes */
+ afp[an++] = 0;
+ }
if (need_keyid)
keyid_from_pk (pk, aki);
@@ -1175,21 +1174,19 @@ keyring_search (KEYRING_HANDLE hd, KEYDB_SEARCH_DESC *desc,
break;
case KEYDB_SEARCH_MODE_SHORT_KID:
- if (pk && desc[n].u.kid[1] == aki[1])
- goto found;
+ if (pk
+ && ((pk->fprlen == 32 && desc[n].u.kid[1] == aki[0])
+ || (pk->fprlen != 32 && desc[n].u.kid[1] == aki[1])))
+ goto found;
break;
case KEYDB_SEARCH_MODE_LONG_KID:
if (pk && desc[n].u.kid[0] == aki[0]
&& desc[n].u.kid[1] == aki[1])
goto found;
break;
- case KEYDB_SEARCH_MODE_FPR16:
- if (pk && !memcmp (desc[n].u.fpr, afp, 16))
- goto found;
- break;
- case KEYDB_SEARCH_MODE_FPR20:
case KEYDB_SEARCH_MODE_FPR:
- if (pk && !memcmp (desc[n].u.fpr, afp, 20))
+ if (pk && desc[n].fprlen >= 16 && desc[n].fprlen <= 32
+ && !memcmp (desc[n].u.fpr, afp, desc[n].fprlen))
goto found;
break;
case KEYDB_SEARCH_MODE_FIRST:
@@ -1479,8 +1476,6 @@ keyring_rebuild_cache (ctrl_t ctrl, void *token, int noisy)
{
if (gpg_err_code (rc) == GPG_ERR_LEGACY_KEY)
continue; /* Skip legacy keys. */
- if (gpg_err_code (rc) == GPG_ERR_UNKNOWN_VERSION)
- continue; /* Skip keys with unknown version. */
log_error ("keyring_get_keyblock failed: %s\n", gpg_strerror (rc));
goto leave;
}