diff --git a/g10/decrypt-data.c b/g10/decrypt-data.c index 6c1d6ebcd..bdc3e2214 100644 --- a/g10/decrypt-data.c +++ b/g10/decrypt-data.c @@ -242,10 +242,8 @@ decrypt_data (ctrl_t ctrl, void *procctx, PKT_encrypted *ed, DEK *dek, if ( opt.verbose && !dek->algo_info_printed ) { if (!openpgp_cipher_test_algo (dek->algo)) - log_info (_("%s.%s encrypted data\n"), - openpgp_cipher_algo_name (dek->algo), - ed->aead_algo? openpgp_aead_algo_name (ed->aead_algo) - /**/ : "CFB"); + log_info (_("%s encrypted data\n"), + openpgp_cipher_algo_mode_name (dek->algo, ed->aead_algo)); else log_info (_("encrypted with unknown algorithm %d\n"), dek->algo ); dek->algo_info_printed = 1; @@ -265,7 +263,7 @@ decrypt_data (ctrl_t ctrl, void *procctx, PKT_encrypted *ed, DEK *dek, if (!gnupg_cipher_is_allowed (opt.compliance, 0, dek->algo, ciphermode)) { log_error (_("cipher algorithm '%s' may not be used in %s mode\n"), - openpgp_cipher_algo_name (dek->algo), + openpgp_cipher_algo_mode_name (dek->algo,ed->aead_algo), gnupg_compliance_option_string (opt.compliance)); *compliance_error = 1; if (opt.flags.require_compliance) diff --git a/g10/main.h b/g10/main.h index e5308744a..0525732f2 100644 --- a/g10/main.h +++ b/g10/main.h @@ -126,6 +126,8 @@ enum gcry_cipher_algos map_cipher_openpgp_to_gcry (cipher_algo_t algo); int openpgp_cipher_blocklen (cipher_algo_t algo); int openpgp_cipher_test_algo(cipher_algo_t algo); const char *openpgp_cipher_algo_name (cipher_algo_t algo); +const char *openpgp_cipher_algo_mode_name (cipher_algo_t algo, + aead_algo_t aead); gpg_error_t openpgp_aead_test_algo (aead_algo_t algo); const char *openpgp_aead_algo_name (aead_algo_t algo); diff --git a/g10/misc.c b/g10/misc.c index 2a431b137..581601209 100644 --- a/g10/misc.c +++ b/g10/misc.c @@ -614,6 +614,19 @@ openpgp_cipher_algo_name (cipher_algo_t algo) } +/* Same as openpgp_cipher_algo_name but returns a string in the form + * "ALGO.MODE". If AEAD is 0 "CFB" is used for the mode. */ +const char * +openpgp_cipher_algo_mode_name (cipher_algo_t algo, aead_algo_t aead) +{ + return map_static_strings ("openpgp_cipher_algo_mode_name", algo, aead, + openpgp_cipher_algo_name (algo), + ".", + aead? openpgp_aead_algo_name (aead) : "CFB", + NULL); +} + + /* Return 0 if ALGO is supported. Return an error if not. */ gpg_error_t openpgp_aead_test_algo (aead_algo_t algo)