mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
kbx: Unify the fingerprint search modes.
* kbx/keybox-search-desc.h (KEYDB_SEARCH_MODE_FPR16) (KEYDB_SEARCH_MODE_FPR20, KEYDB_SEARCH_MODE_FPR32): Remove. Switch all users to KEYDB_SEARCH_MODE_FPR along with the fprlen value. -- These search modes were added over time and there has until recently be no incentive to remove the cruft. With the change for v5 keys I finally went over all places and allowed the generic fingerprint mode along with a given length of the fingerprint at all places. Consequently the other modes can now be removed. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
caf4b3fc16
commit
bdda31a26b
@ -327,9 +327,10 @@ classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc, int openpgp_hack)
|
||||
}
|
||||
desc->u.fpr[i] = c;
|
||||
}
|
||||
desc->fprlen = 16;
|
||||
for (; i < 32; i++)
|
||||
desc->u.fpr[i]= 0;
|
||||
mode = KEYDB_SEARCH_MODE_FPR16;
|
||||
mode = KEYDB_SEARCH_MODE_FPR;
|
||||
}
|
||||
else if ((hexlength == 40
|
||||
&& (s[hexlength] == 0
|
||||
@ -350,9 +351,10 @@ classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc, int openpgp_hack)
|
||||
}
|
||||
desc->u.fpr[i] = c;
|
||||
}
|
||||
desc->fprlen = 20;
|
||||
for (; i < 32; i++)
|
||||
desc->u.fpr[i]= 0;
|
||||
mode = KEYDB_SEARCH_MODE_FPR20;
|
||||
mode = KEYDB_SEARCH_MODE_FPR;
|
||||
}
|
||||
else if ((hexlength == 64
|
||||
&& (s[hexlength] == 0
|
||||
@ -373,7 +375,8 @@ classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc, int openpgp_hack)
|
||||
}
|
||||
desc->u.fpr[i] = c;
|
||||
}
|
||||
mode = KEYDB_SEARCH_MODE_FPR32;
|
||||
desc->fprlen = 32;
|
||||
mode = KEYDB_SEARCH_MODE_FPR;
|
||||
}
|
||||
else if (!hexprefix)
|
||||
{
|
||||
@ -393,7 +396,10 @@ classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc, int openpgp_hack)
|
||||
desc->u.fpr[i] = c;
|
||||
}
|
||||
if (i == 20)
|
||||
mode = KEYDB_SEARCH_MODE_FPR20;
|
||||
{
|
||||
desc->fprlen = 20;
|
||||
mode = KEYDB_SEARCH_MODE_FPR;
|
||||
}
|
||||
for (; i < 32; i++)
|
||||
desc->u.fpr[i]= 0;
|
||||
}
|
||||
@ -438,7 +444,10 @@ classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc, int openpgp_hack)
|
||||
s += 2;
|
||||
}
|
||||
if (i == 20)
|
||||
mode = KEYDB_SEARCH_MODE_FPR20;
|
||||
{
|
||||
desc->fprlen = 20;
|
||||
mode = KEYDB_SEARCH_MODE_FPR;
|
||||
}
|
||||
for (; i < 32; i++)
|
||||
desc->u.fpr[i]= 0;
|
||||
}
|
||||
|
@ -1437,7 +1437,7 @@ ks_hkp_search (ctrl_t ctrl, parsed_uri_t uri, const char *pattern,
|
||||
{
|
||||
gpg_error_t err;
|
||||
KEYDB_SEARCH_DESC desc;
|
||||
char fprbuf[2+40+1];
|
||||
char fprbuf[2+64+1];
|
||||
char *hostport = NULL;
|
||||
char *request = NULL;
|
||||
estream_t fp = NULL;
|
||||
@ -1456,6 +1456,7 @@ ks_hkp_search (ctrl_t ctrl, parsed_uri_t uri, const char *pattern,
|
||||
err = classify_user_id (pattern, &desc, 1);
|
||||
if (err)
|
||||
return err;
|
||||
log_assert (desc.fprlen <= 64);
|
||||
switch (desc.mode)
|
||||
{
|
||||
case KEYDB_SEARCH_MODE_EXACT:
|
||||
@ -1473,17 +1474,10 @@ ks_hkp_search (ctrl_t ctrl, parsed_uri_t uri, const char *pattern,
|
||||
(ulong)desc.u.kid[0], (ulong)desc.u.kid[1]);
|
||||
pattern = fprbuf;
|
||||
break;
|
||||
case KEYDB_SEARCH_MODE_FPR16:
|
||||
fprbuf[0] = '0';
|
||||
fprbuf[1] = 'x';
|
||||
bin2hex (desc.u.fpr, 16, fprbuf+2);
|
||||
pattern = fprbuf;
|
||||
break;
|
||||
case KEYDB_SEARCH_MODE_FPR20:
|
||||
case KEYDB_SEARCH_MODE_FPR:
|
||||
fprbuf[0] = '0';
|
||||
fprbuf[1] = 'x';
|
||||
bin2hex (desc.u.fpr, 20, fprbuf+2);
|
||||
bin2hex (desc.u.fpr, desc.fprlen, fprbuf+2);
|
||||
pattern = fprbuf;
|
||||
break;
|
||||
default:
|
||||
@ -1586,7 +1580,7 @@ ks_hkp_get (ctrl_t ctrl, parsed_uri_t uri, const char *keyspec, estream_t *r_fp)
|
||||
{
|
||||
gpg_error_t err;
|
||||
KEYDB_SEARCH_DESC desc;
|
||||
char kidbuf[2+40+1];
|
||||
char kidbuf[2+64+1];
|
||||
const char *exactname = NULL;
|
||||
char *searchkey = NULL;
|
||||
char *hostport = NULL;
|
||||
@ -1607,6 +1601,7 @@ ks_hkp_get (ctrl_t ctrl, parsed_uri_t uri, const char *keyspec, estream_t *r_fp)
|
||||
err = classify_user_id (keyspec, &desc, 1);
|
||||
if (err)
|
||||
return err;
|
||||
log_assert (desc.fprlen <= 64);
|
||||
switch (desc.mode)
|
||||
{
|
||||
case KEYDB_SEARCH_MODE_SHORT_KID:
|
||||
@ -1616,21 +1611,21 @@ ks_hkp_get (ctrl_t ctrl, parsed_uri_t uri, const char *keyspec, estream_t *r_fp)
|
||||
snprintf (kidbuf, sizeof kidbuf, "0x%08lX%08lX",
|
||||
(ulong)desc.u.kid[0], (ulong)desc.u.kid[1]);
|
||||
break;
|
||||
case KEYDB_SEARCH_MODE_FPR20:
|
||||
case KEYDB_SEARCH_MODE_FPR:
|
||||
/* This is a v4 fingerprint. */
|
||||
if (desc.fprlen < 20)
|
||||
{
|
||||
log_error ("HKP keyservers do not support v3 fingerprints\n");
|
||||
return gpg_error (GPG_ERR_INV_USER_ID);
|
||||
}
|
||||
kidbuf[0] = '0';
|
||||
kidbuf[1] = 'x';
|
||||
bin2hex (desc.u.fpr, 20, kidbuf+2);
|
||||
bin2hex (desc.u.fpr, desc.fprlen, kidbuf+2);
|
||||
break;
|
||||
|
||||
case KEYDB_SEARCH_MODE_EXACT:
|
||||
exactname = desc.u.name;
|
||||
break;
|
||||
|
||||
case KEYDB_SEARCH_MODE_FPR16:
|
||||
log_error ("HKP keyservers do not support v3 fingerprints\n");
|
||||
/* fall through */
|
||||
default:
|
||||
return gpg_error (GPG_ERR_INV_USER_ID);
|
||||
}
|
||||
|
@ -376,8 +376,6 @@ keyspec_to_ldap_filter (const char *keyspec, char **filter, int only_exact)
|
||||
(ulong) desc.u.kid[0], (ulong) desc.u.kid[1]);
|
||||
break;
|
||||
|
||||
case KEYDB_SEARCH_MODE_FPR16:
|
||||
case KEYDB_SEARCH_MODE_FPR20:
|
||||
case KEYDB_SEARCH_MODE_FPR:
|
||||
case KEYDB_SEARCH_MODE_ISSUER:
|
||||
case KEYDB_SEARCH_MODE_ISSUER_SN:
|
||||
|
@ -69,10 +69,7 @@ do_delete_key (ctrl_t ctrl, const char *username, int secret, int force,
|
||||
|
||||
/* Search the userid. */
|
||||
err = classify_user_id (username, &desc, 1);
|
||||
exactmatch = (desc.mode == KEYDB_SEARCH_MODE_FPR
|
||||
|| desc.mode == KEYDB_SEARCH_MODE_FPR16
|
||||
|| desc.mode == KEYDB_SEARCH_MODE_FPR20
|
||||
|| desc.mode == KEYDB_SEARCH_MODE_FPR32);
|
||||
exactmatch = (desc.mode == KEYDB_SEARCH_MODE_FPR);
|
||||
if (!err)
|
||||
err = keydb_search (hd, &desc, 1, NULL);
|
||||
if (err)
|
||||
|
18
g10/export.c
18
g10/export.c
@ -451,9 +451,6 @@ exact_subkey_match_p (KEYDB_SEARCH_DESC *desc, KBNODE node)
|
||||
keyid_from_pk (node->pkt->pkt.public_key, kid);
|
||||
break;
|
||||
|
||||
case KEYDB_SEARCH_MODE_FPR16:
|
||||
case KEYDB_SEARCH_MODE_FPR20:
|
||||
case KEYDB_SEARCH_MODE_FPR32:
|
||||
case KEYDB_SEARCH_MODE_FPR:
|
||||
fingerprint_from_pk (node->pkt->pkt.public_key, fpr, &fprlen);
|
||||
break;
|
||||
@ -474,21 +471,6 @@ exact_subkey_match_p (KEYDB_SEARCH_DESC *desc, KBNODE node)
|
||||
result = 1;
|
||||
break;
|
||||
|
||||
case KEYDB_SEARCH_MODE_FPR16:
|
||||
if (fprlen == 16 && !memcmp (desc->u.fpr, fpr, 16))
|
||||
result = 1;
|
||||
break;
|
||||
|
||||
case KEYDB_SEARCH_MODE_FPR20:
|
||||
if (fprlen == 20 && !memcmp (desc->u.fpr, fpr, 20))
|
||||
result = 1;
|
||||
break;
|
||||
|
||||
case KEYDB_SEARCH_MODE_FPR32:
|
||||
if (fprlen == 32 && !memcmp (desc->u.fpr, fpr, 32))
|
||||
result = 1;
|
||||
break;
|
||||
|
||||
case KEYDB_SEARCH_MODE_FPR:
|
||||
if (fprlen == desc->fprlen && !memcmp (desc->u.fpr, fpr, desc->fprlen))
|
||||
result = 1;
|
||||
|
@ -897,9 +897,6 @@ key_byname (ctrl_t ctrl, GETKEY_CTX *retctx, strlist_t namelist,
|
||||
if (!include_unusable
|
||||
&& ctx->items[n].mode != KEYDB_SEARCH_MODE_SHORT_KID
|
||||
&& ctx->items[n].mode != KEYDB_SEARCH_MODE_LONG_KID
|
||||
&& ctx->items[n].mode != KEYDB_SEARCH_MODE_FPR16
|
||||
&& ctx->items[n].mode != KEYDB_SEARCH_MODE_FPR20
|
||||
&& ctx->items[n].mode != KEYDB_SEARCH_MODE_FPR32
|
||||
&& ctx->items[n].mode != KEYDB_SEARCH_MODE_FPR)
|
||||
{
|
||||
ctx->items[n].skipfnc = skip_unusable;
|
||||
|
@ -5082,9 +5082,6 @@ main (int argc, char **argv)
|
||||
|
||||
if (! (desc.mode == KEYDB_SEARCH_MODE_SHORT_KID
|
||||
|| desc.mode == KEYDB_SEARCH_MODE_LONG_KID
|
||||
|| desc.mode == KEYDB_SEARCH_MODE_FPR16
|
||||
|| desc.mode == KEYDB_SEARCH_MODE_FPR20
|
||||
|| desc.mode == KEYDB_SEARCH_MODE_FPR32
|
||||
|| desc.mode == KEYDB_SEARCH_MODE_FPR
|
||||
|| desc.mode == KEYDB_SEARCH_MODE_KEYGRIP))
|
||||
{
|
||||
|
29
g10/keydb.c
29
g10/keydb.c
@ -559,21 +559,9 @@ keydb_search_desc_dump (struct keydb_search_desc *desc)
|
||||
case KEYDB_SEARCH_MODE_LONG_KID:
|
||||
return xasprintf ("LONG_KID: '%s'",
|
||||
format_keyid (desc->u.kid, KF_LONG, b, sizeof (b)));
|
||||
case KEYDB_SEARCH_MODE_FPR16:
|
||||
bin2hex (desc->u.fpr, 16, fpr);
|
||||
return xasprintf ("FPR16: '%s'",
|
||||
format_hexfingerprint (fpr, b, sizeof (b)));
|
||||
case KEYDB_SEARCH_MODE_FPR20:
|
||||
bin2hex (desc->u.fpr, 20, fpr);
|
||||
return xasprintf ("FPR20: '%s'",
|
||||
format_hexfingerprint (fpr, b, sizeof (b)));
|
||||
case KEYDB_SEARCH_MODE_FPR32:
|
||||
bin2hex (desc->u.fpr, 20, fpr);
|
||||
return xasprintf ("FPR32: '%s'",
|
||||
format_hexfingerprint (fpr, b, sizeof (b)));
|
||||
case KEYDB_SEARCH_MODE_FPR:
|
||||
bin2hex (desc->u.fpr, desc->fprlen, fpr);
|
||||
return xasprintf ("FPR: '%s'",
|
||||
return xasprintf ("FPR%02d: '%s'", desc->fprlen,
|
||||
format_hexfingerprint (fpr, b, sizeof (b)));
|
||||
case KEYDB_SEARCH_MODE_ISSUER:
|
||||
return xasprintf ("ISSUER: '%s'", desc->u.name);
|
||||
@ -1534,10 +1522,11 @@ keydb_update_keyblock (ctrl_t ctrl, KEYDB_HANDLE hd, kbnode_t kb)
|
||||
|
||||
memset (&desc, 0, sizeof (desc));
|
||||
fingerprint_from_pk (pk, desc.u.fpr, &len);
|
||||
if (len == 20)
|
||||
desc.mode = KEYDB_SEARCH_MODE_FPR20;
|
||||
else if (len == 32)
|
||||
desc.mode = KEYDB_SEARCH_MODE_FPR32;
|
||||
if (len == 20 || len == 32)
|
||||
{
|
||||
desc.mode = KEYDB_SEARCH_MODE_FPR;
|
||||
desc.fprlen = len;
|
||||
}
|
||||
else
|
||||
log_bug ("%s: Unsupported key length: %zu\n", __func__, len);
|
||||
|
||||
@ -1910,11 +1899,7 @@ keydb_search (KEYDB_HANDLE hd, KEYDB_SEARCH_DESC *desc,
|
||||
/* NB: If one of the exact search modes below is used in a loop to
|
||||
walk over all keys (with the same fingerprint) the caching must
|
||||
have been disabled for the handle. */
|
||||
if (desc[0].mode == KEYDB_SEARCH_MODE_FPR20)
|
||||
fprlen = 20;
|
||||
else if (desc[0].mode == KEYDB_SEARCH_MODE_FPR32)
|
||||
fprlen = 32;
|
||||
else if (desc[0].mode == KEYDB_SEARCH_MODE_FPR)
|
||||
if (desc[0].mode == KEYDB_SEARCH_MODE_FPR)
|
||||
fprlen = desc[0].fprlen;
|
||||
else
|
||||
fprlen = 0;
|
||||
|
@ -2564,10 +2564,7 @@ find_by_primary_fpr (ctrl_t ctrl, const char *fpr,
|
||||
*r_kdbhd = NULL;
|
||||
|
||||
if (classify_user_id (fpr, &desc, 1)
|
||||
|| !(desc.mode == KEYDB_SEARCH_MODE_FPR
|
||||
|| desc.mode == KEYDB_SEARCH_MODE_FPR16
|
||||
|| desc.mode == KEYDB_SEARCH_MODE_FPR20
|
||||
|| desc.mode == KEYDB_SEARCH_MODE_FPR32))
|
||||
|| desc.mode != KEYDB_SEARCH_MODE_FPR)
|
||||
{
|
||||
log_error (_("\"%s\" is not a fingerprint\n"), fpr);
|
||||
err = gpg_error (GPG_ERR_INV_NAME);
|
||||
@ -2582,25 +2579,9 @@ find_by_primary_fpr (ctrl_t ctrl, const char *fpr,
|
||||
|
||||
/* Check that the primary fingerprint has been given. */
|
||||
fingerprint_from_pk (keyblock->pkt->pkt.public_key, fprbin, &fprlen);
|
||||
if (fprlen == 16 && desc.mode == KEYDB_SEARCH_MODE_FPR16
|
||||
&& !memcmp (fprbin, desc.u.fpr, 16))
|
||||
;
|
||||
else if (fprlen == 16 && desc.mode == KEYDB_SEARCH_MODE_FPR
|
||||
&& !memcmp (fprbin, desc.u.fpr, 16)
|
||||
&& !desc.u.fpr[16]
|
||||
&& !desc.u.fpr[17]
|
||||
&& !desc.u.fpr[18]
|
||||
&& !desc.u.fpr[19])
|
||||
;
|
||||
else if (fprlen == 20 && desc.mode == KEYDB_SEARCH_MODE_FPR20
|
||||
&& !memcmp (fprbin, desc.u.fpr, 20))
|
||||
;
|
||||
else if (fprlen == 32 && desc.mode == KEYDB_SEARCH_MODE_FPR32
|
||||
&& !memcmp (fprbin, desc.u.fpr, 32))
|
||||
;
|
||||
else if (desc.mode == KEYDB_SEARCH_MODE_FPR
|
||||
&& fprlen == desc.fprlen
|
||||
&& !memcmp (fprbin, desc.u.fpr, fprlen))
|
||||
if (desc.mode == KEYDB_SEARCH_MODE_FPR
|
||||
&& fprlen == desc.fprlen
|
||||
&& !memcmp (fprbin, desc.u.fpr, fprlen))
|
||||
;
|
||||
else
|
||||
{
|
||||
@ -2924,9 +2905,7 @@ keyedit_quick_set_expire (ctrl_t ctrl, const char *fpr, const char *expirestr,
|
||||
|
||||
/* Parse the fingerprint. */
|
||||
if (classify_user_id (subkeyfprs[idx], &desc, 1)
|
||||
|| !(desc.mode == KEYDB_SEARCH_MODE_FPR
|
||||
|| desc.mode == KEYDB_SEARCH_MODE_FPR20
|
||||
|| desc.mode == KEYDB_SEARCH_MODE_FPR32))
|
||||
|| desc.mode != KEYDB_SEARCH_MODE_FPR)
|
||||
{
|
||||
log_error (_("\"%s\" is not a proper fingerprint\n"),
|
||||
subkeyfprs[idx] );
|
||||
|
27
g10/keyid.c
27
g10/keyid.c
@ -493,24 +493,6 @@ keystr_from_desc(KEYDB_SEARCH_DESC *desc)
|
||||
case KEYDB_SEARCH_MODE_SHORT_KID:
|
||||
return keystr(desc->u.kid);
|
||||
|
||||
case KEYDB_SEARCH_MODE_FPR20:
|
||||
{
|
||||
u32 keyid[2];
|
||||
|
||||
keyid[0] = buf32_to_u32 (desc->u.fpr+12);
|
||||
keyid[1] = buf32_to_u32 (desc->u.fpr+16);
|
||||
return keystr(keyid);
|
||||
}
|
||||
|
||||
case KEYDB_SEARCH_MODE_FPR32:
|
||||
{
|
||||
u32 keyid[2];
|
||||
|
||||
keyid[0] = buf32_to_u32 (desc->u.fpr);
|
||||
keyid[1] = buf32_to_u32 (desc->u.fpr+4);
|
||||
return keystr(keyid);
|
||||
}
|
||||
|
||||
case KEYDB_SEARCH_MODE_FPR:
|
||||
{
|
||||
u32 keyid[2];
|
||||
@ -520,17 +502,18 @@ keystr_from_desc(KEYDB_SEARCH_DESC *desc)
|
||||
keyid[0] = buf32_to_u32 (desc->u.fpr);
|
||||
keyid[1] = buf32_to_u32 (desc->u.fpr+4);
|
||||
}
|
||||
else
|
||||
else if (desc->fprlen == 20)
|
||||
{
|
||||
keyid[0] = buf32_to_u32 (desc->u.fpr+12);
|
||||
keyid[1] = buf32_to_u32 (desc->u.fpr+16);
|
||||
}
|
||||
else if (desc->fprlen == 16)
|
||||
return "?v3 fpr?";
|
||||
else /* oops */
|
||||
return "?vx fpr?";
|
||||
return keystr(keyid);
|
||||
}
|
||||
|
||||
case KEYDB_SEARCH_MODE_FPR16:
|
||||
return "?v3 fpr?";
|
||||
|
||||
default:
|
||||
BUG();
|
||||
}
|
||||
|
@ -995,9 +995,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_FPR32:
|
||||
case KEYDB_SEARCH_MODE_FPR:
|
||||
need_fpr = 1;
|
||||
break;
|
||||
@ -1182,18 +1179,6 @@ keyring_search (KEYRING_HANDLE hd, KEYDB_SEARCH_DESC *desc,
|
||||
&& 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:
|
||||
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))
|
||||
|
@ -470,7 +470,6 @@ parse_preferred_keyserver(PKT_signature *sig)
|
||||
static void
|
||||
print_keyrec (ctrl_t ctrl, int number,struct keyrec *keyrec)
|
||||
{
|
||||
int i;
|
||||
|
||||
iobuf_writebyte(keyrec->uidbuf,0);
|
||||
iobuf_flush_temp(keyrec->uidbuf);
|
||||
@ -509,34 +508,6 @@ print_keyrec (ctrl_t ctrl, int number,struct keyrec *keyrec)
|
||||
es_printf ("key %s",keystr(keyrec->desc.u.kid));
|
||||
break;
|
||||
|
||||
/* If it gave us a PGP 2.x fingerprint, not much we can do
|
||||
beyond displaying it. */
|
||||
case KEYDB_SEARCH_MODE_FPR16:
|
||||
es_printf ("key ");
|
||||
for(i=0;i<16;i++)
|
||||
es_printf ("%02X",keyrec->desc.u.fpr[i]);
|
||||
break;
|
||||
|
||||
/* If we get a modern fingerprint, we have the most
|
||||
flexibility. */
|
||||
case KEYDB_SEARCH_MODE_FPR20:
|
||||
{
|
||||
u32 kid[2];
|
||||
keyid_from_fingerprint (ctrl, keyrec->desc.u.fpr,20,kid);
|
||||
es_printf("key %s",keystr(kid));
|
||||
}
|
||||
break;
|
||||
|
||||
/* If we get a modern fingerprint, we have the most
|
||||
flexibility. */
|
||||
case KEYDB_SEARCH_MODE_FPR32:
|
||||
{
|
||||
u32 kid[2];
|
||||
keyid_from_fingerprint (ctrl, keyrec->desc.u.fpr, 32, kid);
|
||||
es_printf("key %s",keystr(kid));
|
||||
}
|
||||
break;
|
||||
|
||||
case KEYDB_SEARCH_MODE_FPR:
|
||||
{
|
||||
u32 kid[2];
|
||||
@ -632,9 +603,6 @@ parse_keyrec(char *keystring)
|
||||
err = classify_user_id (tok, &work->desc, 1);
|
||||
if (err || (work->desc.mode != KEYDB_SEARCH_MODE_SHORT_KID
|
||||
&& work->desc.mode != KEYDB_SEARCH_MODE_LONG_KID
|
||||
&& work->desc.mode != KEYDB_SEARCH_MODE_FPR16
|
||||
&& work->desc.mode != KEYDB_SEARCH_MODE_FPR20
|
||||
&& work->desc.mode != KEYDB_SEARCH_MODE_FPR32
|
||||
&& work->desc.mode != KEYDB_SEARCH_MODE_FPR))
|
||||
{
|
||||
work->desc.mode=KEYDB_SEARCH_MODE_NONE;
|
||||
@ -1016,9 +984,6 @@ keyserver_export (ctrl_t ctrl, strlist_t users)
|
||||
err = classify_user_id (users->d, &desc, 1);
|
||||
if (err || (desc.mode != KEYDB_SEARCH_MODE_SHORT_KID
|
||||
&& desc.mode != KEYDB_SEARCH_MODE_LONG_KID
|
||||
&& desc.mode != KEYDB_SEARCH_MODE_FPR16
|
||||
&& desc.mode != KEYDB_SEARCH_MODE_FPR20
|
||||
&& desc.mode != KEYDB_SEARCH_MODE_FPR32
|
||||
&& desc.mode != KEYDB_SEARCH_MODE_FPR))
|
||||
{
|
||||
log_error(_("\"%s\" not a key ID: skipping\n"),users->d);
|
||||
@ -1088,26 +1053,11 @@ keyserver_retrieval_screener (kbnode_t keyblock, void *opaque)
|
||||
/* Compare requested and returned fingerprints if available. */
|
||||
for (n = 0; n < ndesc; n++)
|
||||
{
|
||||
if (desc[n].mode == KEYDB_SEARCH_MODE_FPR20)
|
||||
{
|
||||
if (fpr_len == 20 && !memcmp (fpr, desc[n].u.fpr, 20))
|
||||
return 0;
|
||||
}
|
||||
else if (desc[n].mode == KEYDB_SEARCH_MODE_FPR32)
|
||||
{
|
||||
if (fpr_len == 32 && !memcmp (fpr, desc[n].u.fpr, 32))
|
||||
return 0;
|
||||
}
|
||||
else if (desc[n].mode == KEYDB_SEARCH_MODE_FPR)
|
||||
if (desc[n].mode == KEYDB_SEARCH_MODE_FPR)
|
||||
{
|
||||
if (fpr_len == desc[n].fprlen && !memcmp (fpr, desc[n].u.fpr, 32))
|
||||
return 0;
|
||||
}
|
||||
else if (desc[n].mode == KEYDB_SEARCH_MODE_FPR16)
|
||||
{
|
||||
if (fpr_len == 16 && !memcmp (fpr, desc[n].u.fpr, 16))
|
||||
return 0;
|
||||
}
|
||||
else if (desc[n].mode == KEYDB_SEARCH_MODE_LONG_KID)
|
||||
{
|
||||
if (keyid[0] == desc[n].u.kid[0] && keyid[1] == desc[n].u.kid[1])
|
||||
@ -1143,9 +1093,6 @@ keyserver_import (ctrl_t ctrl, strlist_t users)
|
||||
err = classify_user_id (users->d, &desc[count], 1);
|
||||
if (err || (desc[count].mode != KEYDB_SEARCH_MODE_SHORT_KID
|
||||
&& desc[count].mode != KEYDB_SEARCH_MODE_LONG_KID
|
||||
&& desc[count].mode != KEYDB_SEARCH_MODE_FPR16
|
||||
&& desc[count].mode != KEYDB_SEARCH_MODE_FPR20
|
||||
&& desc[count].mode != KEYDB_SEARCH_MODE_FPR32
|
||||
&& desc[count].mode != KEYDB_SEARCH_MODE_FPR))
|
||||
{
|
||||
log_error (_("\"%s\" not a key ID: skipping\n"), users->d);
|
||||
@ -1202,12 +1149,8 @@ keyserver_import_fprint (ctrl_t ctrl, const byte *fprint,size_t fprint_len,
|
||||
|
||||
memset(&desc,0,sizeof(desc));
|
||||
|
||||
if(fprint_len==16)
|
||||
desc.mode=KEYDB_SEARCH_MODE_FPR16;
|
||||
else if(fprint_len==20)
|
||||
desc.mode=KEYDB_SEARCH_MODE_FPR20;
|
||||
else if(fprint_len==32)
|
||||
desc.mode=KEYDB_SEARCH_MODE_FPR32;
|
||||
if (fprint_len == 16 || fprint_len == 20 || fprint_len == 32)
|
||||
desc.mode = KEYDB_SEARCH_MODE_FPR;
|
||||
else
|
||||
return -1;
|
||||
|
||||
@ -1337,14 +1280,12 @@ keyidlist (ctrl_t ctrl, strlist_t users, KEYDB_SEARCH_DESC **klist,
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t dummy;
|
||||
size_t fprlen;
|
||||
|
||||
if (node->pkt->pkt.public_key->version == 4)
|
||||
(*klist)[*count].mode = KEYDB_SEARCH_MODE_FPR20;
|
||||
else
|
||||
(*klist)[*count].mode = KEYDB_SEARCH_MODE_FPR32;
|
||||
fingerprint_from_pk (node->pkt->pkt.public_key,
|
||||
(*klist)[*count].u.fpr,&dummy);
|
||||
(*klist)[*count].u.fpr, &fprlen);
|
||||
(*klist)[*count].mode = KEYDB_SEARCH_MODE_FPR;
|
||||
(*klist)[*count].fprlen = fprlen;
|
||||
}
|
||||
|
||||
/* This is a little hackish, using the skipfncvalue as a
|
||||
@ -1661,11 +1602,9 @@ keyserver_get_chunk (ctrl_t ctrl, KEYDB_SEARCH_DESC *desc, int ndesc,
|
||||
{
|
||||
int quiet = 0;
|
||||
|
||||
if (desc[idx].mode == KEYDB_SEARCH_MODE_FPR20
|
||||
|| desc[idx].mode == KEYDB_SEARCH_MODE_FPR32
|
||||
|| desc[idx].mode == KEYDB_SEARCH_MODE_FPR16)
|
||||
if (desc[idx].mode == KEYDB_SEARCH_MODE_FPR)
|
||||
{
|
||||
n = 1+2+2*32;
|
||||
n = 1+2+2*desc[idx].fprlen;
|
||||
if (idx && linelen + n > MAX_KS_GET_LINELEN)
|
||||
break; /* Declare end of this chunk. */
|
||||
linelen += n;
|
||||
@ -1676,13 +1615,9 @@ keyserver_get_chunk (ctrl_t ctrl, KEYDB_SEARCH_DESC *desc, int ndesc,
|
||||
else
|
||||
{
|
||||
strcpy (pattern[npat], "0x");
|
||||
bin2hex (desc[idx].u.fpr,
|
||||
desc[idx].mode == KEYDB_SEARCH_MODE_FPR32? 32 :
|
||||
desc[idx].mode == KEYDB_SEARCH_MODE_FPR20? 20 : 16,
|
||||
pattern[npat]+2);
|
||||
bin2hex (desc[idx].u.fpr, desc[idx].fprlen, pattern[npat]+2);
|
||||
npat++;
|
||||
if (desc[idx].mode == KEYDB_SEARCH_MODE_FPR20
|
||||
|| desc[idx].mode == KEYDB_SEARCH_MODE_FPR32)
|
||||
if (desc[idx].fprlen == 20 || desc[idx].fprlen == 32)
|
||||
npat_fpr++;
|
||||
}
|
||||
}
|
||||
|
@ -36,9 +36,6 @@ typedef enum {
|
||||
KEYDB_SEARCH_MODE_WORDS,
|
||||
KEYDB_SEARCH_MODE_SHORT_KID,
|
||||
KEYDB_SEARCH_MODE_LONG_KID,
|
||||
KEYDB_SEARCH_MODE_FPR16,
|
||||
KEYDB_SEARCH_MODE_FPR20,
|
||||
KEYDB_SEARCH_MODE_FPR32,
|
||||
KEYDB_SEARCH_MODE_FPR, /* (Length of fpr in .fprlen) */
|
||||
KEYDB_SEARCH_MODE_ISSUER,
|
||||
KEYDB_SEARCH_MODE_ISSUER_SN,
|
||||
|
@ -1083,18 +1083,6 @@ keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc,
|
||||
goto found;
|
||||
break;
|
||||
|
||||
case KEYDB_SEARCH_MODE_FPR20:
|
||||
pk_no = has_fingerprint (blob, desc[n].u.fpr, 20);
|
||||
if (pk_no)
|
||||
goto found;
|
||||
break;
|
||||
|
||||
case KEYDB_SEARCH_MODE_FPR32:
|
||||
pk_no = has_fingerprint (blob, desc[n].u.fpr, 32);
|
||||
if (pk_no)
|
||||
goto found;
|
||||
break;
|
||||
|
||||
case KEYDB_SEARCH_MODE_KEYGRIP:
|
||||
if (has_keygrip (blob, desc[n].u.grip))
|
||||
goto found;
|
||||
|
@ -64,8 +64,6 @@ delete_one (ctrl_t ctrl, const char *username)
|
||||
/* If the key is specified in a unique way, include ephemeral keys
|
||||
in the search. */
|
||||
if ( desc.mode == KEYDB_SEARCH_MODE_FPR
|
||||
|| desc.mode == KEYDB_SEARCH_MODE_FPR20
|
||||
|| desc.mode == KEYDB_SEARCH_MODE_FPR16
|
||||
|| desc.mode == KEYDB_SEARCH_MODE_KEYGRIP )
|
||||
{
|
||||
is_ephem = 1;
|
||||
|
@ -198,8 +198,6 @@ gpgsm_export (ctrl_t ctrl, strlist_t names, estream_t stream)
|
||||
{
|
||||
for (i=0; (i < ndesc
|
||||
&& (desc[i].mode == KEYDB_SEARCH_MODE_FPR
|
||||
|| desc[i].mode == KEYDB_SEARCH_MODE_FPR20
|
||||
|| desc[i].mode == KEYDB_SEARCH_MODE_FPR16
|
||||
|| desc[i].mode == KEYDB_SEARCH_MODE_KEYGRIP)); i++)
|
||||
;
|
||||
if (i == ndesc)
|
||||
|
@ -1477,8 +1477,6 @@ list_internal_keys (ctrl_t ctrl, strlist_t names, estream_t fp,
|
||||
|
||||
for (i=0; (i < ndesc
|
||||
&& (desc[i].mode == KEYDB_SEARCH_MODE_FPR
|
||||
|| desc[i].mode == KEYDB_SEARCH_MODE_FPR20
|
||||
|| desc[i].mode == KEYDB_SEARCH_MODE_FPR16
|
||||
|| desc[i].mode == KEYDB_SEARCH_MODE_KEYGRIP)); i++)
|
||||
;
|
||||
if (i == ndesc)
|
||||
|
@ -853,8 +853,7 @@ command_send (const char *fingerprint, const char *userid)
|
||||
time_t thistime;
|
||||
|
||||
if (classify_user_id (fingerprint, &desc, 1)
|
||||
|| !(desc.mode == KEYDB_SEARCH_MODE_FPR
|
||||
|| desc.mode == KEYDB_SEARCH_MODE_FPR20))
|
||||
|| desc.mode != KEYDB_SEARCH_MODE_FPR)
|
||||
{
|
||||
log_error (_("\"%s\" is not a fingerprint\n"), fingerprint);
|
||||
err = gpg_error (GPG_ERR_INV_NAME);
|
||||
|
@ -946,8 +946,7 @@ wks_cmd_install_key (const char *fname, const char *userid)
|
||||
}
|
||||
|
||||
if (!classify_user_id (fname, &desc, 1)
|
||||
&& (desc.mode == KEYDB_SEARCH_MODE_FPR
|
||||
|| desc.mode == KEYDB_SEARCH_MODE_FPR20))
|
||||
&& desc.mode == KEYDB_SEARCH_MODE_FPR)
|
||||
{
|
||||
/* FNAME looks like a fingerprint. Get the key from the
|
||||
* standard keyring. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user