mirror of
git://git.gnupg.org/gnupg.git
synced 2024-11-10 21:38:50 +01:00
Use the longest key ID available when talking to a HKP server.
This is issue 1340. Now that PKSD is dead, and SKS supports long key IDs, this is safe to do. Patch from Daniel Kahn Gillmor <dkg@fifthhorseman.net>.
This commit is contained in:
parent
120b0ce136
commit
6fe25e5602
@ -234,9 +234,10 @@ static int
|
|||||||
get_key(char *getkey)
|
get_key(char *getkey)
|
||||||
{
|
{
|
||||||
CURLcode res;
|
CURLcode res;
|
||||||
char request[MAX_URL+60];
|
char request[MAX_URL+92];
|
||||||
char *offset;
|
char *offset;
|
||||||
struct curl_writer_ctx ctx;
|
struct curl_writer_ctx ctx;
|
||||||
|
size_t keylen;
|
||||||
|
|
||||||
memset(&ctx,0,sizeof(ctx));
|
memset(&ctx,0,sizeof(ctx));
|
||||||
|
|
||||||
@ -262,14 +263,19 @@ get_key(char *getkey)
|
|||||||
strcat(request,port);
|
strcat(request,port);
|
||||||
strcat(request,opt->path);
|
strcat(request,opt->path);
|
||||||
/* request is MAX_URL+55 bytes long - MAX_URL covers the whole URL,
|
/* request is MAX_URL+55 bytes long - MAX_URL covers the whole URL,
|
||||||
including any supplied path. The 60 overcovers this /pks/... etc
|
including any supplied path. The 92 overcovers this /pks/... etc
|
||||||
string plus the 8 bytes of key id */
|
string plus the 8, 16, or 40 bytes of key id/fingerprint */
|
||||||
append_path(request,"/pks/lookup?op=get&options=mr&search=0x");
|
append_path(request,"/pks/lookup?op=get&options=mr&search=0x");
|
||||||
|
|
||||||
/* fingerprint or long key id. Take the last 8 characters and treat
|
/* send only fingerprint, long key id, or short keyid. see:
|
||||||
it like a short key id */
|
https://tools.ietf.org/html/draft-shaw-openpgp-hkp-00#section-3.1.1.1 */
|
||||||
if(strlen(getkey)>8)
|
keylen = strlen(getkey);
|
||||||
offset=&getkey[strlen(getkey)-8];
|
if(keylen >= 40)
|
||||||
|
offset=&getkey[keylen-40];
|
||||||
|
else if(keylen >= 16)
|
||||||
|
offset=&getkey[keylen-16];
|
||||||
|
else if(keylen >= 8)
|
||||||
|
offset=&getkey[keylen-8];
|
||||||
else
|
else
|
||||||
offset=getkey;
|
offset=getkey;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user