aboutsummaryrefslogtreecommitdiffstats
path: root/g10/decrypt-data.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2024-06-24 14:31:24 +0000
committerWerner Koch <[email protected]>2024-06-24 14:31:40 +0000
commit1695cf267edf85bc451b59bf012083feb250bf59 (patch)
treecbd9cddb3b17e25106143ec02aaa3bf7ec705ceb /g10/decrypt-data.c
parentgpg: Rename recently added import option no-seckeys to only-pubkeys. (diff)
downloadgnupg-1695cf267edf85bc451b59bf012083feb250bf59.tar.gz
gnupg-1695cf267edf85bc451b59bf012083feb250bf59.zip
gpg: New option --show-only-session-key
* g10/options.h (opt): Add show_only_session_key and turn show_session_key into a bit flag. * g10/gpg.c (oShowOnlySessionKey): New. (opts): Add "show-only-session-key". (main): Set flag. * g10/mainproc.c (proc_encrypted): Handle the new option. * g10/decrypt-data.c (decrypt_data): Ditto. Add compliance error flag to the DECRYPTION_INFO status line. -- This new option is somehow related to GnuPG-bug-id: 1825
Diffstat (limited to 'g10/decrypt-data.c')
-rw-r--r--g10/decrypt-data.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/g10/decrypt-data.c b/g10/decrypt-data.c
index ea4d48955..81209f66f 100644
--- a/g10/decrypt-data.c
+++ b/g10/decrypt-data.c
@@ -263,11 +263,13 @@ decrypt_data (ctrl_t ctrl, void *procctx, PKT_encrypted *ed, DEK *dek,
/* Check compliance. */
if (!gnupg_cipher_is_allowed (opt.compliance, 0, dek->algo, ciphermode))
{
- log_error (_("cipher algorithm '%s' may not be used in %s mode\n"),
+ gpgrt_log (opt.show_only_session_key? GPGRT_LOGLVL_INFO
+ /* */: GPGRT_LOGLVL_ERROR,
+ _("cipher algorithm '%s' may not be used in %s mode\n"),
openpgp_cipher_algo_mode_name (dek->algo,ed->aead_algo),
gnupg_compliance_option_string (opt.compliance));
*compliance_error = 1;
- if (opt.flags.require_compliance)
+ if (opt.flags.require_compliance && !opt.show_only_session_key)
{
/* We fail early in this case because it does not make sense
* to first decrypt everything. */
@@ -276,8 +278,9 @@ decrypt_data (ctrl_t ctrl, void *procctx, PKT_encrypted *ed, DEK *dek,
}
}
- write_status_printf (STATUS_DECRYPTION_INFO, "%d %d %d",
- ed->mdc_method, dek->algo, ed->aead_algo);
+ write_status_printf (STATUS_DECRYPTION_INFO, "%d %d %d %d",
+ ed->mdc_method, dek->algo, ed->aead_algo,
+ *compliance_error);
if (opt.show_session_key)
{
@@ -297,6 +300,11 @@ decrypt_data (ctrl_t ctrl, void *procctx, PKT_encrypted *ed, DEK *dek,
log_info ("session key: '%s%s'\n", numbuf, hexbuf);
write_status_strings (STATUS_SESSION_KEY, numbuf, hexbuf, NULL);
xfree (hexbuf);
+ if (opt.show_only_session_key)
+ {
+ rc = 0;
+ goto leave;
+ }
}
rc = openpgp_cipher_test_algo (dek->algo);