1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

kbx: Change X.509 S/N search definition.

* kbx/keybox-search-desc.h (struct keydb_search_desc): Do not overload
SNLLEN with a hex flag.  Add SNHEX.
* kbx/keybox-search.c (keybox_search): Adjust.
* common/userids.c (classify_user_id): Adjust.
* sm/keydb.c (keydb_search_desc_dump): Adjust.
* g10/keydb.c (keydb_search_desc_dump): Adjust.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2020-09-08 10:05:08 +02:00
parent 2bc1ec2944
commit adec6a84f6
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
5 changed files with 15 additions and 21 deletions

View File

@ -192,7 +192,8 @@ classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc, int openpgp_hack)
}
}
desc->sn = (const unsigned char*)s;
desc->snlen = -1;
desc->snlen = si - s;
desc->snhex = 1;
if (!*si)
mode = KEYDB_SEARCH_MODE_SN;
else

View File

@ -487,15 +487,11 @@ keydb_search_desc_dump (struct keydb_search_desc *desc)
case KEYDB_SEARCH_MODE_ISSUER:
return xasprintf ("ISSUER: '%s'", desc->u.name);
case KEYDB_SEARCH_MODE_ISSUER_SN:
return xasprintf ("ISSUER_SN: '%*s'",
(int) (desc->snlen == -1
? strlen (desc->sn) : desc->snlen),
desc->sn);
return xasprintf ("ISSUER_SN: '#%.*s/%s'",
(int)desc->snlen,desc->sn, desc->u.name);
case KEYDB_SEARCH_MODE_SN:
return xasprintf ("SN: '%*s'",
(int) (desc->snlen == -1
? strlen (desc->sn) : desc->snlen),
desc->sn);
return xasprintf ("SN: '%.*s'",
(int)desc->snlen, desc->sn);
case KEYDB_SEARCH_MODE_SUBJECT:
return xasprintf ("SUBJECT: '%s'", desc->u.name);
case KEYDB_SEARCH_MODE_KEYGRIP:

View File

@ -75,7 +75,7 @@ struct keydb_search_desc
int (*skipfnc)(void *, u32 *, int);
void *skipfncvalue;
const unsigned char *sn;
int snlen; /* -1 := sn is a hex string */
unsigned short snlen;
union {
const char *name;
unsigned char fpr[32];
@ -83,6 +83,7 @@ struct keydb_search_desc
unsigned char grip[KEYGRIP_LEN];
unsigned char ubid[UBID_LEN];
} u;
byte snhex; /* SN above is a hexstring and not binary. */
byte fprlen; /* Only used with KEYDB_SEARCH_MODE_FPR. */
int exact; /* Use exactly this key ('!' suffix in gpg). */
};

View File

@ -982,7 +982,7 @@ keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc,
}
if (desc[n].skipfnc)
any_skip = 1;
if (desc[n].snlen == -1 && !sn_array)
if (desc[n].snhex && !sn_array)
{
sn_array = xtrycalloc (ndesc, sizeof *sn_array);
if (!sn_array)
@ -1042,12 +1042,12 @@ keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc,
{
if (!desc[n].sn)
;
else if (desc[n].snlen == -1)
else if (desc[n].snhex)
{
unsigned char *sn;
s = desc[n].sn;
for (i=0; *s && *s != '/'; s++, i++)
for (i=0; *s && *s != '/' && i < desc[n].snlen; s++, i++)
;
odd = (i & 1);
snlen = (i+1)/2;

View File

@ -1385,15 +1385,11 @@ keydb_search_desc_dump (struct keydb_search_desc *desc)
case KEYDB_SEARCH_MODE_ISSUER:
return xasprintf ("ISSUER: '%s'", desc->u.name);
case KEYDB_SEARCH_MODE_ISSUER_SN:
return xasprintf ("ISSUER_SN: '%*s'",
(int) (desc->snlen == -1
? strlen (desc->sn) : desc->snlen),
desc->sn);
return xasprintf ("ISSUER_SN: '#%.*s/%s'",
(int)desc->snlen,desc->sn, desc->u.name);
case KEYDB_SEARCH_MODE_SN:
return xasprintf ("SN: '%*s'",
(int) (desc->snlen == -1
? strlen (desc->sn) : desc->snlen),
desc->sn);
return xasprintf ("SN: '%.*s'",
(int)desc->snlen, desc->sn);
case KEYDB_SEARCH_MODE_SUBJECT:
return xasprintf ("SUBJECT: '%s'", desc->u.name);
case KEYDB_SEARCH_MODE_KEYGRIP: