aboutsummaryrefslogtreecommitdiffstats
path: root/g10/misc.c
diff options
context:
space:
mode:
authorDaniel Kahn Gillmor <[email protected]>2015-10-23 21:46:57 +0000
committerWerner Koch <[email protected]>2015-10-26 15:56:56 +0000
commit91015d021b3dcbe21ad0e580a4f34c523abf9e72 (patch)
treeb01eb463119fa01aacb6a191e2cbbbe9521c951c /g10/misc.c
parentw32: Make it build again if Tofu support is not available. (diff)
downloadgnupg-91015d021b3dcbe21ad0e580a4f34c523abf9e72.tar.gz
gnupg-91015d021b3dcbe21ad0e580a4f34c523abf9e72.zip
gpg: Ensure all weak digest rejection notices are shown
* g10/main.h: Add rejection_shown flag to each weakhash struct * g10/misc.c (print_digest_algo_note, additional_weak_digest): Do not treat MD5 separately; (print_digest_rejected_note): Use weakhash.rejection_shown instead of static shown. * g10/options.h (opt): Change from additional_weak_digests to weak_digests. * g10/sig-check.c: Do not treat MD5 separately. * g10/gpg.c (main): Explicitly set MD5 as weak. * g10/gpgv.c (main): Explicitly set MD5 as weak. -- Previously, only one weak digest rejection message was shown, of whichever was the first type encountered. This meant that if "gpg --weak-digest SHA224" encountered both an MD5 digest and a SHA224 digest, it would only show the user that the MD5 digest was rejected. In order to let the user know which algorithms were rejected, we needed to move the "shown" flag into a per-weak-algorithm location. Given this additional complication, it made no sense to continue to treat MD5 specially, so it is added as a default weak algorithm in the same opt.weak_digests data structure as any other. Signed-Off-By: Daniel Kahn Gillmor <[email protected]>
Diffstat (limited to '')
-rw-r--r--g10/misc.c51
1 files changed, 25 insertions, 26 deletions
diff --git a/g10/misc.c b/g10/misc.c
index 93ddaa042..5c77714d3 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -307,7 +307,6 @@ 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;
@@ -322,34 +321,38 @@ print_digest_algo_note (digest_algo_t algo)
gcry_md_algo_name (galgo));
}
}
- else if(algo == DIGEST_ALGO_MD5)
- deprecated = 1;
else
- for (weak = opt.additional_weak_digests; weak != NULL; weak = weak->next)
+ for (weak = opt.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 (galgo));
- }
+ {
+ es_fflush (es_stdout);
+ log_info (_("WARNING: digest algorithm %s is deprecated\n"),
+ gcry_md_algo_name (galgo));
+ }
}
void
print_digest_rejected_note (enum gcry_md_algos algo)
{
- static int shown;
-
- if (!shown)
+ struct weakhash* weak;
+ int show = 1;
+ for (weak = opt.weak_digests; weak; weak = weak->next)
+ if (weak->algo == algo)
+ {
+ if (weak->rejection_shown)
+ show = 0;
+ else
+ weak->rejection_shown = 1;
+ break;
+ }
+
+ if (show)
{
es_fflush (es_stdout);
log_info
(_("Note: signatures using the %s algorithm are rejected\n"),
gcry_md_algo_name(algo));
- shown = 1;
}
}
@@ -1699,9 +1702,6 @@ 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);
@@ -1709,15 +1709,14 @@ additional_weak_digest (const char* digestname)
}
/* Check to ensure it's not already present. */
- for (weak = opt.additional_weak_digests; weak != NULL; weak = weak->next)
- {
- if (algo == weak->algo)
- return;
- }
+ for (weak = opt.weak_digests; weak; 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;
+ weak->rejection_shown = 0;
+ weak->next = opt.weak_digests;
+ opt.weak_digests = weak;
}