From dd19cabe81b7bf4177ea2ca741f6eb6cd1cab25e Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 1 Jun 2018 01:01:08 +0200 Subject: [PATCH] core: New decryption result flag 'legacy_cipher_nomdc'. * src/gpgme.h.in (_gpgme_op_decrypt_result): Add flag legacy_cipher_nomdc. * src/decrypt.c (parse_status_error): Set this flag. * tests/run-decrypt.c (print_result): print it. (main): Print the result even on error. Signed-off-by: Werner Koch --- NEWS | 8 +++++--- doc/gpgme.texi | 17 +++++++++++++++-- src/decrypt.c | 7 ++++++- src/gpgme.h.in | 6 +++++- tests/run-decrypt.c | 3 +++ 5 files changed, 34 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index 848f4e99..bc1330ad 100644 --- a/NEWS +++ b/NEWS @@ -6,9 +6,11 @@ Noteworthy changes in version 1.11.2 (unreleased) * Interface changes relative to the 1.11.1 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - cpp: DecryptionResult::sessionKey NEW. - cpp: DecryptionResult::symkeyAlgo NEW. - cpp: Data::rewind NEW. + gpgme_decrypt_result_t EXTENDED: New field legacy_cipher_nomdc. + cpp: DecryptionResult::sessionKey NEW. + cpp: DecryptionResult::symkeyAlgo NEW. + cpp: Data::rewind NEW. + Noteworthy changes in version 1.11.1 (2018-04-20) ------------------------------------------------- diff --git a/doc/gpgme.texi b/doc/gpgme.texi index c745675b..d8771167 100644 --- a/doc/gpgme.texi +++ b/doc/gpgme.texi @@ -5368,7 +5368,7 @@ This is a pointer to a structure used to store the result of a data, you can retrieve the pointer to the result with @code{gpgme_op_decrypt_result}. As with all result structures, it this structure shall be considered read-only and an application must -not allocated such a strucure on its own. The structure contains the +not allocate such a strucure on its own. The structure contains the following members: @table @code @@ -5378,9 +5378,22 @@ algorithm that is not supported. @item unsigned int wrong_key_usage : 1 @since{0.9.0} - This is true if the key was not used according to its policy. +@item unsigned int legacy_cipher_nomdc : 1 +@since{1.11.2} +The message was made by a legacy algorithm without any integrity +protection. This might be an old but legitimate message. + +@item unsigned int is_mime : 1; +@since{1.11.0} +The message claims that the content is a MIME object. + +@item unsigned int is_de_vs : 1; +@since{1.10.0} +The message was encrypted in a VS-NfD compliant way. This is a +specification in Germany for a restricted communication level. + @item gpgme_recipient_t recipients @since{1.1.0} diff --git a/src/decrypt.c b/src/decrypt.c index 7dbc6fd6..f2278d8d 100644 --- a/src/decrypt.c +++ b/src/decrypt.c @@ -57,7 +57,7 @@ typedef struct int any_no_seckey; /* If the engine emits a DECRYPTION_INFO status and that does not - * indicate that an integrity proetction mode is active, this flag + * indicate that an integrity protection mode is active, this flag * is set. */ int not_integrity_protected; @@ -214,6 +214,11 @@ parse_status_error (char *args, op_data_t opd) break; } } + else if (!strcmp (field[0], "nomdc_with_legacy_cipher")) + { + opd->result.legacy_cipher_nomdc = 1; + opd->not_integrity_protected = 1; + } free (args2); diff --git a/src/gpgme.h.in b/src/gpgme.h.in index 49fafb90..5279f6a2 100644 --- a/src/gpgme.h.in +++ b/src/gpgme.h.in @@ -1365,8 +1365,12 @@ struct _gpgme_op_decrypt_result /* The message claims that the content is a MIME object. */ unsigned int is_mime : 1; + /* The message was made by a legacy algorithm without any integrity + * protection. This might be an old but legitimate message. */ + unsigned int legacy_cipher_nomdc : 1; + /* Internal to GPGME, do not use. */ - int _unused : 29; + int _unused : 28; gpgme_recipient_t recipients; diff --git a/tests/run-decrypt.c b/tests/run-decrypt.c index 69de139c..8ec0cb4f 100644 --- a/tests/run-decrypt.c +++ b/tests/run-decrypt.c @@ -55,6 +55,7 @@ print_result (gpgme_decrypt_result_t result) printf ("Original file name .: %s\n", nonnull(result->file_name)); printf ("Wrong key usage ....: %s\n", result->wrong_key_usage? "yes":"no"); + printf ("Legacy w/o MDC ... .: %s\n", result->legacy_cipher_nomdc?"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)); @@ -267,6 +268,8 @@ main (int argc, char **argv) if (err) { fprintf (stderr, PGM ": decrypt failed: %s\n", gpgme_strerror (err)); + if (result) + print_result (result); exit (1); } if (result)