diff options
author | Werner Koch <[email protected]> | 2018-01-10 16:07:11 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2018-01-10 16:07:11 +0000 |
commit | 4e2ba546cdccbbc6d3e29867ee5671fd44d74e67 (patch) | |
tree | ed822c35d3c88ba22a4754e2765a02a928e1a6ef /g10/pkclist.c | |
parent | gpg: Add option and preference framework for AEAD. (diff) | |
download | gnupg-4e2ba546cdccbbc6d3e29867ee5671fd44d74e67.tar.gz gnupg-4e2ba546cdccbbc6d3e29867ee5671fd44d74e67.zip |
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 <[email protected]>
Diffstat (limited to 'g10/pkclist.c')
-rw-r--r-- | g10/pkclist.c | 25 |
1 files changed, 25 insertions, 0 deletions
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) |