aboutsummaryrefslogtreecommitdiffstats
path: root/common/userids.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/userids.c')
-rw-r--r--common/userids.c45
1 files changed, 38 insertions, 7 deletions
diff --git a/common/userids.c b/common/userids.c
index 01f2cd84b..41cf2876c 100644
--- a/common/userids.c
+++ b/common/userids.c
@@ -226,14 +226,15 @@ classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc, int openpgp_hack)
goto out;
}
}
- if (i != 32 && i != 40)
+ if (i != 32 && i != 40 && i != 64)
{
rc = gpg_error (GPG_ERR_INV_USER_ID); /* Invalid length of fpr. */
goto out;
}
for (i=0,si=s; si < se; i++, si +=2)
desc->u.fpr[i] = hextobyte(si);
- for (; i < 20; i++)
+ desc->fprlen = i;
+ for (; i < 32; i++)
desc->u.fpr[i]= 0;
mode = KEYDB_SEARCH_MODE_FPR;
}
@@ -326,6 +327,8 @@ classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc, int openpgp_hack)
}
desc->u.fpr[i] = c;
}
+ for (; i < 32; i++)
+ desc->u.fpr[i]= 0;
mode = KEYDB_SEARCH_MODE_FPR16;
}
else if ((hexlength == 40
@@ -333,7 +336,7 @@ classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc, int openpgp_hack)
|| (s[hexlength] == '!' && s[hexlength + 1] == 0)))
|| (!hexprefix && hexlength == 41 && *s == '0'))
{
- /* SHA1/RMD160 fingerprint. */
+ /* SHA1 fingerprint. */
int i;
if (hexlength == 41)
s++;
@@ -347,8 +350,31 @@ classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc, int openpgp_hack)
}
desc->u.fpr[i] = c;
}
+ for (; i < 32; i++)
+ desc->u.fpr[i]= 0;
mode = KEYDB_SEARCH_MODE_FPR20;
}
+ else if ((hexlength == 64
+ && (s[hexlength] == 0
+ || (s[hexlength] == '!' && s[hexlength + 1] == 0)))
+ || (!hexprefix && hexlength == 65 && *s == '0'))
+ {
+ /* SHA256 fingerprint. */
+ int i;
+ if (hexlength == 65)
+ s++;
+ for (i=0; i < 32; i++, s+=2)
+ {
+ int c = hextobyte(s);
+ if (c == -1)
+ {
+ rc = gpg_error (GPG_ERR_INV_USER_ID);
+ goto out;
+ }
+ desc->u.fpr[i] = c;
+ }
+ mode = KEYDB_SEARCH_MODE_FPR32;
+ }
else if (!hexprefix)
{
/* The fingerprint in an X.509 listing is often delimited by
@@ -368,14 +394,17 @@ classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc, int openpgp_hack)
}
if (i == 20)
mode = KEYDB_SEARCH_MODE_FPR20;
+ for (; i < 32; i++)
+ desc->u.fpr[i]= 0;
}
if (!mode)
{
/* Still not found. Now check for a space separated
- OpenPGP v4 fingerprint like:
- 8061 5870 F5BA D690 3336 86D0 F2AD 85AC 1E42 B367
- or
- 8061 5870 F5BA D690 3336 86D0 F2AD 85AC 1E42 B367
+ * OpenPGP v4 fingerprint like:
+ * 8061 5870 F5BA D690 3336 86D0 F2AD 85AC 1E42 B367
+ * or
+ * 8061 5870 F5BA D690 3336 86D0 F2AD 85AC 1E42 B367
+ * FIXME: Support OpenPGP v5 fingerprint
*/
hexlength = strspn (s, " 0123456789abcdefABCDEF");
if (s[hexlength] && s[hexlength] != ' ')
@@ -410,6 +439,8 @@ classify_user_id (const char *name, KEYDB_SEARCH_DESC *desc, int openpgp_hack)
}
if (i == 20)
mode = KEYDB_SEARCH_MODE_FPR20;
+ for (; i < 32; i++)
+ desc->u.fpr[i]= 0;
}
}
if (!mode) /* Default to substring search. */