1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-06-08 23:37:47 +02:00

Add a DECRYPTION_INFO status.

* g10/status.h (STATUS_DECRYPTION_INFO): New.
* g10/status.c (get_status_string): Add new status string.
* g10/encr-data.c: Include status.h.
(decrypt_data): Print STATUS_DECRYPTION_INFO.
--
This is  backport of commit  5667e33.

DECRYPTION_INFO <mdc_method> <sym_algo>
   Print information about the symmetric encryption algorithm and
   the MDC method.  This will be emitted even if the decryption
   fails.
This commit is contained in:
Werner Koch 2012-01-13 16:20:53 +01:00
parent 1575678710
commit cfb193a1de
3 changed files with 29 additions and 17 deletions

View File

@ -30,7 +30,7 @@
#include "cipher.h"
#include "options.h"
#include "i18n.h"
#include "status.h"
static int mdc_decode_filter( void *opaque, int control, IOBUF a,
byte *buf, size_t *ret_len);
@ -91,6 +91,15 @@ decrypt_data( void *procctx, PKT_encrypted *ed, DEK *dek )
log_info(_("encrypted with unknown algorithm %d\n"), dek->algo );
dek->algo_info_printed = 1;
}
{
char buf[20];
snprintf (buf, sizeof buf, "%d %d", ed->mdc_method, dek->algo);
write_status_text (STATUS_DECRYPTION_INFO, buf);
}
if( (rc=check_cipher_algo(dek->algo)) )
goto leave;
blocksize = cipher_get_blocksize(dek->algo);
@ -120,7 +129,7 @@ decrypt_data( void *procctx, PKT_encrypted *ed, DEK *dek )
{
log_error("key setup failed: %s\n", g10_errstr(rc) );
goto leave;
}
if (!ed->buf) {
log_error(_("problem handling encrypted packet\n"));
@ -199,7 +208,7 @@ decrypt_data( void *procctx, PKT_encrypted *ed, DEK *dek )
/*log_hexdump("MDC calculated:",md_read( dfx->mdc_hash, 0), datalen);*/
/*log_hexdump("MDC message :", dfx->defer, 20);*/
}
leave:
release_dfx_context (dfx);

View File

@ -75,7 +75,7 @@ progress_cb ( void *ctx, int c )
}
static const char *
get_status_string ( int no )
get_status_string ( int no )
{
const char *s;
@ -165,6 +165,7 @@ get_status_string ( int no )
case STATUS_PKA_TRUST_GOOD : s = "PKA_TRUST_GOOD"; break;
case STATUS_BEGIN_SIGNING : s = "BEGIN_SIGNING"; break;
case STATUS_ERROR : s = "ERROR"; break;
case STATUS_DECRYPTION_INFO: s = "DECRYPTION_INFO"; break;
default: s = "?"; break;
}
return s;
@ -187,13 +188,13 @@ status_currently_allowed (int no)
prompt the user. */
switch (no)
{
case STATUS_GET_BOOL:
case STATUS_GET_LINE:
case STATUS_GET_HIDDEN:
case STATUS_GOT_IT:
case STATUS_GET_BOOL:
case STATUS_GET_LINE:
case STATUS_GET_HIDDEN:
case STATUS_GOT_IT:
case STATUS_IMPORTED:
case STATUS_IMPORT_OK:
case STATUS_IMPORT_CHECK:
case STATUS_IMPORT_OK:
case STATUS_IMPORT_CHECK:
case STATUS_IMPORT_RES:
return 1; /* Yes. */
default:
@ -214,7 +215,7 @@ set_status_fd ( int fd )
if ( statusfp && statusfp != stdout && statusfp != stderr )
fclose (statusfp);
statusfp = NULL;
if ( fd == -1 )
if ( fd == -1 )
return;
if( fd == 1 )
@ -260,7 +261,7 @@ write_status_text ( int no, const char *text)
fputs ( "\\n", statusfp );
else if (*text == '\r')
fputs ( "\\r", statusfp );
else
else
putc ( *(const byte *)text, statusfp );
}
}
@ -287,7 +288,7 @@ write_status_text_and_buffer ( int no, const char *string,
if( !statusfp || !status_currently_allowed (no) )
return; /* Not enabled or allowed. */
if (wrap == -1) {
lower_limit--;
wrap = 0;
@ -306,8 +307,8 @@ write_status_text_and_buffer ( int no, const char *string,
first = 0;
}
for (esc=0, s=buffer, n=len; n && !esc; s++, n-- ) {
if ( *s == '%' || *(const byte*)s <= lower_limit
|| *(const byte*)s == 127 )
if ( *s == '%' || *(const byte*)s <= lower_limit
|| *(const byte*)s == 127 )
esc = 1;
if ( wrap && ++count > wrap ) {
dowrap=1;
@ -317,7 +318,7 @@ write_status_text_and_buffer ( int no, const char *string,
if (esc) {
s--; n++;
}
if (s != buffer)
if (s != buffer)
fwrite (buffer, s-buffer, 1, statusfp );
if ( esc ) {
fprintf (statusfp, "%%%02X", *(const byte*)s );
@ -535,7 +536,7 @@ myread(int fd, void *buf, size_t count)
raise (SIGHUP); /* no more input data */
#endif
}
}
}
return rc;
}

View File

@ -120,6 +120,8 @@
#define STATUS_ERROR 85
#define STATUS_DECRYPTION_INFO 86
/*-- status.c --*/
void set_status_fd ( int fd );