1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-01-21 14:47:03 +01:00

gpg: Add a DECRYPTION_INFO status.

* common/status.h (STATUS_DECRYPTION_INFO): New.
* g10/encr-data.c: Include status.h.
(decrypt_data): Emit STATUS_DECRYPTION_INFO line.
--

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-31 15:14:20 +01:00
parent 66e93807a9
commit f772757ea1
3 changed files with 60 additions and 44 deletions

View File

@ -49,6 +49,7 @@ enum
STATUS_NO_PUBKEY, STATUS_NO_PUBKEY,
STATUS_NO_SECKEY, STATUS_NO_SECKEY,
STATUS_NEED_PASSPHRASE_SYM, STATUS_NEED_PASSPHRASE_SYM,
STATUS_DECRYPTION_INFO,
STATUS_DECRYPTION_FAILED, STATUS_DECRYPTION_FAILED,
STATUS_DECRYPTION_OKAY, STATUS_DECRYPTION_OKAY,
STATUS_MISSING_PASSPHRASE, STATUS_MISSING_PASSPHRASE,

View File

@ -57,7 +57,7 @@ record; gpg2 does this by default and the option is a dummy.
f = The key is fully valid f = The key is fully valid
u = The key is ultimately valid. This often means u = The key is ultimately valid. This often means
that the secret key is available, but any key may that the secret key is available, but any key may
be marked as ultimately valid. be marked as ultimately valid.
If the validity information is given for a UID or UAT If the validity information is given for a UID or UAT
record, it describes the validity calculated based on this record, it describes the validity calculated based on this
@ -97,7 +97,7 @@ record; gpg2 does this by default and the option is a dummy.
This is a single letter, but be prepared that additional This is a single letter, but be prepared that additional
information may follow in some future versions. For trust information may follow in some future versions. For trust
signatures with a regular expression, this is the regular signatures with a regular expression, this is the regular
expression value, quoted as in field 10. expression value, quoted as in field 10.
10. Field: User-ID. The value is quoted like a C string to avoid 10. Field: User-ID. The value is quoted like a C string to avoid
control characters (the colon is quoted "\x3a"). control characters (the colon is quoted "\x3a").
@ -134,7 +134,7 @@ record; gpg2 does this by default and the option is a dummy.
this is the same string as the fingerprint. The advantage this is the same string as the fingerprint. The advantage
of using this value is that it is guaranteed to have been of using this value is that it is guaranteed to have been
been build by the same lookup algorithm as gpgsm uses. been build by the same lookup algorithm as gpgsm uses.
For "uid" records this lists the preferences in the same For "uid" records this lists the preferences in the same
way the gpg's --edit-key menu does. way the gpg's --edit-key menu does.
For "sig" records, this is the fingerprint of the key that For "sig" records, this is the fingerprint of the key that
issued the signature. Note that this is only filled in if issued the signature. Note that this is only filled in if
@ -190,7 +190,7 @@ Example for a "tru" trust base record:
(gpg's option --marginals-needed) (gpg's option --marginals-needed)
7: Number of completely trusted users to introduce a new key signer. 7: Number of completely trusted users to introduce a new key signer.
(gpg's option --completes-needed) (gpg's option --completes-needed)
8: Maximum depth of a certification chain. 8: Maximum depth of a certification chain.
*gpg's option --max-cert-depth) *gpg's option --max-cert-depth)
The "spk" signature subpacket records have the fields: The "spk" signature subpacket records have the fields:
@ -236,7 +236,7 @@ more arguments in future versions.
keyid if it is available. This is the case with CMS and might keyid if it is available. This is the case with CMS and might
eventually also be available for OpenPGP. eventually also be available for OpenPGP.
EXPKEYSIG <long_keyid_or_fpr> <username> EXPKEYSIG <long_keyid_or_fpr> <username>
The signature with the keyid is good, but the signature was The signature with the keyid is good, but the signature was
made by an expired key. The username is the primary one made by an expired key. The username is the primary one
encoded in UTF-8 and %XX escaped. The fingerprint may be used encoded in UTF-8 and %XX escaped. The fingerprint may be used
@ -328,13 +328,13 @@ more arguments in future versions.
UNEXPECTED <what> UNEXPECTED <what>
Unexpected data has been encountered Unexpected data has been encountered
0 - not further specified 1 0 - not further specified 1
TRUST_UNDEFINED <error token> TRUST_UNDEFINED <error token>
TRUST_NEVER <error token> TRUST_NEVER <error token>
TRUST_MARGINAL [0 [<validation_model>]] TRUST_MARGINAL [0 [<validation_model>]]
TRUST_FULLY [0 [<validation_model>]] TRUST_FULLY [0 [<validation_model>]]
TRUST_ULTIMATE [0 [<validation_model>]] TRUST_ULTIMATE [0 [<validation_model>]]
For good signatures one of these status lines are emitted to For good signatures one of these status lines are emitted to
indicate the validity of the key used to create the signature. indicate the validity of the key used to create the signature.
@ -355,7 +355,7 @@ more arguments in future versions.
PKA_TRUST_BAD <mailbox> PKA_TRUST_BAD <mailbox>
Depending on the outcome of the PKA check one of the above Depending on the outcome of the PKA check one of the above
status codes is emitted in addition to a TRUST_* status. status codes is emitted in addition to a TRUST_* status.
Without PKA info available or Without PKA info available or
SIGEXPIRED SIGEXPIRED
This is deprecated in favor of KEYEXPIRED. This is deprecated in favor of KEYEXPIRED.
@ -452,7 +452,7 @@ more arguments in future versions.
1 := Entirely new key. 1 := Entirely new key.
2 := New user IDs 2 := New user IDs
4 := New signatures 4 := New signatures
8 := New subkeys 8 := New subkeys
16 := Contains private key. 16 := Contains private key.
The flags may be ORed. The flags may be ORed.
@ -474,7 +474,7 @@ more arguments in future versions.
operation: operation:
1 - verify 1 - verify
2 - encrypt 2 - encrypt
3 - decrypt 3 - decrypt
FILE_DONE FILE_DONE
Marks the end of a file processing which has been started Marks the end of a file processing which has been started
@ -505,7 +505,7 @@ more arguments in future versions.
"char" is the character displayed with no --status-fd enabled, with "char" is the character displayed with no --status-fd enabled, with
the linefeed replaced by an 'X'. "cur" is the current amount the linefeed replaced by an 'X'. "cur" is the current amount
done and "total" is amount to be done; a "total" of 0 indicates that done and "total" is amount to be done; a "total" of 0 indicates that
the total amount is not known. The condition the total amount is not known. The condition
TOATL && CUR == TOTAL TOATL && CUR == TOTAL
may be used to detect the end of an operation. may be used to detect the end of an operation.
Well known values for WHAT: Well known values for WHAT:
@ -524,7 +524,7 @@ more arguments in future versions.
"learncard" Send by the agent and gpgsm while learing "learncard" Send by the agent and gpgsm while learing
the data of a smartcard. the data of a smartcard.
"card_busy" A smartcard is still working "card_busy" A smartcard is still working
SIG_CREATED <type> <pubkey algo> <hash algo> <class> <timestamp> <key fpr> SIG_CREATED <type> <pubkey algo> <hash algo> <class> <timestamp> <key fpr>
A signature has been created using these parameters. A signature has been created using these parameters.
type: 'D' = detached type: 'D' = detached
@ -536,7 +536,7 @@ more arguments in future versions.
Note, that TIMESTAMP may either be a number with seconds since Note, that TIMESTAMP may either be a number with seconds since
epoch or an ISO 8601 string which can be detected by the epoch or an ISO 8601 string which can be detected by the
presence of the letter 'T' inside. presence of the letter 'T' inside.
KEY_CREATED <type> <fingerprint> [<handle>] KEY_CREATED <type> <fingerprint> [<handle>]
A key has been created A key has been created
type: 'B' = primary and subkey type: 'B' = primary and subkey
@ -557,13 +557,13 @@ more arguments in future versions.
is used. The format is suitable to be passed to the option is used. The format is suitable to be passed to the option
--override-session-key --override-session-key
NOTATION_NAME <name> NOTATION_NAME <name>
NOTATION_DATA <string> NOTATION_DATA <string>
name and string are %XX escaped; the data may be split name and string are %XX escaped; the data may be split
among several NOTATION_DATA lines. among several NOTATION_DATA lines.
USERID_HINT <long main keyid> <string> USERID_HINT <long main keyid> <string>
Give a hint about the user ID for a certain keyID. Give a hint about the user ID for a certain keyID.
POLICY_URL <string> POLICY_URL <string>
string is %XX escaped string is %XX escaped
@ -587,7 +587,7 @@ more arguments in future versions.
8 := "Policy mismatch" 8 := "Policy mismatch"
9 := "Not a secret key" 9 := "Not a secret key"
10 := "Key not trusted" 10 := "Key not trusted"
11 := "Missing certificate" 11 := "Missing certificate"
12 := "Missing issuer certificate" 12 := "Missing issuer certificate"
Note that for historical reasons the INV_RECP status is also Note that for historical reasons the INV_RECP status is also
@ -621,9 +621,9 @@ more arguments in future versions.
SUCCESS [<location>] SUCCESS [<location>]
Postive confirimation that an operation succeeded. <location> Postive confirimation that an operation succeeded. <location>
is optional but if given should not contain spaces. is optional but if given should not contain spaces.
Used only with a few commands. Used only with a few commands.
ATTRIBUTE <fpr> <octets> <type> <index> <count> ATTRIBUTE <fpr> <octets> <type> <index> <count>
<timestamp> <expiredate> <flags> <timestamp> <expiredate> <flags>
@ -650,7 +650,7 @@ more arguments in future versions.
3 = Card with serialnumber detected 3 = Card with serialnumber detected
4 = No card available. 4 = No card available.
5 = No card reader available 5 = No card reader available
6 = No card support available 6 = No card support available
PLAINTEXT <format> <timestamp> <filename> PLAINTEXT <format> <timestamp> <filename>
This indicates the format of the plaintext that is about to be This indicates the format of the plaintext that is about to be
@ -695,6 +695,12 @@ more arguments in future versions.
may either be the specified mountpoint or one randomly choosen may either be the specified mountpoint or one randomly choosen
by g13. by g13.
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.
Format of the "--attribute-fd" output Format of the "--attribute-fd" output
===================================== =====================================
@ -827,7 +833,7 @@ The format of this file is as follows:
relinquishes the GUI from implementing its own passphrase relinquishes the GUI from implementing its own passphrase
entry code. This is a global option. entry code. This is a global option.
%no-ask-passphrase %no-ask-passphrase
Disable the ask-passphrase mode. Disable the ask-passphrase mode.
%no-protection %no-protection
With GnuPG 2.1 it is not anymore possible to specify a With GnuPG 2.1 it is not anymore possible to specify a
passphrase for unattended key generation. The passphrase passphrase for unattended key generation. The passphrase
@ -898,7 +904,7 @@ The format of this file is as follows:
information and which is also part of the fingerprint information and which is also part of the fingerprint
calculation. Either a date like "1986-04-26" or a full calculation. Either a date like "1986-04-26" or a full
timestamp like "19860426T042640" may be used. The time is timestamp like "19860426T042640" may be used. The time is
considered to be UTC. If it is not given the current time considered to be UTC. If it is not given the current time
is used. is used.
Preferences: <string> Preferences: <string>
Set the cipher, hash, and compression preference values for Set the cipher, hash, and compression preference values for
@ -1207,7 +1213,7 @@ Other Notes
OIDs below the GnuPG arc: OIDs below the GnuPG arc:
========================= =========================
1.3.6.1.4.1.11591.2 GnuPG 1.3.6.1.4.1.11591.2 GnuPG
1.3.6.1.4.1.11591.2.1 notation 1.3.6.1.4.1.11591.2.1 notation
1.3.6.1.4.1.11591.2.1.1 pkaAddress 1.3.6.1.4.1.11591.2.1.1 pkaAddress
1.3.6.1.4.1.11591.2.12242973 invalid encoded OID 1.3.6.1.4.1.11591.2.12242973 invalid encoded OID

