aboutsummaryrefslogtreecommitdiffstats
path: root/g10/keyring.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2019-03-14 07:54:59 +0000
committerWerner Koch <[email protected]>2019-03-14 10:26:54 +0000
commitf40e9d6a528521d12795e1a6cc15c849b216be92 (patch)
treebebe6f71b5d00e8dda7d67dae3b3f4e27e12a815 /g10/keyring.c
parentgpg: Implemented latest rfc4880bis version 5 packet hashing. (diff)
downloadgnupg-f40e9d6a528521d12795e1a6cc15c849b216be92.tar.gz
gnupg-f40e9d6a528521d12795e1a6cc15c849b216be92.zip
kbx: Add support for 32 byte fingerprints.
* common/userids.c (classify_user_id): Support 32 byte fingerprints. * kbx/keybox-search-desc.h (KEYDB_SEARCH_MODE_FPR32): New. (struct keydb_search_desc): Add field fprlen. * kbx/keybox-defs.h (struct _keybox_openpgp_key_info): Add field version and increase size of fpr to 32. * kbx/keybox-blob.c: Define new version 2 for PGP and X509 blobs. (struct keyboxblob_key): Add field fprlen and increase size of fpr. (pgp_create_key_part_single): Allow larger fingerprints. (create_blob_header): Implement blob version 2 and add arg want_fpr32. (_keybox_create_openpgp_blob): Detect the need for blob version 2. * kbx/keybox-search.c (blob_get_first_keyid): Support 32 byte fingerprints. (blob_cmp_fpr): Ditto. (blob_cmp_fpr_part): Ditto. (has_fingerprint): Add arg fprlen and pass on. (keybox_search): Support KEYDB_SEARCH_MODE_FPR32 and adjust for changed has_fingerprint. * kbx/keybox-openpgp.c (parse_key): Support version 5 keys. * kbx/keybox-dump.c (_keybox_dump_blob): Support blob version 2. * g10/delkey.c (do_delete_key): Support KEYDB_SEARCH_MODE_FPR32. * g10/export.c (exact_subkey_match_p): Ditto. * g10/gpg.c (main): Ditto. * g10/getkey.c (get_pubkey_byfprint): Adjust for changed KEYDB_SEARCH_MODE_FPR. * g10/keydb.c (keydb_search_desc_dump): Support KEYDB_SEARCH_MODE_FPR32 and adjust for changed KEYDB_SEARCH_MODE_FPR. (keydb_search): Add new arg fprlen and change all callers. * g10/keyedit.c (find_by_primary_fpr): Ditto. * g10/keyid.c (keystr_from_desc): Ditto. * g10/keyring.c (keyring_search): Ditto. * g10/keyserver.c (print_keyrec): Ditto. (parse_keyrec): Ditto. (keyserver_export): Ditto. (keyserver_retrieval_screener): Ditto. (keyserver_import): Ditto. (keyserver_import_fprint): Ditto. (keyidlist): Ditto. (keyserver_get_chunk): Ditto. * g10/keydb.c (keydb_search): Add new arg fprlen and change all callers. * sm/keydb.c (keydb_search_fpr): Adjust for changed KEYDB_SEARCH_MODE_FPR. -- This prepares the support for OpenPGP v5 keys. The new version 2 blob format is needed for the longer fingerprints and we also use this opportunity to prepare for storing the keygrip in the blob for faster lookup by keygrip. Right now this is not yet functional. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'g10/keyring.c')
-rw-r--r--g10/keyring.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/g10/keyring.c b/g10/keyring.c
index 25ef50747..bc1d06c09 100644
--- a/g10/keyring.c
+++ b/g10/keyring.c
@@ -997,6 +997,7 @@ keyring_search (KEYRING_HANDLE hd, KEYDB_SEARCH_DESC *desc,
break;
case KEYDB_SEARCH_MODE_FPR16:
case KEYDB_SEARCH_MODE_FPR20:
+ case KEYDB_SEARCH_MODE_FPR32:
case KEYDB_SEARCH_MODE_FPR:
need_fpr = 1;
break;
@@ -1134,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);
@@ -1185,10 +1187,18 @@ keyring_search (KEYRING_HANDLE hd, KEYDB_SEARCH_DESC *desc,
goto found;
break;
case KEYDB_SEARCH_MODE_FPR20:
- case KEYDB_SEARCH_MODE_FPR:
if (pk && !memcmp (desc[n].u.fpr, afp, 20))
goto found;
break;
+ case KEYDB_SEARCH_MODE_FPR32:
+ if (pk && !memcmp (desc[n].u.fpr, afp, 32))
+ goto found;
+ break;
+ case KEYDB_SEARCH_MODE_FPR:
+ 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:
if (pk)
goto found;