Skip to content

Commit 8e979aa

Browse files
Eric Biggerssmfrench
authored andcommitted
smb: Use arc4 library instead of duplicate arc4 code
fs/smb/common/cifs_arc4.c has an implementation of ARC4, but a copy of this same code is also present in lib/crypto/arc4.c to serve the other users of this legacy algorithm in the kernel. Remove the duplicate implementation in fs/smb/, which seems to have been added because of a misunderstanding, and just use the lib/crypto/ one. Signed-off-by: Eric Biggers <ebiggers@kernel.org> Reviewed-by: Paulo Alcantara (Red Hat) <pc@manguebit.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 02696ac commit 8e979aa

File tree

7 files changed

+10
-108
lines changed

7 files changed

+10
-108
lines changed

fs/smb/client/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ config CIFS
1515
select CRYPTO_GCM
1616
select CRYPTO_ECB
1717
select CRYPTO_AES
18+
select CRYPTO_LIB_ARC4
1819
select KEYS
1920
select DNS_RESOLVER
2021
select ASN1

fs/smb/client/cifsencrypt.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
#include <linux/highmem.h>
2323
#include <linux/fips.h>
2424
#include <linux/iov_iter.h>
25-
#include "../common/arc4.h"
2625
#include <crypto/aead.h>
26+
#include <crypto/arc4.h>
2727

2828
static size_t cifs_shash_step(void *iter_base, size_t progress, size_t len,
2929
void *priv, void *priv2)
@@ -725,9 +725,9 @@ calc_seckey(struct cifs_ses *ses)
725725
return -ENOMEM;
726726
}
727727

728-
cifs_arc4_setkey(ctx_arc4, ses->auth_key.response, CIFS_SESS_KEY_SIZE);
729-
cifs_arc4_crypt(ctx_arc4, ses->ntlmssp->ciphertext, sec_key,
730-
CIFS_CPHTXT_SIZE);
728+
arc4_setkey(ctx_arc4, ses->auth_key.response, CIFS_SESS_KEY_SIZE);
729+
arc4_crypt(ctx_arc4, ses->ntlmssp->ciphertext, sec_key,
730+
CIFS_CPHTXT_SIZE);
731731

732732
/* make secondary_key/nonce as session key */
733733
memcpy(ses->auth_key.response, sec_key, CIFS_SESS_KEY_SIZE);

fs/smb/common/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
# Makefile for Linux filesystem routines that are shared by client and server.
44
#
55

6-
obj-$(CONFIG_SMBFS) += cifs_arc4.o
76
obj-$(CONFIG_SMBFS) += cifs_md4.o

fs/smb/common/arc4.h

Lines changed: 0 additions & 23 deletions
This file was deleted.

fs/smb/common/cifs_arc4.c

Lines changed: 0 additions & 75 deletions
This file was deleted.

fs/smb/server/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ config SMB_SERVER
1010
select CRYPTO_MD5
1111
select CRYPTO_HMAC
1212
select CRYPTO_ECB
13+
select CRYPTO_LIB_ARC4
1314
select CRYPTO_LIB_DES
1415
select CRYPTO_LIB_SHA256
1516
select CRYPTO_SHA256

fs/smb/server/auth.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "glob.h"
2121

2222
#include <linux/fips.h>
23+
#include <crypto/arc4.h>
2324
#include <crypto/des.h>
2425

2526
#include "server.h"
@@ -29,7 +30,6 @@
2930
#include "mgmt/user_config.h"
3031
#include "crypto_ctx.h"
3132
#include "transport_ipc.h"
32-
#include "../common/arc4.h"
3333

3434
/*
3535
* Fixed format data defining GSS header and fixed string
@@ -365,10 +365,9 @@ int ksmbd_decode_ntlmssp_auth_blob(struct authenticate_message *authblob,
365365
if (!ctx_arc4)
366366
return -ENOMEM;
367367

368-
cifs_arc4_setkey(ctx_arc4, sess->sess_key,
369-
SMB2_NTLMV2_SESSKEY_SIZE);
370-
cifs_arc4_crypt(ctx_arc4, sess->sess_key,
371-
(char *)authblob + sess_key_off, sess_key_len);
368+
arc4_setkey(ctx_arc4, sess->sess_key, SMB2_NTLMV2_SESSKEY_SIZE);
369+
arc4_crypt(ctx_arc4, sess->sess_key,
370+
(char *)authblob + sess_key_off, sess_key_len);
372371
kfree_sensitive(ctx_arc4);
373372
}
374373

0 commit comments

Comments
 (0)