Skip to contentSkip to conversation

crypto: remove md4 driver

PATCH In review Dimitri John Ledkov 3 participants 6 messages Oct 8, 2023 – Oct 14, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: remove md4 driver

No internal users left and cryptographically insecure. Users should upgrade to something else, e.g. sha256 blake3.

Some drivers have their own full or partial md4 implementation without using crypto/md4.

Userspace code search indicates a few copies of hash_info.h
https://codesearch.debian.net/search?q=HASH_ALGO_MD4&literal=1 without need for MD4.

Preserve uapi hash algorithm indexes and array length, but rename the MD4 enum.

---
 crypto/Kconfig                 |   6 -
 crypto/Makefile                |   1 -
 crypto/hash_info.c             |   4 +-
 crypto/md4.c                   | 241 ---------------------------------
 crypto/tcrypt.c                |  12 --
 crypto/testmgr.c               |   6 -
 crypto/testmgr.h               |  42 ------
 include/uapi/linux/hash_info.h |   2 +-
 8 files changed, 3 insertions(+), 311 deletions(-)
 delete mode 100644 crypto/md4.c
crypto/Kconfig +0 -6
index 650b1b3620..7d293a1ae8 100644
@@ -946,12 +946,6 @@ config CRYPTO_HMAC
 
 	  This is required for IPsec AH (XFRM_AH) and IPsec ESP (XFRM_ESP).
 
-config CRYPTO_MD4
-	tristate "MD4"
-	select CRYPTO_HASH
-	help
-	  MD4 message digest algorithm (RFC1320)
-
 config CRYPTO_MD5
 	tristate "MD5"
 	select CRYPTO_HASH
crypto/Makefile +0 -1
index 953a7e105e..67473c6fd1 100644
@@ -72,7 +72,6 @@ obj-$(CONFIG_CRYPTO_HMAC) += hmac.o
 obj-$(CONFIG_CRYPTO_VMAC) += vmac.o
 obj-$(CONFIG_CRYPTO_XCBC) += xcbc.o
 obj-$(CONFIG_CRYPTO_NULL2) += crypto_null.o
-obj-$(CONFIG_CRYPTO_MD4) += md4.o
 obj-$(CONFIG_CRYPTO_MD5) += md5.o
 obj-$(CONFIG_CRYPTO_RMD160) += rmd160.o
 obj-$(CONFIG_CRYPTO_SHA1) += sha1_generic.o
crypto/hash_info.c +2 -2
index a49ff96bde..7591ab8d48 100644
@@ -9,7 +9,7 @@
 #include <crypto/hash_info.h>
 
 const char *const hash_algo_name[HASH_ALGO__LAST] = {
-	[HASH_ALGO_MD4]		= "md4",
+	[__REMOVED_HASH_ALGO_MD4] = "",
 	[HASH_ALGO_MD5]		= "md5",
 	[HASH_ALGO_SHA1]	= "sha1",
 	[HASH_ALGO_RIPE_MD_160]	= "rmd160",
@@ -33,7 +33,7 @@ const char *const hash_algo_name[HASH_ALGO__LAST] = {
 EXPORT_SYMBOL_GPL(hash_algo_name);
 
 const int hash_digest_size[HASH_ALGO__LAST] = {
-	[HASH_ALGO_MD4]		= MD5_DIGEST_SIZE,
+	[__REMOVED_HASH_ALGO_MD4] = 0,
 	[HASH_ALGO_MD5]		= MD5_DIGEST_SIZE,
 	[HASH_ALGO_SHA1]	= SHA1_DIGEST_SIZE,
 	[HASH_ALGO_RIPE_MD_160]	= RMD160_DIGEST_SIZE,
crypto/md4.c deleted +0 -241

241 lines not on this page · raw message

crypto/tcrypt.c +0 -12
index 202ca1a310..22fde782d4 100644
@@ -1487,10 +1487,6 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb)
 		ret = min(ret, tcrypt_test("ctr(des3_ede)"));
 		break;
 
-	case 5:
-		ret = min(ret, tcrypt_test("md4"));
-		break;
-
 	case 6:
 		ret = min(ret, tcrypt_test("sha256"));
 		break;
@@ -2228,10 +2224,6 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb)
 			break;
 		}
 		fallthrough;
-	case 301:
-		test_hash_speed("md4", sec, generic_hash_speed_template);
-		if (mode > 300 && mode < 400) break;
-		fallthrough;
 	case 302:
 		test_hash_speed("md5", sec, generic_hash_speed_template);
 		if (mode > 300 && mode < 400) break;
