aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2019-08-15 05:01:12 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2019-08-22 00:57:34 -0400
commit9a394d1208147715b8a365f44b4e7bfbb2094748 (patch)
tree7126f454de1e419a794dcd87c5c2d4fca52c9793 /fs/cifs
parent18fbe0da8e98fe167fbfe1757003e2a2a74d24f3 (diff)
fs: cifs: move from the crypto cipher API to the new DES library interface
Some legacy code in the CIFS driver uses single DES to calculate some password hash, and uses the crypto cipher API to do so. Given that there is no point in invoking an accelerated cipher for doing 56-bit symmetric encryption on a single 8-byte block of input, the flexibility of the crypto cipher API does not add much value here, and so we're much better off using a library call into the generic C implementation. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'fs/cifs')
-rw-r--r--fs/cifs/Kconfig2
-rw-r--r--fs/cifs/cifsfs.c1
-rw-r--r--fs/cifs/smbencrypt.c18
3 files changed, 10 insertions, 11 deletions
diff --git a/fs/cifs/Kconfig b/fs/cifs/Kconfig
index b16219e5dac9..350bc3061656 100644
--- a/fs/cifs/Kconfig
+++ b/fs/cifs/Kconfig
@@ -16,7 +16,7 @@ config CIFS
16 select CRYPTO_GCM 16 select CRYPTO_GCM
17 select CRYPTO_ECB 17 select CRYPTO_ECB
18 select CRYPTO_AES 18 select CRYPTO_AES
19 select CRYPTO_DES 19 select CRYPTO_LIB_DES
20 select KEYS 20 select KEYS
21 help 21 help
22 This is the client VFS module for the SMB3 family of NAS protocols, 22 This is the client VFS module for the SMB3 family of NAS protocols,
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 3289b566463f..4e2f74894e9b 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -1601,7 +1601,6 @@ MODULE_DESCRIPTION
1601 ("VFS to access SMB3 servers e.g. Samba, Macs, Azure and Windows (and " 1601 ("VFS to access SMB3 servers e.g. Samba, Macs, Azure and Windows (and "
1602 "also older servers complying with the SNIA CIFS Specification)"); 1602 "also older servers complying with the SNIA CIFS Specification)");
1603MODULE_VERSION(CIFS_VERSION); 1603MODULE_VERSION(CIFS_VERSION);
1604MODULE_SOFTDEP("pre: des");
1605MODULE_SOFTDEP("pre: ecb"); 1604MODULE_SOFTDEP("pre: ecb");
1606MODULE_SOFTDEP("pre: hmac"); 1605MODULE_SOFTDEP("pre: hmac");
1607MODULE_SOFTDEP("pre: md4"); 1606MODULE_SOFTDEP("pre: md4");
diff --git a/fs/cifs/smbencrypt.c b/fs/cifs/smbencrypt.c
index 2b6d87bfdf8e..39a938443e3e 100644
--- a/fs/cifs/smbencrypt.c
+++ b/fs/cifs/smbencrypt.c
@@ -11,13 +11,14 @@
11 11
12*/ 12*/
13 13
14#include <linux/crypto.h>
15#include <linux/module.h> 14#include <linux/module.h>
16#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/fips.h>
17#include <linux/fs.h> 17#include <linux/fs.h>
18#include <linux/string.h> 18#include <linux/string.h>
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/random.h> 20#include <linux/random.h>
21#include <crypto/des.h>
21#include "cifs_fs_sb.h" 22#include "cifs_fs_sb.h"
22#include "cifs_unicode.h" 23#include "cifs_unicode.h"
23#include "cifspdu.h" 24#include "cifspdu.h"
@@ -58,19 +59,18 @@ static int
58smbhash(unsigned char *out, const unsigned char *in, unsigned char *key) 59smbhash(unsigned char *out, const unsigned char *in, unsigned char *key)
59{ 60{
60 unsigned char key2[8]; 61 unsigned char key2[8];
61 struct crypto_cipher *tfm_des; 62 struct des_ctx ctx;
62 63
63 str_to_key(key, key2); 64 str_to_key(key, key2);
64 65
65 tfm_des = crypto_alloc_cipher("des", 0, 0); 66 if (fips_enabled) {
66 if (IS_ERR(tfm_des)) { 67 cifs_dbg(VFS, "FIPS compliance enabled: DES not permitted\n");
67 cifs_dbg(VFS, "could not allocate des crypto API\n"); 68 return -ENOENT;
68 return PTR_ERR(tfm_des);
69 } 69 }
70 70
71 crypto_cipher_setkey(tfm_des, key2, 8); 71 des_expand_key(&ctx, key2, DES_KEY_SIZE);
72 crypto_cipher_encrypt_one(tfm_des, out, in); 72 des_encrypt(&ctx, out, in);
73 crypto_free_cipher(tfm_des); 73 memzero_explicit(&ctx, sizeof(ctx));
74 74
75 return 0; 75 return 0;
76} 76}