diff options
author | Daniel Kahn Gillmor <[email protected]> | 2015-10-18 21:35:32 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2015-10-19 12:24:27 +0000 |
commit | 76afaed65e3b0ddfa4923cb577ada43217dd4b18 (patch) | |
tree | 6d4e201bbb13c88b29aaafe9b4eef3dfadf87d3f /g10/misc.c | |
parent | dirmngr: Make --use-tor work - still leaks DNS. (diff) | |
download | gnupg-76afaed65e3b0ddfa4923cb577ada43217dd4b18.tar.gz gnupg-76afaed65e3b0ddfa4923cb577ada43217dd4b18.zip |
gpg: Add option --weak-digest to gpg and gpgv.
* g10/options.h: Add additional_weak_digests linked list to opts.
* g10/main.h: Declare weakhash linked list struct and
additional_weak_digest() function to insert newly-declared weak
digests into opts.
* g10/misc.c: (additional_weak_digest): New function.
(print_digest_algo_note): Check for deprecated digests; use proper
gcry_md_algos type.
* g10/sig-check.c: (do_check): Reject weak digests in addition to MD5.
* g10/gpg.c: Add --weak-digest option to gpg.
* doc/gpg.texi: Document gpg --weak-digest option.
* g10/gpgv.c: Add --weak-digest option to gpgv.
* doc/gpgv.texi: Document gpgv --weak-digest option.
--
gpg and gpgv treat signatures made over MD5 as unreliable, unless the
user supplies --allow-weak-digests to gpg. Signatures over any other
digest are considered acceptable.
Despite SHA-1 being a mandatory-to-implement digest algorithm in RFC
4880, the collision-resistance of SHA-1 is weaker than anyone would
like it to be.
Some operators of high-value targets that depend on OpenPGP signatures
may wish to require their signers to use a stronger digest algorithm
than SHA1, even if the OpenPGP ecosystem at large cannot deprecate
SHA1 entirely today.
This changeset adds a new "--weak-digest DIGEST" option for both gpg
and gpgv, which makes it straightforward for anyone to treat any
signature or certification made over the specified digest as
unreliable.
This option can be supplied multiple times if the operator wishes to
deprecate multiple digest algorithms, and will be ignored completely
if the operator supplies --allow-weak-digests (as before).
MD5 is still always considered weak, regardless of any further
--weak-digest options supplied.
Signed-off-by: Daniel Kahn Gillmor <[email protected]>
Capitialized some comments, shorted a line in do_check, and changed
subject to name the option. -wk
Diffstat (limited to 'g10/misc.c')
-rw-r--r-- | g10/misc.c | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/g10/misc.c b/g10/misc.c index 9134b2823..c135059d8 100644 --- a/g10/misc.c +++ b/g10/misc.c @@ -307,6 +307,10 @@ print_cipher_algo_note (cipher_algo_t algo) void print_digest_algo_note (digest_algo_t algo) { + int deprecated = 0; + const enum gcry_md_algos galgo = map_md_openpgp_to_gcry (algo); + const struct weakhash *weak; + if(algo >= 100 && algo <= 110) { static int warn=0; @@ -315,14 +319,21 @@ print_digest_algo_note (digest_algo_t algo) warn=1; es_fflush (es_stdout); log_info (_("WARNING: using experimental digest algorithm %s\n"), - gcry_md_algo_name (algo)); + gcry_md_algo_name (galgo)); } } - else if(algo==DIGEST_ALGO_MD5) + else if(algo == DIGEST_ALGO_MD5) + deprecated = 1; + else + for (weak = opt.additional_weak_digests; weak != NULL; weak = weak->next) + if (weak->algo == galgo) + deprecated = 1; + + if (deprecated) { es_fflush (es_stdout); log_info (_("WARNING: digest algorithm %s is deprecated\n"), - gcry_md_algo_name (algo)); + gcry_md_algo_name (galgo)); } } @@ -1676,3 +1687,37 @@ ecdsa_qbits_from_Q (unsigned int qbits) qbits /= 2; return qbits; } + + +/* Ignore signatures and certifications made over certain digest + * algorithms by default, MD5 is considered weak. This allows users + * to deprecate support for other algorithms as well. + */ +void +additional_weak_digest (const char* digestname) +{ + struct weakhash *weak = NULL; + const enum gcry_md_algos algo = string_to_digest_algo(digestname); + + if (algo == GCRY_MD_MD5) + return; /* MD5 is always considered weak, no need to add it. */ + + if (algo == GCRY_MD_NONE) + { + log_error(_("Unknown weak digest '%s'\n"), digestname); + return; + } + + /* Check to ensure it's not already present. */ + for (weak = opt.additional_weak_digests; weak != NULL; weak = weak->next) + { + if (algo == weak->algo) + return; + } + + /* Add it to the head of the list. */ + weak = xmalloc(sizeof(*weak)); + weak->algo = algo; + weak->next = opt.additional_weak_digests; + opt.additional_weak_digests = weak; +} |