View File

@ -1,6 +1,6 @@
/* encr-data.c - process an encrypted data packet /* encr-data.c - process an encrypted data packet
* Copyright (C) 1998, 1999, 2000, 2001, 2005, * Copyright (C) 1998, 1999, 2000, 2001, 2005,
* 2006, 2009 Free Software Foundation, Inc. * 2006, 2009, 2012 Free Software Foundation, Inc.
* *
* This file is part of GnuPG. * This file is part of GnuPG.
* *
@ -30,6 +30,7 @@
#include "cipher.h" #include "cipher.h"
#include "options.h" #include "options.h"
#include "i18n.h" #include "i18n.h"
#include "status.h"
static int mdc_decode_filter ( void *opaque, int control, IOBUF a, static int mdc_decode_filter ( void *opaque, int control, IOBUF a,
@ -80,7 +81,7 @@ decrypt_data( void *procctx, PKT_encrypted *ed, DEK *dek )
byte temp[32]; byte temp[32];
unsigned blocksize; unsigned blocksize;
unsigned nprefix; unsigned nprefix;
dfx = xtrycalloc (1, sizeof *dfx); dfx = xtrycalloc (1, sizeof *dfx);
if (!dfx) if (!dfx)
return gpg_error_from_syserror (); return gpg_error_from_syserror ();
@ -89,12 +90,20 @@ decrypt_data( void *procctx, PKT_encrypted *ed, DEK *dek )
if ( opt.verbose && !dek->algo_info_printed ) if ( opt.verbose && !dek->algo_info_printed )
{ {
if (!openpgp_cipher_test_algo (dek->algo)) if (!openpgp_cipher_test_algo (dek->algo))
log_info (_("%s encrypted data\n"), log_info (_("%s encrypted data\n"),
openpgp_cipher_algo_name (dek->algo)); openpgp_cipher_algo_name (dek->algo));
else else
log_info (_("encrypted with unknown algorithm %d\n"), dek->algo ); log_info (_("encrypted with unknown algorithm %d\n"), dek->algo );
dek->algo_info_printed = 1; 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);
}
rc = openpgp_cipher_test_algo (dek->algo); rc = openpgp_cipher_test_algo (dek->algo);
if (rc) if (rc)
goto leave; goto leave;
@ -105,7 +114,7 @@ decrypt_data( void *procctx, PKT_encrypted *ed, DEK *dek )
if ( ed->len && ed->len < (nprefix+2) ) if ( ed->len && ed->len < (nprefix+2) )
BUG(); BUG();
if ( ed->mdc_method ) if ( ed->mdc_method )
{ {
if (gcry_md_open (&dfx->mdc_hash, ed->mdc_method, 0 )) if (gcry_md_open (&dfx->mdc_hash, ed->mdc_method, 0 ))
BUG (); BUG ();
@ -140,7 +149,7 @@ decrypt_data( void *procctx, PKT_encrypted *ed, DEK *dek )
goto leave; goto leave;
} }
if (!ed->buf) if (!ed->buf)
{ {
log_error(_("problem handling encrypted packet\n")); log_error(_("problem handling encrypted packet\n"));
goto leave; goto leave;
@ -150,7 +159,7 @@ decrypt_data( void *procctx, PKT_encrypted *ed, DEK *dek )
if ( ed->len ) if ( ed->len )
{ {
for (i=0; i < (nprefix+2) && ed->len; i++, ed->len-- ) for (i=0; i < (nprefix+2) && ed->len; i++, ed->len-- )
{ {
if ( (c=iobuf_get(ed->buf)) == -1 ) if ( (c=iobuf_get(ed->buf)) == -1 )
break; break;
@ -158,7 +167,7 @@ decrypt_data( void *procctx, PKT_encrypted *ed, DEK *dek )
temp[i] = c; temp[i] = c;
} }
} }
else else
{ {
for (i=0; i < (nprefix+2); i++ ) for (i=0; i < (nprefix+2); i++ )
if ( (c=iobuf_get(ed->buf)) == -1 ) if ( (c=iobuf_get(ed->buf)) == -1 )
@ -166,7 +175,7 @@ decrypt_data( void *procctx, PKT_encrypted *ed, DEK *dek )
else else
temp[i] = c; temp[i] = c;
} }
gcry_cipher_decrypt (dfx->cipher_hd, temp, nprefix+2, NULL, 0); gcry_cipher_decrypt (dfx->cipher_hd, temp, nprefix+2, NULL, 0);
gcry_cipher_sync (dfx->cipher_hd); gcry_cipher_sync (dfx->cipher_hd);
p = temp; p = temp;
@ -177,7 +186,7 @@ decrypt_data( void *procctx, PKT_encrypted *ed, DEK *dek )
rc = gpg_error (GPG_ERR_BAD_KEY); rc = gpg_error (GPG_ERR_BAD_KEY);
goto leave; goto leave;
} }
if ( dfx->mdc_hash ) if ( dfx->mdc_hash )
gcry_md_write (dfx->mdc_hash, temp, nprefix+2); gcry_md_write (dfx->mdc_hash, temp, nprefix+2);
@ -192,7 +201,7 @@ decrypt_data( void *procctx, PKT_encrypted *ed, DEK *dek )
if ( ed->mdc_method && dfx->eof_seen == 2 ) if ( ed->mdc_method && dfx->eof_seen == 2 )
rc = gpg_error (GPG_ERR_INV_PACKET); rc = gpg_error (GPG_ERR_INV_PACKET);
else if ( ed->mdc_method ) else if ( ed->mdc_method )
{ {
/* We used to let parse-packet.c handle the MDC packet but this /* We used to let parse-packet.c handle the MDC packet but this
turned out to be a problem with compressed packets: With old turned out to be a problem with compressed packets: With old
style packets there is no length information available and style packets there is no length information available and
@ -226,8 +235,8 @@ decrypt_data( void *procctx, PKT_encrypted *ed, DEK *dek )
/* log_printhex("MDC message:", dfx->defer, 22); */ /* log_printhex("MDC message:", dfx->defer, 22); */
/* log_printhex("MDC calc:", gcry_md_read (dfx->mdc_hash,0), datalen); */ /* log_printhex("MDC calc:", gcry_md_read (dfx->mdc_hash,0), datalen); */
} }
leave: leave:
release_dfx_context (dfx); release_dfx_context (dfx);
return rc; return rc;
@ -244,7 +253,7 @@ mdc_decode_filter (void *opaque, int control, IOBUF a,
size_t n, size = *ret_len; size_t n, size = *ret_len;
int rc = 0; int rc = 0;
int c; int c;
if ( control == IOBUFCTRL_UNDERFLOW && dfx->eof_seen ) if ( control == IOBUFCTRL_UNDERFLOW && dfx->eof_seen )
{ {
*ret_len = 0; *ret_len = 0;
@ -254,7 +263,7 @@ mdc_decode_filter (void *opaque, int control, IOBUF a,
{ {
assert (a); assert (a);
assert ( size > 44 ); assert ( size > 44 );
/* Get at least 22 bytes and put it somewhere ahead in the buffer. */ /* Get at least 22 bytes and put it somewhere ahead in the buffer. */
for (n=22; n < 44 ; n++ ) for (n=22; n < 44 ; n++ )
{ {
@ -262,7 +271,7 @@ mdc_decode_filter (void *opaque, int control, IOBUF a,
break; break;
buf[n] = c; buf[n] = c;
} }
if ( n == 44 ) if ( n == 44 )
{ {
/* We have enough stuff - flush the deferred stuff. */ /* We have enough stuff - flush the deferred stuff. */
/* (we asserted that the buffer is large enough) */ /* (we asserted that the buffer is large enough) */
@ -276,7 +285,7 @@ mdc_decode_filter (void *opaque, int control, IOBUF a,
memcpy (buf, dfx->defer, 22 ); memcpy (buf, dfx->defer, 22 );
} }
/* Now fill up. */ /* Now fill up. */
for (; n < size; n++ ) for (; n < size; n++ )
{ {
if ( (c = iobuf_get(a)) == -1 ) if ( (c = iobuf_get(a)) == -1 )
break; break;
@ -317,11 +326,11 @@ mdc_decode_filter (void *opaque, int control, IOBUF a,
} }
*ret_len = n; *ret_len = n;
} }
else if ( control == IOBUFCTRL_FREE ) else if ( control == IOBUFCTRL_FREE )
{ {
release_dfx_context (dfx); release_dfx_context (dfx);
} }
else if ( control == IOBUFCTRL_DESC ) else if ( control == IOBUFCTRL_DESC )
{ {
*(char**)buf = "mdc_decode_filter"; *(char**)buf = "mdc_decode_filter";
} }
@ -335,8 +344,8 @@ decode_filter( void *opaque, int control, IOBUF a, byte *buf, size_t *ret_len)
decode_filter_ctx_t fc = opaque; decode_filter_ctx_t fc = opaque;
size_t n, size = *ret_len; size_t n, size = *ret_len;
int rc = 0; int rc = 0;
if ( control == IOBUFCTRL_UNDERFLOW ) if ( control == IOBUFCTRL_UNDERFLOW )
{ {
assert(a); assert(a);
n = iobuf_read ( a, buf, size ); n = iobuf_read ( a, buf, size );
@ -351,7 +360,7 @@ decode_filter( void *opaque, int control, IOBUF a, byte *buf, size_t *ret_len)
rc = -1; /* EOF */ rc = -1; /* EOF */
*ret_len = n; *ret_len = n;
} }
else if ( control == IOBUFCTRL_FREE ) else if ( control == IOBUFCTRL_FREE )
{ {
release_dfx_context (fc); release_dfx_context (fc);
} }