core: Add 'is_mime' flags to the verify and decrypt results.

* src/op-support.c (_gpgme_parse_plaintext): Add arg r_mime.
* src/decrypt.c (_gpgme_decrypt_status_handler): Ser mime flag.
* src/verify.c (_gpgme_verify_status_handler): Ditto.
* src/gpgme.h.in (gpgme_op_verify_result_t): Append fields 'is_mime'
and '_unused'.
(gpgme_op_decrypt_result_t): New field 'is_mime'.  Shrink '_unused'.

* tests/run-decrypt.c (print_result): Print MIME flag.
* tests/run-verify.c (print_result): Ditto.
--

Note that this flag (Liternal Data packet's 'm' mode) is only
specified in RFC-4880bis.  To use it you currently need to add
"rfc4880bis" to the the gpg.conf.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2018-04-18 15:20:35 +02:00
parent 23177e4410
commit 65479fe7b8
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
9 changed files with 51 additions and 26 deletions

2
NEWS
View File

@ -12,6 +12,8 @@ Noteworthy changes in version 1.10.1 (unreleased)
GPGME_ENCRYPT_WANT_ADDRESS NEW.
gpgme_import_result_t EXTENDED: New field 'skipped_v3_keys'.
gpgme_decrypt_result_t EXTENDED: New field 'symkey_algo'.
gpgme_decrypt_result_t EXTENDED: New field 'is_mime'.
gpgme_verify_result_t EXTENDED: New field 'is_mime'.
cpp: Key::locate NEW.
cpp: Data::toString NEW.
cpp: ImportResult::numV3KeysSkipped NEW.

View File

@ -5284,7 +5284,7 @@ if @var{cipher} or @var{plain} is not a valid pointer.
@since{1.8.0}
The function @code{gpgme_op_decrypt_ext} is the same as
@code{gpgme_op_decrypt_ext} but has an additional argument
@code{gpgme_op_decrypt} but has an additional argument
@var{flags}. If @var{flags} is 0 both function behave identically.
The value in @var{flags} is a bitwise-or combination of one or

View File

@ -409,9 +409,14 @@ _gpgme_decrypt_status_handler (void *priv, gpgme_status_code_t code,
break;
case GPGME_STATUS_PLAINTEXT:
err = _gpgme_parse_plaintext (args, &opd->result.file_name);
if (err)
return err;
{
int mime = 0;
err = _gpgme_parse_plaintext (args, &opd->result.file_name, &mime);
if (err)
return err;
gpgrt_log_debug ("decrypt.c setting mime to %d\n", mime);
opd->result.is_mime = !!mime;
}
break;
case GPGME_STATUS_INQUIRE_MAXLEN:

View File

@ -1356,8 +1356,11 @@ struct _gpgme_op_decrypt_result
* mode. */
unsigned int is_de_vs : 1;
/* The message claims that the content is a MIME object. */
unsigned int is_mime : 1;
/* Internal to GPGME, do not use. */
int _unused : 30;
int _unused : 29;
gpgme_recipient_t recipients;
@ -1572,6 +1575,12 @@ struct _gpgme_op_verify_result
/* The original file name of the plaintext message, if
available. */
char *file_name;
/* The message claims that the content is a MIME object. */
unsigned int is_mime : 1;
/* Internal to GPGME; do not use. */
unsigned int _unused : 31;
};
typedef struct _gpgme_op_verify_result *gpgme_verify_result_t;

View File

@ -358,7 +358,7 @@ _gpgme_parse_key_considered (const char *args,
/* Parse the PLAINTEXT status line in ARGS and return the result in
FILENAMEP. */
gpgme_error_t
_gpgme_parse_plaintext (char *args, char **filenamep)
_gpgme_parse_plaintext (char *args, char **filenamep, int *r_mime)
{
char *tail;
@ -367,7 +367,9 @@ _gpgme_parse_plaintext (char *args, char **filenamep)
if (*args == '\0')
return 0;
/* First argument is file type. */
/* First argument is file type (a one byte uppercase hex value). */
if (args[0] == '6' && args[1] == 'D')
*r_mime = 1;
while (*args != ' ' && *args != '\0')
args++;
while (*args == ' ')

View File

@ -68,8 +68,8 @@ gpgme_error_t _gpgme_parse_inv_recp (char *args, int for_signing,
gpgme_invalid_key_t *key);
/* Parse the PLAINTEXT status line in ARGS and return the result in
FILENAMEP. */
gpgme_error_t _gpgme_parse_plaintext (char *args, char **filenamep);
FILENAMEP and R_MIME. */
gpgme_error_t _gpgme_parse_plaintext (char *args, char **filenamep,int *r_mime);
/* Parse a FAILURE status line and return the error code. ARGS is
modified to contain the location part. */

View File

@ -1091,9 +1091,14 @@ _gpgme_verify_status_handler (void *priv, gpgme_status_code_t code, char *args)
case GPGME_STATUS_PLAINTEXT:
if (++opd->plaintext_seen > 1)
return gpg_error (GPG_ERR_BAD_DATA);
err = _gpgme_parse_plaintext (args, &opd->result.file_name);
if (err)
return err;
{
int mime = 0;
err = _gpgme_parse_plaintext (args, &opd->result.file_name, &mime);
if (err)
return err;
gpgrt_log_debug ("verify.c: setting mime to %d\n", mime);
opd->result.is_mime = !!mime;
}
break;
case GPGME_STATUS_VERIFICATION_COMPLIANCE_MODE:

View File

@ -53,20 +53,21 @@ print_result (gpgme_decrypt_result_t result)
gpgme_recipient_t recp;
int count = 0;
printf ("Original file name: %s\n", nonnull(result->file_name));
printf ("Wrong key usage: %i\n", result->wrong_key_usage);
printf ("Unsupported algorithm: %s\n",
nonnull(result->unsupported_algorithm));
if (result->session_key)
printf ("Session key: %s\n", result->session_key);
printf ("Symmetric algorithm: %s\n", result->symkey_algo);
printf ("Original file name .: %s\n", nonnull(result->file_name));
printf ("Wrong key usage ....: %s\n", result->wrong_key_usage? "yes":"no");
printf ("Compliance de-vs ...: %s\n", result->is_de_vs? "yes":"no");
printf ("MIME flag ..........: %s\n", result->is_mime? "yes":"no");
printf ("Unsupported algo ...: %s\n", nonnull(result->unsupported_algorithm));
printf ("Session key ........: %s\n", nonnull (result->session_key));
printf ("Symmetric algorithm : %s\n", result->symkey_algo);
for (recp = result->recipients; recp && recp->next; recp = recp->next)
{
printf ("recipient %d\n", count++);
printf ("Recipient ...: %d\n", count++);
printf (" status ....: %s\n", gpgme_strerror (recp->status));
printf (" keyid: %s\n", nonnull (recp->keyid));
printf (" algo ...: %s\n", gpgme_pubkey_algo_name (recp->pubkey_algo));
printf (" keyid .....: %s\n", nonnull (recp->keyid));
printf (" algo ......: %s\n",
gpgme_pubkey_algo_name (recp->pubkey_algo));
}
}

View File

@ -136,10 +136,11 @@ print_result (gpgme_verify_result_t result)
gpgme_tofu_info_t ti;
int count = 0;
printf ("Original file name: %s\n", nonnull(result->file_name));
printf ("Original file name .: %s\n", nonnull(result->file_name));
printf ("MIME flag ..........: %s\n", result->is_mime? "yes":"no");
for (sig = result->signatures; sig; sig = sig->next)
{
printf ("Signature %d\n", count++);
printf ("Signature ...: %d\n", count++);
printf (" status ....: %s\n", gpgme_strerror (sig->status));
printf (" summary ...:"); print_summary (sig->summary); putchar ('\n');
printf (" fingerprint: %s\n", nonnull (sig->fpr));
@ -167,7 +168,7 @@ print_result (gpgme_verify_result_t result)
{
printf (" notation ..: '%s'\n", nt->name);
if (strlen (nt->name) != nt->name_len)
printf (" warning : name larger (%d)\n", nt->name_len);
printf (" warning .: name larger (%d)\n", nt->name_len);
printf (" flags ...:%s%s (0x%02x)\n",
nt->critical? " critical":"",
nt->human_readable? " human":"",
@ -180,7 +181,7 @@ print_result (gpgme_verify_result_t result)
printf (" policy ....: '%s'\n", nt->value);
}
if ((nt->value?strlen (nt->value):0) != nt->value_len)
printf (" warning : value larger (%d)\n", nt->value_len);
printf (" warning .: value larger (%d)\n", nt->value_len);
}
if (sig->key)
{