]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - fs/cifs/smbencrypt.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[linux.git] / fs / cifs / smbencrypt.c
index 2b6d87bfdf8e8f7de3b3657a28137c4496f7b37f..39a938443e3e3470848772389520c8b0e07c933e 100644 (file)
 
 */
 
-#include <linux/crypto.h>
 #include <linux/module.h>
 #include <linux/slab.h>
+#include <linux/fips.h>
 #include <linux/fs.h>
 #include <linux/string.h>
 #include <linux/kernel.h>
 #include <linux/random.h>
+#include <crypto/des.h>
 #include "cifs_fs_sb.h"
 #include "cifs_unicode.h"
 #include "cifspdu.h"
@@ -58,19 +59,18 @@ static int
 smbhash(unsigned char *out, const unsigned char *in, unsigned char *key)
 {
        unsigned char key2[8];
-       struct crypto_cipher *tfm_des;
+       struct des_ctx ctx;
 
        str_to_key(key, key2);
 
-       tfm_des = crypto_alloc_cipher("des", 0, 0);
-       if (IS_ERR(tfm_des)) {
-               cifs_dbg(VFS, "could not allocate des crypto API\n");
-               return PTR_ERR(tfm_des);
+       if (fips_enabled) {
+               cifs_dbg(VFS, "FIPS compliance enabled: DES not permitted\n");
+               return -ENOENT;
        }
 
-       crypto_cipher_setkey(tfm_des, key2, 8);
-       crypto_cipher_encrypt_one(tfm_des, out, in);
-       crypto_free_cipher(tfm_des);
+       des_expand_key(&ctx, key2, DES_KEY_SIZE);
+       des_encrypt(&ctx, out, in);
+       memzero_explicit(&ctx, sizeof(ctx));
 
        return 0;
 }