crypto: mark ecb(arc4) skcipher as obsolete
Subsystems (8)
v3 cover crypto: mark ecb(arc4) skcipher as obsolete
RC4 hasn't aged very well, and is a poor fit for the skcipher API so it would be good if we could get rid of the ecb(arc4) drivers in the kernel at some point in the future. This prevents new users from creeping in, and allows us to improve the skcipher API without having to care too much about obsolete algorithms that may be difficult to support going forward.
So let's get rid of any remaining in-kernel users, either by switching them to the arc4 library API (for cases which simply cannot change algorithms, e.g., WEP), or dropping the code entirely. Also remove the remaining h/w accelerated implementations, and mark the generic s/w implementation as obsolete in Kconfig.
Changes since v2:
- depend on CRYPTO_USER_API not CRYPTO_USER
- rename CRYPTO_USER_ENABLE_OBSOLETE to CRYPTO_USER_API_ENABLE_OBSOLETE for clarity
Changes since RFC [0]:
- keep ecb(arc4) generic C implementation, and the associated test vectors, but print a warning about ecb(arc4) being obsolete so we can identify remaining users
- add a Kconfig option to en/disable obsolete algorithms that are only kept around to prevent breaking users that rely on it via the socket interface
- add a patch to clean up some bogus Kconfig dependencies
- add acks to patches #1, #2 and #3
[0] https://lore.kernel.org/driverdev-devel/[email protected]/
Ard Biesheuvel (7):
staging/rtl8192e: switch to RC4 library interface staging/rtl8192u: switch to RC4 library interface
SUNRPC: remove RC4-HMAC-MD5 support from KerberosV
crypto: n2 - remove ecb(arc4) support
crypto: bcm-iproc - remove ecb(arc4) support
net: wireless: drop bogus CRYPTO_xxx Kconfig selects
crypto: arc4 - mark ecb(arc4) skcipher as obsolete
crypto/Kconfig | 10 + crypto/arc4.c | 10 + drivers/crypto/bcm/cipher.c | 96 +----- drivers/crypto/bcm/cipher.h | 1 - drivers/crypto/bcm/spu.c | 23 +- drivers/crypto/bcm/spu.h | 1 - drivers/crypto/bcm/spu2.c | 12 +- drivers/crypto/bcm/spu2.h | 1 - drivers/crypto/n2_core.c | 46 --- drivers/net/wireless/intel/ipw2x00/Kconfig | 4 - drivers/net/wireless/intersil/hostap/Kconfig | 4 - drivers/staging/rtl8192e/Kconfig | 4 +- drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 70 +---- drivers/staging/rtl8192e/rtllib_crypt_wep.c | 72 +---- drivers/staging/rtl8192u/Kconfig | 1 + .../rtl8192u/ieee80211/ieee80211_crypt_tkip.c | 81 +---- .../rtl8192u/ieee80211/ieee80211_crypt_wep.c | 64 +--- include/linux/sunrpc/gss_krb5.h | 11 - include/linux/sunrpc/gss_krb5_enctypes.h | 9 +- net/sunrpc/Kconfig | 1 - net/sunrpc/auth_gss/gss_krb5_crypto.c | 276 ------------------ net/sunrpc/auth_gss/gss_krb5_mech.c | 95 ------ net/sunrpc/auth_gss/gss_krb5_seal.c | 1 - net/sunrpc/auth_gss/gss_krb5_seqnum.c | 87 ------ net/sunrpc/auth_gss/gss_krb5_unseal.c | 1 - net/sunrpc/auth_gss/gss_krb5_wrap.c | 65 +---- 26 files changed, 97 insertions(+), 949 deletions(-)
Signature · 1 line
2.17.1
PATCH v3 2/7 staging/rtl8192u: switch to RC4 library interface
Switch to the ARC4 library interface, to remove the pointless dependency on the skcipher API, from which we will hopefully be able to drop ecb(arc4) skcipher support.
--- drivers/staging/rtl8192u/Kconfig | 1 + drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c | 81 ++++---------------- drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c | 64 +++------------- 3 files changed, 27 insertions(+), 119 deletions(-)
drivers/staging/rtl8192u/Kconfig +1 -0
@@ -8,3 +8,4 @@ config RTL8192U select CRYPTO select CRYPTO_AES select CRYPTO_CCM + select CRYPTO_LIB_ARC4
drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c +14 -67
191 lines not on this page · raw message
drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c +12 -52
132 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 1/7 staging/rtl8192e: switch to RC4 library interface
In reply to Ard BiesheuvelSwitch to the ARC4 library interface, to remove the pointless dependency on the skcipher API, from which we will hopefully be able to drop ecb(arc4) skcipher support.
--- drivers/staging/rtl8192e/Kconfig | 4 +- drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 70 ++++--------------- drivers/staging/rtl8192e/rtllib_crypt_wep.c | 72 ++++---------------- 3 files changed, 28 insertions(+), 118 deletions(-)
drivers/staging/rtl8192e/Kconfig +2 -2
@@ -25,7 +25,7 @@ config RTLLIB_CRYPTO_CCMP config RTLLIB_CRYPTO_TKIP tristate "Support for rtllib TKIP crypto" depends on RTLLIB - select CRYPTO_ARC4 + select CRYPTO_LIB_ARC4 select CRYPTO_MICHAEL_MIC default y help
@@ -35,7 +35,7 @@ config RTLLIB_CRYPTO_TKIP config RTLLIB_CRYPTO_WEP tristate "Support for rtllib WEP crypto" - select CRYPTO_ARC4 + select CRYPTO_LIB_ARC4 depends on RTLLIB default y help
drivers/staging/rtl8192e/rtllib_crypt_tkip.c +12 -58
171 lines not on this page · raw message
drivers/staging/rtl8192e/rtllib_crypt_wep.c +14 -58
139 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 4/7 crypto: n2 - remove ecb(arc4) support
In reply to Ard Biesheuvel--- drivers/crypto/n2_core.c | 46 -------------------- 1 file changed, 46 deletions(-)
drivers/crypto/n2_core.c +0 -46
@@ -662,7 +662,6 @@ struct n2_skcipher_context {u8 aes[AES_MAX_KEY_SIZE ];u8 des[DES_KEY_SIZE ];u8 des3[3 *DES_KEY_SIZE ]; -u8 arc4[258 ];/* S-box, X, Y */ } key; };
@@ -789,36 +788,6 @@ static int n2_3des_setkey(struct crypto_skcipher *skcipher, const u8 *key,return 0 ; } -static int n2_arc4_setkey (struct crypto_skcipher *skcipher,const u8 *key, -unsigned int keylen) -{ -struct crypto_tfm *tfm =crypto_skcipher_tfm (skcipher); -struct n2_skcipher_context *ctx =crypto_tfm_ctx (tfm); -struct n2_skcipher_alg *n2alg =n2_skcipher_alg (skcipher); -u8 *s = ctx->key.arc4; -u8 *x = s +256 ; -u8 *y = x +1 ; -int i, j, k; - - ctx->enc_type = n2alg->enc_type; - - j = k =0 ; - *x =0 ; - *y =0 ; -for (i =0 ; i <256 ; i++) - s[i] = i; -for (i =0 ; i <256 ; i++) { -u8 a = s[i]; - j = (j + key[k] + a) &0xff ; - s[i] = s[j]; - s[j] = a; -if (++k >= keylen) - k =0 ; - } - -return 0 ; -} -static inline int skcipher_descriptor_len (int nbytes,unsigned int block_size) {int this_len = nbytes;
@@ -1122,21 +1091,6 @@ struct n2_skcipher_tmpl { };static const struct n2_skcipher_tmpl skcipher_tmpls[] = { -/* ARC4: only ECB is supported (chaining bits ignored) */ - { .name ="ecb(arc4)" , - .drv_name ="ecb-arc4" , - .block_size =1 , - .enc_type = (ENC_TYPE_ALG_RC4_STREAM | -ENC_TYPE_CHAINING_ECB ), - .skcipher = { - .min_keysize =1 , - .max_keysize =256 , - .setkey = n2_arc4_setkey, - .encrypt = n2_encrypt_ecb, - .decrypt = n2_decrypt_ecb, - }, - }, -/* DES: ECB CBC and CFB are supported */ { .name ="ecb(des)" , .drv_name ="ecb-des" ,
Signature · 1 line
2.17.1
PATCH v3 3/7 SUNRPC: remove RC4-HMAC-MD5 support from KerberosV
In reply to Ard BiesheuvelThe RC4-HMAC-MD5 KerberosV algorithm is based on RFC 4757 [0], which was specifically issued for interoperability with Windows 2000, but was never intended to receive the same level of support. The RFC says
The IETF Kerberos community supports publishing this specification as an informational document in order to describe this widely implemented technology. However, while these encryption types provide the operations necessary to implement the base Kerberos specification [RFC4120], they do not provide all the required operations in the Kerberos cryptography framework [RFC3961]. As a result, it is not generally possible to implement potential extensions to Kerberos using these encryption types. The Kerberos encryption type negotiation mechanism [RFC4537] provides one approach for using such extensions even when a Kerberos infrastructure uses long-term RC4 keys. Because this specification does not implement operations required by RFC 3961 and because of security concerns with the use of RC4 and MD4 discussed in Section 8, this specification is not appropriate for publication on the standards track.
The RC4-HMAC encryption types are used to ease upgrade of existing Windows NT environments, provide strong cryptography (128-bit key lengths), and provide exportable (meet United States government export restriction requirements) encryption. This document describes the implementation of those encryption types.
Furthermore, this RFC was re-classified as 'historic' by RFC 8429 [1] in 2018, stating that 'none of the encryption types it specifies should be used'
Note that other outdated algorithms are left in place (some of which are guarded by CONFIG_SUNRPC_DISABLE_INSECURE_ENCTYPES), so this should only adversely affect interoperability with Windows NT/2000 systems that have not received any updates since 2008 (but are connected to a network nonetheless)
[0] https://tools.ietf.org/html/rfc4757
[1] https://tools.ietf.org/html/rfc8429
--- include/linux/sunrpc/gss_krb5.h | 11 - include/linux/sunrpc/gss_krb5_enctypes.h | 9 +- net/sunrpc/Kconfig | 1 - net/sunrpc/auth_gss/gss_krb5_crypto.c | 276 -------------------- net/sunrpc/auth_gss/gss_krb5_mech.c | 95 ------- net/sunrpc/auth_gss/gss_krb5_seal.c | 1 - net/sunrpc/auth_gss/gss_krb5_seqnum.c | 87 ------ net/sunrpc/auth_gss/gss_krb5_unseal.c | 1 - net/sunrpc/auth_gss/gss_krb5_wrap.c | 65 +---- 9 files changed, 16 insertions(+), 530 deletions(-)
include/linux/sunrpc/gss_krb5.h +0 -11
@@ -141,14 +141,12 @@ enum sgn_alg {SGN_ALG_MD2_5 =0x0001 ,SGN_ALG_DES_MAC =0x0002 ,SGN_ALG_3 =0x0003 ,/* not published */ -SGN_ALG_HMAC_MD5 =0x0011 ,/* microsoft w2k; no support */ SGN_ALG_HMAC_SHA1_DES3_KD = 0x0004 };enum seal_alg {SEAL_ALG_NONE =0xffff ,SEAL_ALG_DES =0x0000 ,SEAL_ALG_1 =0x0001 ,/* not published */ -SEAL_ALG_MICROSOFT_RC4 =0x0010 ,/* microsoft w2k; no support */ SEAL_ALG_DES3KD =0x0002 };
@@ -316,14 +314,5 @@ gss_krb5_aes_decrypt(struct krb5_ctx *kctx, u32 offset, u32 len, struct xdr_buf *buf, u32 *plainoffset, u32 *plainlen); -int -krb5_rc4_setup_seq_key (struct krb5_ctx *kctx, -struct crypto_sync_skcipher *cipher, -unsigned char *cksum); - -int -krb5_rc4_setup_enc_key (struct krb5_ctx *kctx, -struct crypto_sync_skcipher *cipher, -s32 seqnum);void gss_krb5_make_confounder (char *p,u32 conflen);
include/linux/sunrpc/gss_krb5_enctypes.h +3 -6
@@ -13,15 +13,13 @@#ifdef CONFIG_SUNRPC_DISABLE_INSECURE_ENCTYPES /* -* NB: This list includes encryption types that were deprecated -* by RFC 8429 (DES3_CBC_SHA1 and ARCFOUR_HMAC). +* NB: This list includes DES3_CBC_SHA1, which was deprecated by RFC 8429. * * ENCTYPE_AES256_CTS_HMAC_SHA1_96 * ENCTYPE_AES128_CTS_HMAC_SHA1_96 * ENCTYPE_DES3_CBC_SHA1 -* ENCTYPE_ARCFOUR_HMAC */ -#define KRB5_SUPPORTED_ENCTYPES "18,17,16,23" +#define KRB5_SUPPORTED_ENCTYPES "18,17,16"#else /* CONFIG_SUNRPC_DISABLE_INSECURE_ENCTYPES */
@@ -32,12 +30,11 @@* ENCTYPE_AES256_CTS_HMAC_SHA1_96 * ENCTYPE_AES128_CTS_HMAC_SHA1_96 * ENCTYPE_DES3_CBC_SHA1 -* ENCTYPE_ARCFOUR_HMAC * ENCTYPE_DES_CBC_MD5 * ENCTYPE_DES_CBC_CRC * ENCTYPE_DES_CBC_MD4 */ -#define KRB5_SUPPORTED_ENCTYPES "18,17,16,23,3,1,2" +#define KRB5_SUPPORTED_ENCTYPES "18,17,16,3,1,2"#endif /* CONFIG_SUNRPC_DISABLE_INSECURE_ENCTYPES */
net/sunrpc/Kconfig +0 -1
@@ -21,7 +21,6 @@ config RPCSEC_GSS_KRB5 depends on SUNRPC && CRYPTO depends on CRYPTO_MD5 && CRYPTO_DES && CRYPTO_CBC && CRYPTO_CTS depends on CRYPTO_ECB && CRYPTO_HMAC && CRYPTO_SHA1 && CRYPTO_AES - depends on CRYPTO_ARC4 default y select SUNRPC_GSS help
net/sunrpc/auth_gss/gss_krb5_crypto.c +0 -276
291 lines not on this page · raw message
net/sunrpc/auth_gss/gss_krb5_mech.c +0 -95
113 lines not on this page · raw message
net/sunrpc/auth_gss/gss_krb5_seal.c +0 -1
@@ -214,7 +214,6 @@ gss_get_mic_kerberos(struct gss_ctx *gss_ctx, struct xdr_buf *text,BUG ();case ENCTYPE_DES_CBC_RAW :case ENCTYPE_DES3_CBC_RAW : -case ENCTYPE_ARCFOUR_HMAC :return gss_get_mic_v1 (ctx, text, token);case ENCTYPE_AES128_CTS_HMAC_SHA1_96 :case ENCTYPE_AES256_CTS_HMAC_SHA1_96 :
net/sunrpc/auth_gss/gss_krb5_seqnum.c +0 -87
111 lines not on this page · raw message
net/sunrpc/auth_gss/gss_krb5_unseal.c +0 -1
@@ -218,7 +218,6 @@ gss_verify_mic_kerberos(struct gss_ctx *gss_ctx,BUG ();case ENCTYPE_DES_CBC_RAW :case ENCTYPE_DES3_CBC_RAW : -case ENCTYPE_ARCFOUR_HMAC :return gss_verify_mic_v1 (ctx, message_buffer, read_token);case ENCTYPE_AES128_CTS_HMAC_SHA1_96 :case ENCTYPE_AES256_CTS_HMAC_SHA1_96 :
net/sunrpc/auth_gss/gss_krb5_wrap.c +13 -52
96 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 6/7 net: wireless: drop bogus CRYPTO_xxx Kconfig selects
In reply to Ard BiesheuvelDrop some bogus Kconfig selects that are not entirely accurate, and unnecessary to begin with, since the same Kconfig options also select LIB80211 features that already imply the selected functionality (AES for CCMP, ARC4 and ECB for TKIP)
--- drivers/net/wireless/intel/ipw2x00/Kconfig | 4 ---- drivers/net/wireless/intersil/hostap/Kconfig | 4 ---- 2 files changed, 8 deletions(-)
drivers/net/wireless/intel/ipw2x00/Kconfig +0 -4
@@ -160,11 +160,7 @@ config LIBIPW select WIRELESS_EXT select WEXT_SPY select CRYPTO - select CRYPTO_ARC4 - select CRYPTO_ECB - select CRYPTO_AES select CRYPTO_MICHAEL_MIC - select CRYPTO_ECB select CRC32 select LIB80211 select LIB80211_CRYPT_WEP
drivers/net/wireless/intersil/hostap/Kconfig +0 -4
@@ -5,11 +5,7 @@ config HOSTAP select WEXT_SPY select WEXT_PRIV select CRYPTO - select CRYPTO_ARC4 - select CRYPTO_ECB - select CRYPTO_AES select CRYPTO_MICHAEL_MIC - select CRYPTO_ECB select CRC32 select LIB80211 select LIB80211_CRYPT_WEP
Signature · 1 line
2.17.1
PATCH v3 7/7 crypto: arc4 - mark ecb(arc4) skcipher as obsolete
In reply to Ard BiesheuvelCryptographic 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
--- crypto/Kconfig | 10 ++++++++++ crypto/arc4.c | 10 ++++++++++ 2 files changed, 20 insertions(+)
crypto/Kconfig +10 -0
@@ -1199,6 +1199,7 @@ config CRYPTO_ANUBIS config CRYPTO_ARC4 tristate "ARC4 cipher algorithm" + depends on CRYPTO_USER_API_ENABLE_OBSOLETE select CRYPTO_SKCIPHER select CRYPTO_LIB_ARC4 help
@@ -1881,6 +1882,15 @@ config CRYPTO_USER_API_AEAD This option enables the user-spaces interface for AEAD cipher algorithms. +config CRYPTO_USER_API_ENABLE_OBSOLETE + bool "Enable obsolete cryptographic algorithms for userspace" + depends on CRYPTO_USER_API + default y + help + Allow obsolete cryptographic algorithms to be selected that have + already been phased out from internal use by the kernel, and are + only useful for userspace clients that still rely on them. + config CRYPTO_STATS bool "Crypto usage statistics for User-space" depends on CRYPTO_USER
crypto/arc4.c +10 -0
@@ -12,6 +12,7 @@#include <crypto/internal/skcipher.h> #include <linux/init.h> #include <linux/module.h> +#include <linux/sched.h> static int crypto_arc4_setkey (struct crypto_skcipher *tfm,const u8 *in_key,unsigned int key_len)
@@ -39,6 +40,14 @@ static int crypto_arc4_crypt(struct skcipher_request *req)return err; } +static int crypto_arc4_init (struct crypto_skcipher *tfm) +{ +pr_warn_ratelimited ("\"%s\" (%ld) uses obsolete ecb(arc4) skcipher\n" , + current->comm, (unsigned long )current->pid); + +return 0 ; +} +static struct skcipher_alg arc4_alg = {/* * For legacy reasons, this is named "ecb(arc4)", not "arc4".
@@ -55,6 +64,7 @@ static struct skcipher_alg arc4_alg = { .setkey = crypto_arc4_setkey, .encrypt = crypto_arc4_crypt, .decrypt = crypto_arc4_crypt, + .init = crypto_arc4_init, };static int __init arc4_init (void )
Signature · 1 line
2.17.1
PATCH v3 5/7 crypto: bcm-iproc - remove ecb(arc4) support
In reply to Ard Biesheuvel--- drivers/crypto/bcm/cipher.c | 96 +------------------- drivers/crypto/bcm/cipher.h | 1 - drivers/crypto/bcm/spu.c | 23 +---- drivers/crypto/bcm/spu.h | 1 - drivers/crypto/bcm/spu2.c | 12 +-- drivers/crypto/bcm/spu2.h | 1 - 6 files changed, 6 insertions(+), 128 deletions(-)
drivers/crypto/bcm/cipher.c +4 -92
@@ -165,10 +165,6 @@ spu_skcipher_rx_sg_create(struct brcm_message *mssg,return -EFAULT ; } -if (ctx->cipher.alg ==CIPHER_ALG_RC4 ) -/* Add buffer to catch 260-byte SUPDT field for RC4 */ -sg_set_buf (sg++, rctx->msg_buf.c.supdt_tweak,SPU_SUPDT_LEN ); -if (stat_pad_len)sg_set_buf (sg++, rctx->msg_buf.rx_stat_pad, stat_pad_len);
@@ -317,7 +313,6 @@ static int handle_skcipher_req(struct iproc_reqctx_s *rctx)u8 local_iv_ctr[MAX_IV_SIZE ];u32 stat_pad_len;/* num bytes to align status field */ u32 pad_len;/* total length of all padding */ -bool update_key = false;struct brcm_message *mssg;/* mailbox message */ /* number of entries in src and dst sg in mailbox message. */
@@ -391,28 +386,6 @@ static int handle_skcipher_req(struct iproc_reqctx_s *rctx) } } -if (ctx->cipher.alg ==CIPHER_ALG_RC4 ) { - rx_frag_num++; -if (chunk_start) { -/* -* for non-first RC4 chunks, use SUPDT from previous -* response as key for this chunk. -*/ - cipher_parms.key_buf = rctx->msg_buf.c.supdt_tweak; - update_key = true; - cipher_parms.type =CIPHER_TYPE_UPDT ; - }else if (!rctx->is_encrypt) { -/* -* First RC4 chunk. For decrypt, key in pre-built msg -* header may have been changed if encrypt required -* multiple chunks. So revert the key to the -* ctx->enckey value. -*/ - update_key = true; - cipher_parms.type =CIPHER_TYPE_INIT ; - } - } -if (ctx->max_payload ==SPU_MAX_PAYLOAD_INF )flow_log ("max_payload infinite\n" );else
@@ -425,14 +398,9 @@ static int handle_skcipher_req(struct iproc_reqctx_s *rctx)memcpy (rctx->msg_buf.bcm_spu_req_hdr, ctx->bcm_spu_req_hdr,sizeof (rctx->msg_buf.bcm_spu_req_hdr)); -/* -* Pass SUPDT field as key. Key field in finish() call is only used -* when update_key has been set above for RC4. Will be ignored in -* all other cases. -*/ spu->spu_cipher_req_finish (rctx->msg_buf.bcm_spu_req_hdr +BCM_HDR_LEN , ctx->spu_req_hdr_len, !(rctx->is_encrypt), - &cipher_parms, update_key, chunksize); + &cipher_parms, chunksize);atomic64_add (chunksize, &iproc_priv.bytes_out);
@@ -527,9 +495,6 @@ static void handle_skcipher_resp(struct iproc_reqctx_s *rctx) __func__, rctx->total_received, payload_len);dump_sg (req->dst, rctx->total_received, payload_len); -if (ctx->cipher.alg ==CIPHER_ALG_RC4 ) -packet_dump (" supdt " , rctx->msg_buf.c.supdt_tweak, -SPU_SUPDT_LEN ); rctx->total_received += payload_len;if (rctx->total_received == rctx->total_todo) {
@@ -1853,26 +1818,6 @@ static int aes_setkey(struct crypto_skcipher *cipher, const u8 *key,return 0 ; } -static int rc4_setkey (struct crypto_skcipher *cipher,const u8 *key, -unsigned int keylen) -{ -struct iproc_ctx_s *ctx =crypto_skcipher_ctx (cipher); -int i; - - ctx->enckeylen =ARC4_MAX_KEY_SIZE +ARC4_STATE_SIZE ; - - ctx->enckey[0 ] =0x00 ;/* 0x00 */ - ctx->enckey[1 ] =0x00 ;/* i */ - ctx->enckey[2 ] =0x00 ;/* 0x00 */ - ctx->enckey[3 ] =0x00 ;/* j */ -for (i =0 ; i <ARC4_MAX_KEY_SIZE ; i++) - ctx->enckey[i +ARC4_STATE_SIZE ] = key[i % keylen]; - - ctx->cipher_type =CIPHER_TYPE_INIT ; - -return 0 ; -} -static int skcipher_setkey (struct crypto_skcipher *cipher,const u8 *key,unsigned int keylen) {
@@ -1895,9 +1840,6 @@ static int skcipher_setkey(struct crypto_skcipher *cipher, const u8 *key,case CIPHER_ALG_AES : err =aes_setkey (cipher, key, keylen);break ; -case CIPHER_ALG_RC4 : - err =rc4_setkey (cipher, key, keylen); -break ;default :pr_err ("%s() Error: unknown cipher alg\n" , __func__); err = -EINVAL ;
@@ -1905,11 +1847,9 @@ static int skcipher_setkey(struct crypto_skcipher *cipher, const u8 *key,if (err)return err; -/* RC4 already populated ctx->enkey */ -if (ctx->cipher.alg !=CIPHER_ALG_RC4 ) { -memcpy (ctx->enckey, key, keylen); - ctx->enckeylen = keylen; - } +memcpy (ctx->enckey, key, keylen); + ctx->enckeylen = keylen; +/* SPU needs XTS keys in the reverse order the crypto API presents */ if ((ctx->cipher.alg ==CIPHER_ALG_AES ) && (ctx->cipher.mode ==CIPHER_MODE_XTS )) {
@@ -2872,9 +2812,6 @@ static int aead_authenc_setkey(struct crypto_aead *cipher, goto badkey; }break ; -case CIPHER_ALG_RC4 : - ctx->cipher_type =CIPHER_TYPE_INIT ; -break ;default :pr_err ("%s() Error: Unknown cipher alg\n" , __func__);return -EINVAL ;
@@ -3603,25 +3540,6 @@ static struct iproc_alg_s driver_algs[] = { },/* SKCIPHER algorithms. */ - { - .type = CRYPTO_ALG_TYPE_SKCIPHER, - .alg.skcipher = { - .base.cra_name = "ecb(arc4)", - .base.cra_driver_name = "ecb-arc4-iproc", - .base.cra_blocksize = ARC4_BLOCK_SIZE, - .min_keysize = ARC4_MIN_KEY_SIZE, - .max_keysize = ARC4_MAX_KEY_SIZE, - .ivsize =0 , - }, - .cipher_info = { - .alg =CIPHER_ALG_RC4 , - .mode = CIPHER_MODE_NONE, - }, - .auth_info = { - .alg =HASH_ALG_NONE , - .mode = HASH_MODE_NONE, - }, - }, { .type = CRYPTO_ALG_TYPE_SKCIPHER, .alg.skcipher = {
@@ -4526,15 +4444,9 @@ static void spu_counters_init(void)static int spu_register_skcipher (struct iproc_alg_s *driver_alg) { -struct spu_hw *spu = &iproc_priv.spu;struct skcipher_alg *crypto = &driver_alg->alg.skcipher;int err; -/* SPU2 does not support RC4 */ -if ((driver_alg->cipher_info.alg ==CIPHER_ALG_RC4 ) && - (spu->spu_type ==SPU_TYPE_SPU2 )) -return 0 ; - crypto->base.cra_module =THIS_MODULE ; crypto->base.cra_priority = cipher_pri; crypto->base.cra_alignmask =0 ;
drivers/crypto/bcm/cipher.h +0 -1
@@ -388,7 +388,6 @@ struct spu_hw {u16 spu_req_hdr_len, unsigned int is_inbound, struct spu_cipher_parms *cipher_parms, - bool update_key, unsigned int data_size); void (*spu_request_pad)(u8 *pad_start, u32 gcm_padding, u32 hash_pad_len, enum hash_alg auth_alg,
drivers/crypto/bcm/spu.c +1 -22
@@ -222,10 +222,6 @@ void spum_dump_msg_hdr(u8 *buf, unsigned int buf_len) cipher_key_len =24 ; name ="3DES" ;break ; -case CIPHER_ALG_RC4 : - cipher_key_len =260 ; - name ="ARC4" ; -break ;case CIPHER_ALG_AES :switch (cipher_type) {case CIPHER_TYPE_AES128 :
@@ -919,21 +915,16 @@ u16 spum_cipher_req_init(u8 *spu_hdr, struct spu_cipher_parms *cipher_parms)* @spu_req_hdr_len: Length in bytes of the SPU request header * @isInbound: 0 encrypt, 1 decrypt * @cipher_parms: Parameters describing cipher operation to be performed -* @update_key: If true, rewrite the cipher key in SCTX * @data_size: Length of the data in the BD field * * Assumes much of the header was already filled in at setkey() time in * spum_cipher_req_init(). -* spum_cipher_req_init() fills in the encryption key. For RC4, when submitting -* a request for a non-first chunk, we use the 260-byte SUPDT field from the -* previous response as the key. update_key is true for this case. Unused in all -* other cases. +* spum_cipher_req_init() fills in the encryption key. */ void spum_cipher_req_finish (u8 *spu_hdr,u16 spu_req_hdr_len,unsigned int is_inbound,struct spu_cipher_parms *cipher_parms, -bool update_key,unsigned int data_size) {struct SPUHEADER *spuh;
@@ -948,11 +939,6 @@ void spum_cipher_req_finish(u8 *spu_hdr,flow_log (" in: %u\n" , is_inbound);flow_log (" cipher alg: %u, cipher_type: %u\n" , cipher_parms->alg, cipher_parms->type); -if (update_key) { -flow_log (" cipher key len: %u\n" , cipher_parms->key_len); -flow_dump (" key: " , cipher_parms->key_buf, - cipher_parms->key_len); - }/* * In XTS mode, API puts "i" parameter (block tweak) in IV. For
@@ -981,13 +967,6 @@ void spum_cipher_req_finish(u8 *spu_hdr,else cipher_bits &= ~CIPHER_INBOUND ; -/* update encryption key for RC4 on non-first chunk */ -if (update_key) { - spuh->sa.cipher_flags |= - cipher_parms->type <<CIPHER_TYPE_SHIFT ; -memcpy (spuh +1 , cipher_parms->key_buf, cipher_parms->key_len); - } -if (cipher_parms->alg && cipher_parms->iv_buf && cipher_parms->iv_len)/* cipher iv provided so put it in here */ memcpy(bdesc_ptr - cipher_parms->iv_len, cipher_parms->iv_buf,
drivers/crypto/bcm/spu.h +0 -1
@@ -251,7 +251,6 @@ void spum_cipher_req_finish(u8 *spu_hdr,u16 spu_req_hdr_len, unsigned int is_inbound, struct spu_cipher_parms *cipher_parms, - bool update_key, unsigned int data_size); void spum_request_pad(u8 *pad_start,
drivers/crypto/bcm/spu2.c +1 -11
@@ -1170,21 +1170,16 @@ u16 spu2_cipher_req_init(u8 *spu_hdr, struct spu_cipher_parms *cipher_parms)* @spu_req_hdr_len: Length in bytes of the SPU request header * @isInbound: 0 encrypt, 1 decrypt * @cipher_parms: Parameters describing cipher operation to be performed -* @update_key: If true, rewrite the cipher key in SCTX * @data_size: Length of the data in the BD field * * Assumes much of the header was already filled in at setkey() time in * spu_cipher_req_init(). -* spu_cipher_req_init() fills in the encryption key. For RC4, when submitting a -* request for a non-first chunk, we use the 260-byte SUPDT field from the -* previous response as the key. update_key is true for this case. Unused in all -* other cases. +* spu_cipher_req_init() fills in the encryption key. */ void spu2_cipher_req_finish (u8 *spu_hdr,u16 spu_req_hdr_len,unsigned int is_inbound,struct spu_cipher_parms *cipher_parms, -bool update_key,unsigned int data_size) {struct SPU2_FMD *fmd;
@@ -1196,11 +1191,6 @@ void spu2_cipher_req_finish(u8 *spu_hdr,flow_log (" in: %u\n" , is_inbound);flow_log (" cipher alg: %u, cipher_type: %u\n" , cipher_parms->alg, cipher_parms->type); -if (update_key) { -flow_log (" cipher key len: %u\n" , cipher_parms->key_len); -flow_dump (" key: " , cipher_parms->key_buf, - cipher_parms->key_len); - }flow_log (" iv len: %d\n" , cipher_parms->iv_len);flow_dump (" iv: " , cipher_parms->iv_buf, cipher_parms->iv_len);flow_log (" data_size: %u\n" , data_size);
drivers/crypto/bcm/spu2.h +0 -1
@@ -200,7 +200,6 @@ void spu2_cipher_req_finish(u8 *spu_hdr,u16 spu_req_hdr_len, unsigned int is_inbound, struct spu_cipher_parms *cipher_parms, - bool update_key, unsigned int data_size); void spu2_request_pad(u8 *pad_start, u32 gcm_padding, u32 hash_pad_len, enum hash_alg auth_alg, enum hash_mode auth_mode,
Signature · 1 line
2.17.1
Herbert Xu
maintainerRe: [PATCH v3 7/7] crypto: arc4 - mark ecb(arc4) skcipher as obsolete
In reply to Ard Biesheuvelcrypto/arc4.c line 15
Quoted 6 lines · Ard Biesheuvel
crypto/arc4.c +1
-0@@ -12,6 +12,7 @@#include <crypto/internal/skcipher.h> #include <linux/init.h> #include <linux/module.h> +#include <linux/sched.h>
This needs kernel.h too for the pr_warn_ratelimited. I'll add it when I apply the series.
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
Herbert Xu
maintainerQuoted 70 lines · Ard Biesheuvel
RC4 hasn't aged very well, and is a poor fit for the skcipher API so it would be good if we could get rid of the ecb(arc4) drivers in the kernel at some point in the future. This prevents new users from creeping in, and allows us to improve the skcipher API without having to care too much about obsolete algorithms that may be difficult to support going forward.
So let's get rid of any remaining in-kernel users, either by switching them to the arc4 library API (for cases which simply cannot change algorithms, e.g., WEP), or dropping the code entirely. Also remove the remaining h/w accelerated implementations, and mark the generic s/w implementation as obsolete in
Kconfig.Changes since v2:
- depend onCRYPTO_USER_APInotCRYPTO_USER
- renameCRYPTO_USER_ENABLE_OBSOLETEtoCRYPTO_USER_API_ENABLE_OBSOLETEfor clarityChanges since RFC [0]:
- keep ecb(arc4) generic C implementation, and the associated test vectors, but print a warning about ecb(arc4) being obsolete so we can identify remaining users
- add aKconfigoption to en/disable obsolete algorithms that are only kept around to prevent breaking users that rely on it via the socket interface
- add a patch to clean up some bogusKconfigdependencies
- add acks to patches #1, #2 and #3[0] https://lore.kernel.org/driverdev-devel/[email protected]/
Cc Herbert Xu <[email protected]>Cc "David S. Miller" <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Trond Myklebust <[email protected]>Cc Anna Schumaker <[email protected]>Cc "J. Bruce Fields" <[email protected]>Cc Chuck Lever <[email protected]>Cc Eric Biggers <[email protected]>Cc Arnd Bergmann <[email protected]>Ard Biesheuvel (7):
staging/rtl8192e: switch to RC4 library interface staging/rtl8192u: switch to RC4 library interface
SUNRPC: remove RC4-HMAC-MD5 support from KerberosV
crypto: n2 - remove ecb(arc4) support
crypto: bcm-iproc - remove ecb(arc4) support
net: wireless: drop bogusCRYPTO_xxxKconfigselects
crypto: arc4 - mark ecb(arc4) skcipher as obsoletecrypto/Kconfig | 10 + crypto/arc4.c | 10 + drivers/crypto/bcm/cipher.c | 96 +----- drivers/crypto/bcm/cipher.h | 1 - drivers/crypto/bcm/spu.c | 23 +- drivers/crypto/bcm/spu.h | 1 - drivers/crypto/bcm/spu2.c | 12 +- drivers/crypto/bcm/spu2.h | 1 - drivers/crypto/n2_core.c | 46 --- drivers/net/wireless/intel/ipw2x00/Kconfig | 4 - drivers/net/wireless/intersil/hostap/Kconfig | 4 - drivers/staging/rtl8192e/Kconfig | 4 +- drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 70 +---- drivers/staging/rtl8192e/rtllib_crypt_wep.c | 72 +---- drivers/staging/rtl8192u/Kconfig | 1 + .../rtl8192u/ieee80211/ieee80211_crypt_tkip.c | 81 +---- .../rtl8192u/ieee80211/ieee80211_crypt_wep.c | 64 +--- include/linux/sunrpc/gss_krb5.h | 11 - include/linux/sunrpc/gss_krb5_enctypes.h | 9 +-
Quoted 8 lines
net/sunrpc/Kconfig | 1 - net/sunrpc/auth_gss/gss_krb5_crypto.c | 276 ------------------ net/sunrpc/auth_gss/gss_krb5_mech.c | 95 ------ net/sunrpc/auth_gss/gss_krb5_seal.c | 1 - net/sunrpc/auth_gss/gss_krb5_seqnum.c | 87 ------ net/sunrpc/auth_gss/gss_krb5_unseal.c | 1 - net/sunrpc/auth_gss/gss_krb5_wrap.c | 65 +---- 26 files changed, 97 insertions(+), 949 deletions(-)
All 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