diff options
Diffstat (limited to 'g10/getkey.c')
-rw-r--r-- | g10/getkey.c | 54 |
1 files changed, 47 insertions, 7 deletions
diff --git a/g10/getkey.c b/g10/getkey.c index 9cb5b9504..5440c29d7 100644 --- a/g10/getkey.c +++ b/g10/getkey.c @@ -738,14 +738,54 @@ classify_user_id( const char *name, KEYDB_SEARCH_DESC *desc ) } mode = KEYDB_SEARCH_MODE_FPR20; } - else { - if (hexprefix) /* This was a hex number with a prefix */ - return 0; /* and a wrong length */ + else if (!hexprefix) { + /* No hex indicator; 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 + */ + mode = 0; + hexlength = strspn (s, " 0123456789abcdefABCDEF"); + if (s[hexlength] && s[hexlength] != ' ') + hexlength = 0; /* Followed by non-space. */ + while (hexlength && s[hexlength-1] == ' ') + hexlength--; /* Trim trailing spaces. */ + if ((hexlength == 49 || hexlength == 50) + && (!s[hexlength] || s[hexlength] == ' ')) { + int i, c; + + for (i=0; i < 20; i++) { + if (i && !(i % 2)) { + if (*s != ' ') + break; + s++; + /* Skip the double space in the middle but + don't require it to help copying + fingerprints from sources which fold + multiple space to one. */ + if (i == 10 && *s == ' ') + s++; + } - desc->exact = 0; - desc->u.name = s; - mode = KEYDB_SEARCH_MODE_SUBSTR; /* default mode */ - } + c = hextobyte(s); + if (c == -1) + break; + desc->u.fpr[i] = c; + s += 2; + } + if (i == 20) + mode = KEYDB_SEARCH_MODE_FPR20; + } + + if (!mode) { + desc->exact = 0; + desc->u.name = s; + mode = KEYDB_SEARCH_MODE_SUBSTR; /* default mode */ + } + } + else /* This was a hex number with a prefix */ + return 0; /* and a wrong length */ } desc->mode = mode; |