aboutsummaryrefslogtreecommitdiffstats
path: root/g10/decrypt-data.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2013-12-11 09:20:15 +0000
committerWerner Koch <[email protected]>2013-12-11 09:20:15 +0000
commit101a54add351ff62793cbfbf3877787c4791f833 (patch)
tree7bf96a96fc6c3cf47ec70f5e78e0ccb97b75d257 /g10/decrypt-data.c
parentgpg: Change OID of Ed25519 and add Brainpool oids. (diff)
downloadgnupg-101a54add351ff62793cbfbf3877787c4791f833.tar.gz
gnupg-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 <[email protected]>
Diffstat (limited to 'g10/decrypt-data.c')
-rw-r--r--g10/decrypt-data.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/g10/decrypt-data.c b/g10/decrypt-data.c
index e219898ee..4ad47cb8e 100644
--- a/g10/decrypt-data.c
+++ b/g10/decrypt-data.c
@@ -106,6 +106,23 @@ decrypt_data (ctrl_t ctrl, void *procctx, PKT_encrypted *ed, DEK *dek)
write_status_text (STATUS_DECRYPTION_INFO, buf);
}
+ if (opt.show_session_key)
+ {
+ char numbuf[25];
+ char *hexbuf;
+
+ snprintf (numbuf, sizeof numbuf, "%d:", dek->algo);
+ hexbuf = bin2hex (dek->key, dek->keylen, NULL);
+ if (!hexbuf)
+ {
+ rc = gpg_error_from_syserror ();
+ goto leave;
+ }
+ log_info ("session key: '%s%s'\n", numbuf, hexbuf);
+ write_status_strings (STATUS_SESSION_KEY, numbuf, hexbuf, NULL);
+ xfree (hexbuf);
+ }
+
rc = openpgp_cipher_test_algo (dek->algo);
if (rc)
goto leave;