aboutsummaryrefslogtreecommitdiffstats
path: root/g10/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'g10/misc.c')
-rw-r--r--g10/misc.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/g10/misc.c b/g10/misc.c
index 67a2f1928..c7107be06 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -331,12 +331,11 @@ print_cipher_algo_note (cipher_algo_t algo)
void
print_digest_algo_note (digest_algo_t algo)
{
- 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;
+ const enum gcry_md_algos galgo = map_md_openpgp_to_gcry (algo);
+
if(!warn)
{
warn=1;
@@ -345,14 +344,13 @@ print_digest_algo_note (digest_algo_t algo)
gcry_md_algo_name (galgo));
}
}
- else
- for (weak = opt.weak_digests; weak != NULL; weak = weak->next)
- if (weak->algo == galgo)
- {
- es_fflush (es_stdout);
- log_info (_("WARNING: digest algorithm %s is deprecated\n"),
- gcry_md_algo_name (galgo));
- }
+ else if (is_weak_digest (algo))
+ {
+ const enum gcry_md_algos galgo = map_md_openpgp_to_gcry (algo);
+ es_fflush (es_stdout);
+ log_info (_("WARNING: digest algorithm %s is deprecated\n"),
+ gcry_md_algo_name (galgo));
+ }
}
@@ -1908,3 +1906,17 @@ additional_weak_digest (const char* digestname)
weak->next = opt.weak_digests;
opt.weak_digests = weak;
}
+
+
+/* Return true if ALGO is in the list of weak digests. */
+int
+is_weak_digest (digest_algo_t algo)
+{
+ const enum gcry_md_algos galgo = map_md_openpgp_to_gcry (algo);
+ const struct weakhash *weak;
+
+ for (weak = opt.weak_digests; weak; weak = weak->next)
+ if (weak->algo == galgo)
+ return 1;
+ return 0;
+}