summaryrefslogtreecommitdiffstats
path: root/agent/genkey.c
diff options
context:
space:
mode:
authorBen Kibbey <bjk@luxsci.net>2011-09-11 22:55:34 +0200
committerWerner Koch <wk@gnupg.org>2011-09-12 09:54:16 +0200
commitfb1cdd7b0ebece16ffe60a30e4d01c5dbb1ca92b (patch)
tree3b5768e1b8efe24ac70e3797638347095cede82a /agent/genkey.c
parentMark component descriptions for translation. (diff)
downloadgnupg2-fb1cdd7b0ebece16ffe60a30e4d01c5dbb1ca92b.tar.xz
gnupg2-fb1cdd7b0ebece16ffe60a30e4d01c5dbb1ca92b.zip
Handle pinentry-mode=loopback.
When this mode is set an inquire will be sent to the client to retrieve the passphrase. This adds a new inquire keyword "NEW_PASSPHRASE" that the GENKEY and PASSWD commands use when generating a new key.
Diffstat (limited to '')
-rw-r--r--agent/genkey.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/agent/genkey.c b/agent/genkey.c
index 09f1c72aa..85ba7023a 100644
--- a/agent/genkey.c
+++ b/agent/genkey.c
@@ -304,6 +304,23 @@ agent_ask_new_passphrase (ctrl_t ctrl, const char *prompt,
*r_passphrase = NULL;
+ if (ctrl->pinentry_mode == PINENTRY_MODE_LOOPBACK)
+ {
+ size_t size;
+ size_t len = 100;
+ unsigned char *buffer;
+
+ err = pinentry_loopback(ctrl, "NEW_PASSPHRASE", &buffer, &size, len);
+ if (err)
+ xfree(buffer);
+ else
+ {
+ buffer[size] = 0;
+ *r_passphrase = buffer;
+ }
+ return err;
+ }
+
pi = gcry_calloc_secure (2, sizeof (*pi) + 100);
pi2 = pi + (sizeof *pi + 100);
pi->max_length = 100;