1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Date: Wed, 05 Feb 2025 18:03:42 -0500
Subject: gpg: Always support and default to using SHA-512.
* g10/main.h (DEFAULT_DIGEST_ALGO): Use SHA512 instead of SHA256 in
standard modes. Use SHA256 for PGP8, and SHA1 for archaic modes.
* configure.ac: Do not allow disabling sha512.
* g10/misc.c (map_md_openpgp_to_gcry): Always support SHA512.
--
SHA512 is more performant on most 64-bit platforms than SHA256, and
offers a better security margin. It is also widely implemented.
RFC 4880 specifies SHA512, and any 4880-compatible client in the last
10 years supports it. According to doc/gpg.texi, PGP 8 supports
SHA256. There's no clear reason to default to SHA1 for compatibility
with those clients. (RFC 2440 and PGP7 don't support SHA256, so leave
that alone)
GnuPG-bug-id: 7516
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
---
configure.ac | 2 +-
g10/main.h | 2 +-
g10/misc.c | 5 +----
3 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/configure.ac b/configure.ac
index c80bce1..42ef43b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -339,7 +339,7 @@ GNUPG_GPG_DISABLE_ALGO([rmd160],[RIPE-MD160 hash])
GNUPG_GPG_DISABLE_ALGO([sha224],[SHA-224 hash])
# SHA256 is a MUST algorithm for GnuPG.
GNUPG_GPG_DISABLE_ALGO([sha384],[SHA-384 hash])
-GNUPG_GPG_DISABLE_ALGO([sha512],[SHA-512 hash])
+# SHA512 is a MUST algorithm for GnuPG.
# Allow disabling of zip support.
diff --git a/g10/main.h b/g10/main.h
index 2482fbd..f15d90f 100644
--- a/g10/main.h
+++ b/g10/main.h
@@ -41,7 +41,7 @@
# define DEFAULT_CIPHER_ALGO CIPHER_ALGO_3DES
#endif
-#define DEFAULT_DIGEST_ALGO ((GNUPG)? DIGEST_ALGO_SHA256:DIGEST_ALGO_SHA1)
+#define DEFAULT_DIGEST_ALGO ((PGP7||RFC2440)?DIGEST_ALGO_SHA1:((PGP8)?DIGEST_ALGO_SHA256:DIGEST_ALGO_SHA512))
#define DEFAULT_S2K_DIGEST_ALGO DEFAULT_DIGEST_ALGO
#ifdef HAVE_ZIP
# define DEFAULT_COMPRESS_ALGO COMPRESS_ALGO_ZIP
diff --git a/g10/misc.c b/g10/misc.c
index 2f4b452..0e6d9d5 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -862,11 +862,8 @@ map_md_openpgp_to_gcry (digest_algo_t algo)
case DIGEST_ALGO_SHA384: return 0;
#endif
-#ifdef GPG_USE_SHA512
case DIGEST_ALGO_SHA512: return GCRY_MD_SHA512;
-#else
- case DIGEST_ALGO_SHA512: return 0;
-#endif
+
default: return 0;
}
}
|