
kissg at ssg
Aug 26, 2008, 8:48 AM
Post #1 of 4
(185 views)
Permalink
|
|
missing hexstrint->plaintext conversion
|
|
Dear Werner et al., At 2006-07-29 (svn revision 4209) gpg-preset-passphrases was changed in order to send passphrases as hexstring. Unfortunately the receiver side did not follow this change well. Received hexstring is cached without converting back to plaintext. This patch below fixes the problem. Regards Gabor --- command.c-orig 2008-08-26 14:43:16.037456000 +0200 +++ command.c 2008-08-26 17:44:36.935945453 +0200 @@ -263,6 +263,28 @@ return 0; } +/* Convert (in place) an already parsed hexstring of + * 'len' digits to native bytes. */ +#define fromhex(h) ( (h)<='9' ? (h)-'0' : ((h)|0x20)-'a'+10 ) +static char * +decode_hexstring (char *string, int len) +{ + unsigned char *from, *to; + + for (from=to=(unsigned char*)string; len>0; to++) + { + unsigned char value; + value = fromhex(*from); + from++; + value <<= 4; + value |= fromhex(*from); + from++; + *to = value; + len -= 2; + } + return string; +} + /* Parse the keygrip in STRING into the provided buffer BUF. BUF must provide space for 20 bytes. BUF is not changed if the function returns an error. */ @@ -1135,7 +1157,10 @@ /* If there is a passphrase, use it. Currently, a passphrase is required. */ if (*line) - passphrase = line; + { + passphrase = decode_hexstring(line, len); + passphrase[len/2] = '\0'; + } else return gpg_error (GPG_ERR_NOT_IMPLEMENTED); _______________________________________________ Gnupg-devel mailing list Gnupg-devel[at]gnupg.org http://lists.gnupg.org/mailman/listinfo/gnupg-devel
|