summaryrefslogtreecommitdiffstats
path: root/g10/cpr.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2013-12-11 10:20:15 +0100
committerWerner Koch <wk@gnupg.org>2013-12-11 10:20:15 +0100
commit101a54add351ff62793cbfbf3877787c4791f833 (patch)
tree7bf96a96fc6c3cf47ec70f5e78e0ccb97b75d257 /g10/cpr.c
parentgpg: Change OID of Ed25519 and add Brainpool oids. (diff)
downloadgnupg2-101a54add351ff62793cbfbf3877787c4791f833.tar.xz
gnupg2-101a54add351ff62793cbfbf3877787c4791f833.zip
gpg: Change --show-session-key to print the session key earlier.
* g10/cpr.c (write_status_strings): New. (write_status_text): Replace code by a call to write_status_strings. * g10/mainproc.c (proc_encrypted): Remove show_session_key code. * g10/decrypt-data.c (decrypt_data): Add new show_session_key code. -- This feature can be used to return the session key for just a part of a file. For example to downloading just the first 32k of a huge file, decrypting that incomplete part and while ignoring all the errors break out the session key. The session key may then be used on the server to decrypt the entire file without the need to have the private key on the server. GnuPG-bug-id: 1389 Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'g10/cpr.c')
-rw-r--r--g10/cpr.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/g10/cpr.c b/g10/cpr.c
index b84710d03..988d211ad 100644
--- a/g10/cpr.c
+++ b/g10/cpr.c
@@ -139,9 +139,14 @@ write_status ( int no )
}
+/* Write a status line with code NO followed by the string TEXT and
+ directly followed by the remaining strings up to a NULL. */
void
-write_status_text (int no, const char *text)
+write_status_strings (int no, const char *text, ...)
{
+ va_list arg_ptr;
+ const char *s;
+
if (!statusfp || !status_currently_allowed (no) )
return; /* Not enabled or allowed. */
@@ -150,15 +155,22 @@ write_status_text (int no, const char *text)
if ( text )
{
es_putc ( ' ', statusfp);
- for (; *text; text++)
+ va_start (arg_ptr, text);
+ s = text;
+ do
{
- if (*text == '\n')
- es_fputs ("\\n", statusfp);
- else if (*text == '\r')
- es_fputs ("\\r", statusfp);
- else
- es_fputc ( *(const byte *)text, statusfp);
+ for (; *s; s++)
+ {
+ if (*s == '\n')
+ es_fputs ("\\n", statusfp);
+ else if (*s == '\r')
+ es_fputs ("\\r", statusfp);
+ else
+ es_fputc (*(const byte *)s, statusfp);
+ }
}
+ while ((s = va_arg (arg_ptr, const char*)));
+ va_end (arg_ptr);
}
es_putc ('\n', statusfp);
if (es_fflush (statusfp) && opt.exit_on_status_write_error)
@@ -166,6 +178,12 @@ write_status_text (int no, const char *text)
}
+void
+write_status_text (int no, const char *text)
+{
+ write_status_strings (no, text, NULL);
+}
+
/* Wrte an ERROR status line using a full gpg-error error value. */
void
write_status_error (const char *where, gpg_error_t err)