Skip to content

Commit 9ace677

Browse files
ardbiesheuvelherbertx
authored andcommitted
crypto: arc4 - mark ecb(arc4) skcipher as obsolete
Cryptographic algorithms may have a lifespan that is significantly shorter than Linux's, and so we need to start phasing out algorithms that are known to be broken, and are no longer fit for general use. RC4 (or arc4) is a good example here: there are a few areas where its use is still somewhat acceptable, e.g., for interoperability with legacy wifi hardware that can only use WEP or TKIP data encryption, but that should not imply that, for instance, use of RC4 based EAP-TLS by the WPA supplicant for negotiating TKIP keys is equally acceptable, or that RC4 should remain available as a general purpose cryptographic transform for all in-kernel and user space clients. Now that all in-kernel users that need to retain support have moved to the arc4 library interface, and the known users of ecb(arc4) via the socket API (iwd [0] and libell [1][2]) have been updated to switch to a local implementation, we can take the next step, and mark the ecb(arc4) skcipher as obsolete, and only provide it if the socket API is enabled in the first place, as well as provide the option to disable all algorithms that have been marked as obsolete. [0] https://git.kernel.org/pub/scm/network/wireless/iwd.git/commit/?id=1db8a85a60c64523 [1] https://git.kernel.org/pub/scm/libs/ell/ell.git/commit/?id=53482ce421b727c2 [2] https://git.kernel.org/pub/scm/libs/ell/ell.git/commit/?id=7f6a137809d42f6b Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 274290e commit 9ace677

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

‎crypto/Kconfig‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,7 @@ config CRYPTO_ANUBIS
11991199

12001200
config CRYPTO_ARC4
12011201
tristate "ARC4 cipher algorithm"
1202+
depends on CRYPTO_USER_API_ENABLE_OBSOLETE
12021203
select CRYPTO_SKCIPHER
12031204
select CRYPTO_LIB_ARC4
12041205
help
@@ -1881,6 +1882,15 @@ config CRYPTO_USER_API_AEAD
18811882
This option enables the user-spaces interface for AEAD
18821883
cipher algorithms.
18831884

1885+
config CRYPTO_USER_API_ENABLE_OBSOLETE
1886+
bool "Enable obsolete cryptographic algorithms for userspace"
1887+
depends on CRYPTO_USER_API
1888+
default y
1889+
help
1890+
Allow obsolete cryptographic algorithms to be selected that have
1891+
already been phased out from internal use by the kernel, and are
1892+
only useful for userspace clients that still rely on them.
1893+
18841894
config CRYPTO_STATS
18851895
bool "Crypto usage statistics for User-space"
18861896
depends on CRYPTO_USER

‎crypto/arc4.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
#include <crypto/arc4.h>
1212
#include <crypto/internal/skcipher.h>
1313
#include <linux/init.h>
14+
#include <linux/kernel.h>
1415
#include <linux/module.h>
16+
#include <linux/sched.h>
1517

1618
static int crypto_arc4_setkey(struct crypto_skcipher *tfm, const u8 *in_key,
1719
unsigned int key_len)
@@ -39,6 +41,14 @@ static int crypto_arc4_crypt(struct skcipher_request *req)
3941
return err;
4042
}
4143

44+
static int crypto_arc4_init(struct crypto_skcipher *tfm)
45+
{
46+
pr_warn_ratelimited("\"%s\" (%ld) uses obsolete ecb(arc4) skcipher\n",
47+
current->comm, (unsigned long)current->pid);
48+
49+
return 0;
50+
}
51+
4252
static struct skcipher_alg arc4_alg = {
4353
/*
4454
* For legacy reasons, this is named "ecb(arc4)", not "arc4".
@@ -55,6 +65,7 @@ static struct skcipher_alg arc4_alg = {
5565
.setkey = crypto_arc4_setkey,
5666
.encrypt = crypto_arc4_crypt,
5767
.decrypt = crypto_arc4_crypt,
68+
.init = crypto_arc4_init,
5869
};
5970

6071
static int __init arc4_init(void)

0 commit comments

Comments
 (0)