1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-03 22:56:33 +02:00

gpg: Allow decryption of symencr even for non-compliant cipher.

* g10/decrypt-data.c (decrypt_data): Add arg compliance_error.  Adjust
all callers.  Fail on compliance error only in --require-compliance
mode.  Make sure to return an error if the buffer is missing; actually
that should be an assert.
* g10/mainproc.c (proc_encrypted): Delay printing of the compliance
mode status.  Consult the compliance error now returned by
decrypt_data.
--

The actual case here is that we fail hard if a message has been AEAD
encrypted with one AEAD capable key and also with one passphrase.  In
general the preference system takes care of not using AEAD if one
recipient's key does not support it.  However, if the sender uses her
own AEAD-capable key _and_ a passphrase the message will be AEAD
encrypted.  This change allows to decrypt that anyway along with a
warning message.

Note that this does currently not work in 2.3 due to a non-compliant
libgcrypt.  We will however, backport this to 2.2.
This commit is contained in:
Werner Koch 2022-03-18 11:13:23 +01:00
parent 7ba44d15ca
commit e081a601f7
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
5 changed files with 47 additions and 18 deletions

View file

@ -762,17 +762,18 @@ proc_encrypted (CTX c, PACKET *pkt)
xfree (pk);
if (compliant)
{
write_status_strings (STATUS_DECRYPTION_COMPLIANCE_MODE,
gnupg_status_compliance_flag (CO_DE_VS),
NULL);
compliance_de_vs |= 1;
}
compliance_de_vs |= 1;
}
if (!result)
result = decrypt_data (c->ctrl, c, pkt->pkt.encrypted, c->dek );
{
int compl_error;
result = decrypt_data (c->ctrl, c, pkt->pkt.encrypted, c->dek,
&compl_error);
if (!result && !compl_error)
compliance_de_vs |= 2;
}
/* Trigger the deferred error. */
if (!result && early_plaintext)
@ -825,12 +826,12 @@ proc_encrypted (CTX c, PACKET *pkt)
if (pkt->pkt.encrypted->aead_algo)
{
write_status (STATUS_GOODMDC);
compliance_de_vs |= 2;
compliance_de_vs |= 4;
}
else if (pkt->pkt.encrypted->mdc_method && !result)
{
write_status (STATUS_GOODMDC);
compliance_de_vs |= 2;
compliance_de_vs |= 4;
}
else
log_info (_("WARNING: message was not integrity protected\n"));
@ -862,6 +863,16 @@ proc_encrypted (CTX c, PACKET *pkt)
* ways to specify the session key (symmmetric and PK). */
}
/* If we concluded that the decryption was compliant, issue a
* compliance status before the thed end of decryption status. */
if (compliance_de_vs == (4|2|1))
{
write_status_strings (STATUS_DECRYPTION_COMPLIANCE_MODE,
gnupg_status_compliance_flag (CO_DE_VS),
NULL);
}
xfree (c->dek);
c->dek = NULL;
free_packet (pkt, NULL);
@ -878,7 +889,7 @@ proc_encrypted (CTX c, PACKET *pkt)
* de-vs compliance mode by just looking at the exit status. */
if (opt.flags.require_compliance
&& opt.compliance == CO_DE_VS
&& compliance_de_vs != (2|1))
&& compliance_de_vs != (4|2|1))
{
log_error (_("operation forced to fail due to"
" unfulfilled compliance rules\n"));