From 4e2ba546cdccbbc6d3e29867ee5671fd44d74e67 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 10 Jan 2018 17:07:11 +0100 Subject: gpg: New option --force-aead * g10/dek.h (DEK): Turn fields use_mdc, algo_printed and symmetric into single bit vars. Make sure they are always set to 1 or 0. (DEK): New field use_aead. * g10/options.h (struct opt): New field force_aead. * g10/pkclist.c (select_aead_from_pklist): New. * g10/gpg.c (oForceAEAD): New const. (opts): New options "--force-aead". (main): Set new option. * g10/encrypt.c (use_aead): New. (encrypt_simple): Implement new flags DEK.use_aead. (encrypt_crypt): Ditto. (encrypt_filter): Ditto. * g10/sign.c (sign_symencrypt_file): Ditto. -- This patch should be enough to detect whether AEAD can be used. Not tested. Signed-off-by: Werner Koch --- g10/pkclist.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'g10/pkclist.c') diff --git a/g10/pkclist.c b/g10/pkclist.c index a759672ab..b85efa4cd 100644 --- a/g10/pkclist.c +++ b/g10/pkclist.c @@ -1651,6 +1651,31 @@ select_mdc_from_pklist (PK_LIST pk_list) } +/* Select the AEAD flag from the pk_list. We can only use AEAD if all + * recipients support this feature. Returns true if AEAD can be used. */ +int +select_aead_from_pklist (PK_LIST pk_list) +{ + pk_list_t pkr; + int aead; + + if (!pk_list) + return 0; + + for (pkr = pk_list; pkr; pkr = pkr->next) + { + if (pkr->pk->user_id) /* selected by user ID */ + aead = pkr->pk->user_id->flags.aead; + else + aead = pkr->pk->flags.aead; + if (!aead) + return 0; /* At least one recipient does not support it. */ + } + + return 1; /* Can be used. */ +} + + /* Print a warning for all keys in PK_LIST missing the MDC feature. */ void warn_missing_mdc_from_pklist (PK_LIST pk_list) -- cgit v1.2.3