gpg-agent with preset passphrase
Andreas Hartmann
andihartmann at freenet.de
Thu Sep 1 14:37:53 CEST 2005
Hello Richard,
the problem is, that the passphrase supplied with gpg-preset-passphrase is
stored native and not as a hexstring. I did the following changes in agent.c:
--- command.c.old 2005-07-27 16:18:13.000000000 +0200
+++ command.c 2005-09-01 14:30:46.000000000 +0200
@@ -807,7 +807,10 @@
unsigned char grip[20];
char *grip_clear = NULL;
char *passphrase = NULL;
+ char *hexstring;
int ttl;
+ int i;
+ unsigned char *p;
if (!opt.allow_preset_passphrase)
return gpg_error (GPG_ERR_NOT_SUPPORTED);
@@ -843,7 +846,18 @@
else
return map_to_assuan_status (gpg_error (GPG_ERR_NOT_IMPLEMENTED));
- rc = agent_put_cache (grip_clear, CACHE_MODE_ANY, passphrase, ttl);
+ /* map passphrase to hexstring */
+ hexstring = gcry_malloc_secure(strlen ((char*)passphrase)*2+1);
+ if (!hexstring)
+ {
+ xfree (passphrase);
+ return map_to_assuan_status (gpg_error (GPG_ERR_MISSING_VALUE));
+ }
+
+ for (i=0, p=passphrase; *p; p++, i+=2)
+ sprintf(hexstring+i,"%02X",*p);
+
+ rc = agent_put_cache (grip_clear, CACHE_MODE_ANY, hexstring, ttl);
if (rc)
log_error ("command preset_passwd failed: %s\n", gpg_strerror (rc));
These changes are probably not the best way, but they are working. The
developpers do have a better solution for sure :-).
But now, I have a question: How is it possible to get the KEYGRIP? If I do
the following, I'm allways getting errors:
andreas at athlon:~ > gpg-protect-tool --show-keygrip tmp_key.pub
gpg-protect-tool: invalid S-Expression in `tmp_key.pub' (off=919): Bad
hexadecimal character in S-expression
andreas at athlon:~ > gpg-protect-tool --show-keygrip tmp_key.sec
gpg-protect-tool: invalid S-Expression in `tmp_key.sec' (off=1017):
Invalid length specifier in S-expression
Probably wrong file format of the keys?
Kind regards,
Andreas Hartmann
More information about the Gnupg-users
mailing list