diff options
author | Werner Koch <[email protected]> | 2020-11-02 12:39:58 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2020-11-02 12:45:19 +0000 |
commit | 15746d60d492f5792e4a179ab0a08801b4049695 (patch) | |
tree | b628736e3c40487352de01a8baff28829cf3d195 /g10/sign.c | |
parent | gpg: Fix iteration over signatures (diff) | |
download | gnupg-15746d60d492f5792e4a179ab0a08801b4049695.tar.gz gnupg-15746d60d492f5792e4a179ab0a08801b4049695.zip |
gpg: Do not use weak digest algos if selected by recipient prefs.
* g10/misc.c (is_weak_digest): New.
(print_digest_algo_note): Use it here.
* g10/sig-check.c (check_signature_end_simple): Use it.
* g10/sign.c (hash_for): Do not use recipient_digest_algo if it is in
the least of weak digest algorithm.
--
If a message is signed and encrypted to several recipients, the to be
used digest algorithm is deduced from the preferences of the
recipient. This is so that all recipients are able to check the the
signature. However, if the sender has a declared an algorithm as
week, that algorithm shall not be used - in this case we fallback to
the standard way of selecting an algorithm.
Note that a smarter way of selecting the algo is to check this while
figuring out the algorithm - this needs more testing and thus we do it
the simple way.
Reported-by: Phil Pennock
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'g10/sign.c')
-rw-r--r-- | g10/sign.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/g10/sign.c b/g10/sign.c index 9fa11c564..d92531eb2 100644 --- a/g10/sign.c +++ b/g10/sign.c @@ -646,7 +646,7 @@ hash_for (PKT_public_key *pk) { return opt.def_digest_algo; } - else if (recipient_digest_algo) + else if (recipient_digest_algo && !is_weak_digest (recipient_digest_algo)) { return recipient_digest_algo; } @@ -1204,6 +1204,7 @@ sign_file (ctrl_t ctrl, strlist_t filenames, int detached, strlist_t locusr, && ((algo = select_algo_from_prefs (pk_list, PREFTYPE_HASH, -1, &hint)) > 0)) { + /* Note that we later check that the algo is not weak. */ recipient_digest_algo = algo; } } |