diff options
author | Werner Koch <[email protected]> | 2013-12-11 09:20:15 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2013-12-11 09:50:55 +0000 |
commit | fa3f555d756be0229ab10516b901e50230b22033 (patch) | |
tree | e0d23f3acddfca47d2a729d9b3058d8431fc9507 | |
parent | Update config.{guess,sub} and some copyright notices. (diff) | |
download | gnupg-fa3f555d756be0229ab10516b901e50230b22033.tar.gz gnupg-fa3f555d756be0229ab10516b901e50230b22033.zip |
Change --show-session-key to print the session key earlier.
* g10/mainproc.c (proc_encrypted): Move show_session_key code to ...
* g10/decrypt-data.c (decrypt_data): here.
--
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.
This is the same feature as
commit 101a54add351ff62793cbfbf3877787c4791f833 for 2.1 and
commit 3ae90ff28c500967cb90b1176299d2ca01ef450f for 2.0.
GnuPG-bug-id: 1389
Signed-off-by: Werner Koch <[email protected]>
-rw-r--r-- | g10/encr-data.c | 10 | ||||
-rw-r--r-- | g10/mainproc.c | 11 |
2 files changed, 11 insertions, 10 deletions
diff --git a/g10/encr-data.c b/g10/encr-data.c index a591bebf7..8d277ce2e 100644 --- a/g10/encr-data.c +++ b/g10/encr-data.c @@ -100,6 +100,16 @@ decrypt_data( void *procctx, PKT_encrypted *ed, DEK *dek ) write_status_text (STATUS_DECRYPTION_INFO, buf); } + if (opt.show_session_key) + { + char *buf = xmalloc (dek->keylen*2 + 20); + sprintf (buf, "%d:", dek->algo); + for (i=0; i < dek->keylen; i++ ) + sprintf(buf+strlen(buf), "%02X", dek->key[i] ); + log_info ("session key: `%s'\n", buf); + write_status_text (STATUS_SESSION_KEY, buf); + } + if( (rc=check_cipher_algo(dek->algo)) ) goto leave; blocksize = cipher_get_blocksize(dek->algo); diff --git a/g10/mainproc.c b/g10/mainproc.c index d03a9a700..5b6d8db04 100644 --- a/g10/mainproc.c +++ b/g10/mainproc.c @@ -587,6 +587,7 @@ proc_encrypted( CTX c, PACKET *pkt ) } else if( !c->dek ) result = G10ERR_NO_SECKEY; + if( !result ) result = decrypt_data( c, pkt->pkt.encrypted, c->dek ); @@ -600,16 +601,6 @@ proc_encrypted( CTX c, PACKET *pkt ) write_status( STATUS_GOODMDC ); else if(!opt.no_mdc_warn) log_info (_("WARNING: message was not integrity protected\n")); - if(opt.show_session_key) - { - int i; - char *buf = xmalloc ( c->dek->keylen*2 + 20 ); - sprintf ( buf, "%d:", c->dek->algo ); - for(i=0; i < c->dek->keylen; i++ ) - sprintf(buf+strlen(buf), "%02X", c->dek->key[i] ); - log_info( "session key: `%s'\n", buf ); - write_status_text ( STATUS_SESSION_KEY, buf ); - } } else if( result == G10ERR_BAD_SIGN ) { log_error(_("WARNING: encrypted message has been manipulated!\n")); |