@@ -2336,10 +2328,6 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb)
 			break;
 		}
 		fallthrough;
-	case 401:
-		test_ahash_speed("md4", sec, generic_hash_speed_template);
-		if (mode > 400 && mode < 500) break;
-		fallthrough;
 	case 402:
 		test_ahash_speed("md5", sec, generic_hash_speed_template);
 		if (mode > 400 && mode < 500) break;
crypto/testmgr.c +0 -6
index 216878c8bc..7b1e4cf0fb 100644
@@ -5399,12 +5399,6 @@ static const struct alg_test_desc alg_test_descs[] = {
 				.decomp = __VECS(lzorle_decomp_tv_template)
 			}
 		}
-	}, {
-		.alg = "md4",
-		.test = alg_test_hash,
-		.suite = {
-			.hash = __VECS(md4_tv_template)
-		}
 	}, {
 		.alg = "md5",
 		.test = alg_test_hash,
crypto/testmgr.h +0 -42

48 lines not on this page · raw message

include/uapi/linux/hash_info.h +1 -1
index 74a8609fcb..c8500e9c88 100644
@@ -15,7 +15,7 @@
 #define _UAPI_LINUX_HASH_INFO_H
 
 enum hash_algo {
-	HASH_ALGO_MD4,
+	__REMOVED_HASH_ALGO_MD4, /* deprecated and removed */
 	HASH_ALGO_MD5,
 	HASH_ALGO_SHA1,
 	HASH_ALGO_RIPE_MD_160,
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 14 lines · Dimitri John Ledkov

No internal users left and cryptographically insecure. Users should upgrade to something else, e.g. sha256 blake3.

Some drivers have their own full or partial md4 implementation without using crypto/md4.

Userspace code search indicates a few copies of hash_info.h
https://codesearch.debian.net/search?q=HASH_ALGO_MD4&literal=1 without need for MD4.

Preserve uapi hash algorithm indexes and array length, but rename the MD4 enum.

Quoted 11 lines
---
 crypto/Kconfig                 |   6 -
 crypto/Makefile                |   1 -
 crypto/hash_info.c             |   4 +-
 crypto/md4.c                   | 241 ---------------------------------
 crypto/tcrypt.c                |  12 --
 crypto/testmgr.c               |   6 -
 crypto/testmgr.h               |  42 ------
 include/uapi/linux/hash_info.h |   2 +-
 8 files changed, 3 insertions(+), 311 deletions(-)
 delete mode 100644 crypto/md4.c

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#2 lore raw

Hi Herbert,

Quoted 27 lines · Herbert Xu
Quoted 24 lines · Dimitri John Ledkov

No internal users left and cryptographically insecure. Users should upgrade to something else, e.g. sha256 blake3.

Some drivers have their own full or partial md4 implementation without using crypto/md4.

Userspace code search indicates a few copies of hash_info.h
https://codesearch.debian.net/search?q=HASH_ALGO_MD4&literal=1 without need for MD4.

Preserve uapi hash algorithm indexes and array length, but rename the MD4 enum.

---
  crypto/Kconfig                 |   6 -
  crypto/Makefile                |   1 -
  crypto/hash_info.c             |   4 +-
  crypto/md4.c                   | 241 ---------------------------------
  crypto/tcrypt.c                |  12 --
  crypto/testmgr.c               |   6 -
  crypto/testmgr.h               |  42 ------
  include/uapi/linux/hash_info.h |   2 +-
  8 files changed, 3 insertions(+), 311 deletions(-)
Quoted 1 line

delete mode 100644 crypto/md4.c

Quoted 1 line

Patch applied. Thanks.

Does this patch break userspace?

Here's a thread regarding MD4 the last time its removal was attempted:
https://lore.kernel.org/linux-crypto/[email protected]/

Please note that iwd does use MD4 hashes here:
https://git.kernel.org/pub/scm/libs/ell/ell.git/tree/ell/checksum.c#n63

https://git.kernel.org/pub/scm/network/wireless/iwd.git/tree/src/eap-mschapv2.c#n165

Regards,
-Denis

#3 lore raw
Quoted 31 lines · Denis Kenzior

Hi Herbert,

Quoted 27 lines · Herbert Xu
Quoted 25 lines · Dimitri John Ledkov

No internal users left and cryptographically insecure. Users should upgrade to something else, e.g. sha256 blake3.

Some drivers have their own full or partial md4 implementation without using crypto/md4.

Userspace code search indicates a few copies of hash_info.h
https://codesearch.debian.net/search?q=HASH_ALGO_MD4&literal=1 without need for MD4.

Preserve uapi hash algorithm indexes and array length, but rename the MD4 enum.

---
  crypto/Kconfig                 |   6 -
  crypto/Makefile                |   1 -
  crypto/hash_info.c             |   4 +-
  crypto/md4.c                   | 241 ---------------------------------
  crypto/tcrypt.c                |  12 --
  crypto/testmgr.c               |   6 -
  crypto/testmgr.h               |  42 ------
  include/uapi/linux/hash_info.h |   2 +-
  8 files changed, 3 insertions(+), 311 deletions(-)

delete mode 100644 crypto/md4.c

Quoted 3 lines
Quoted 1 line

Patch applied. Thanks.

Does this patch break userspace?

I will check all of the below and get back to you.

Quoted 11 lines

Here's a thread regarding MD4 the last time its removal was attempted:
https://lore.kernel.org/linux-crypto/[email protected]/

Please note that iwd does use MD4 hashes here:
https://git.kernel.org/pub/scm/libs/ell/ell.git/tree/ell/checksum.c#n63

https://git.kernel.org/pub/scm/network/wireless/iwd.git/tree/src/eap-mschapv2.c#n165

Regards,
-Denis

Signature · 3 lines
okurrr,

Dimitri
maintainer
#4 lore raw
In reply to Denis Kenzior
Quoted 10 lines · Denis Kenzior

Does this patch break userspace?

Here's a thread regarding MD4 the last time its removal was attempted:
https://lore.kernel.org/linux-crypto/[email protected]/

Please note that iwd does use MD4 hashes here:
https://git.kernel.org/pub/scm/libs/ell/ell.git/tree/ell/checksum.c#n63

https://git.kernel.org/pub/scm/network/wireless/iwd.git/tree/src/eap-mschapv2.c#n165

I've backed this out for now.

Thanks,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#5 lore raw
In reply to Denis Kenzior
Quoted 35 lines · Denis Kenzior

Hi Herbert,

Quoted 27 lines · Herbert Xu
Quoted 24 lines · Dimitri John Ledkov

No internal users left and cryptographically insecure. Users should upgrade to something else, e.g. sha256 blake3.

Some drivers have their own full or partial md4 implementation without using crypto/md4.

Userspace code search indicates a few copies of hash_info.h
https://codesearch.debian.net/search?q=HASH_ALGO_MD4&literal=1 without need for MD4.

Preserve uapi hash algorithm indexes and array length, but rename the MD4 enum.

---
  crypto/Kconfig                 |   6 -
  crypto/Makefile                |   1 -
  crypto/hash_info.c             |   4 +-
  crypto/md4.c                   | 241 ---------------------------------
  crypto/tcrypt.c                |  12 --
  crypto/testmgr.c               |   6 -
  crypto/testmgr.h               |  42 ------
  include/uapi/linux/hash_info.h |   2 +-
  8 files changed, 3 insertions(+), 311 deletions(-)
Quoted 1 line

delete mode 100644 crypto/md4.c

Quoted 1 line

Patch applied. Thanks.

Does this patch break userspace?

Quoted 8 lines

Here's a thread regarding MD4 the last time its removal was attempted:
https://lore.kernel.org/linux-crypto/[email protected]/

Please note that iwd does use MD4 hashes here:
https://git.kernel.org/pub/scm/libs/ell/ell.git/tree/ell/checksum.c#n63

https://git.kernel.org/pub/scm/network/wireless/iwd.git/tree/src/eap-mschapv2.c#n165

Thank you for this reference. The WiFI eap mschapv2 based authentication indeed relies on MD4. The IWD code uses kernel as a basically impromptu userspace library to gain access to MD4, which sounds like a poor way of doing this. In comparison NetworkManager uses userspace crypto libraries to compute that.

Note that iwd has an alternative code path of using md4 hashed password, meaning it does still work on kernels without MD4.

It worries me a lot that this is still in active use.

MS-CHAPv2 has been completely broken since 2012 with a cloud service at the time offered to automatically crack any communication. It is insecure, does not provide any confidentiality, and worse off allows to steal & reuse credentials to later impersonate the original user. It is worse than unencrypted WiFi in that sense. Even Windows 11 since at least 22H2 release prohibits such connections. I will propose patches to IWD to stop using the md5 crypto kernel interface. As much as it is convenient, users of insecure & obsolete cryptography must not hold up removal of such methods from the kernel.

Signature · 3 lines
okurrr,

Dimitri