diff options
author | Werner Koch <wk@gnupg.org> | 2002-01-29 11:05:05 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2002-01-29 11:05:05 +0100 |
commit | 2d1d9d928c652f4d9fcab2d9d020c6225c16ee2c (patch) | |
tree | 9d6ced2631cee69c3f8e2dae8396c78ab3fc3a00 /agent/command.c | |
parent | * certreqgen.c (create_request): Store the email address in the req. (diff) | |
download | gnupg2-2d1d9d928c652f4d9fcab2d9d020c6225c16ee2c.tar.xz gnupg2-2d1d9d928c652f4d9fcab2d9d020c6225c16ee2c.zip |
* findkey.c (agent_key_available): New.
* command.c (cmd_havekey): New.
(register_commands): And register new command.
Diffstat (limited to 'agent/command.c')
-rw-r--r-- | agent/command.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/agent/command.c b/agent/command.c index 37276991c..bbcab8e7d 100644 --- a/agent/command.c +++ b/agent/command.c @@ -120,6 +120,37 @@ cmd_marktrusted (ASSUAN_CONTEXT ctx, char *line) +/* HAVEKEY <hexstring_with_keygrip> + + Return success when the secret key is available */ +static int +cmd_havekey (ASSUAN_CONTEXT ctx, char *line) +{ + int n; + char *p; + unsigned char buf[20]; + + /* parse the hash value */ + for (p=line,n=0; hexdigitp (p); p++, n++) + ; + if (*p) + return set_error (Parameter_Error, "invalid hexstring"); + if ((n&1)) + return set_error (Parameter_Error, "odd number of digits"); + n /= 2; + if (n != 20) + return set_error (Parameter_Error, "invalid length of keygrip"); + + for (p=line, n=0; n < 20; p += 2, n++) + buf[n] = xtoi_2 (p); + + if (agent_key_available (buf)) + return ASSUAN_No_Secret_Key; + + return 0; +} + + /* SIGKEY <hexstring_with_keygrip> SETKEY <hexstring_with_keygrip> @@ -414,6 +445,7 @@ register_commands (ASSUAN_CONTEXT ctx) int (*handler)(ASSUAN_CONTEXT, char *line); } table[] = { { "ISTRUSTED", 0, cmd_istrusted }, + { "HAVEKEY", 0, cmd_havekey }, { "SIGKEY", 0, cmd_sigkey }, { "SETKEY", 0, cmd_sigkey }, { "SETHASH", 0, cmd_sethash }, |