| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | Unix SMB/Netbios implementation. |
|---|
| 3 | 4 | Version 1.9. |
|---|
| .. | .. |
|---|
| 8 | 9 | Copyright (C) Andrew Bartlett <abartlet@samba.org> 2002-2003 |
|---|
| 9 | 10 | Modified by Steve French (sfrench@us.ibm.com) 2002-2003 |
|---|
| 10 | 11 | |
|---|
| 11 | | - This program is free software; you can redistribute it and/or modify |
|---|
| 12 | | - it under the terms of the GNU General Public License as published by |
|---|
| 13 | | - the Free Software Foundation; either version 2 of the License, or |
|---|
| 14 | | - (at your option) any later version. |
|---|
| 15 | | - |
|---|
| 16 | | - This program is distributed in the hope that it will be useful, |
|---|
| 17 | | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 18 | | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 19 | | - GNU General Public License for more details. |
|---|
| 20 | | - |
|---|
| 21 | | - You should have received a copy of the GNU General Public License |
|---|
| 22 | | - along with this program; if not, write to the Free Software |
|---|
| 23 | | - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|---|
| 24 | 12 | */ |
|---|
| 25 | 13 | |
|---|
| 26 | | -#include <linux/crypto.h> |
|---|
| 27 | 14 | #include <linux/module.h> |
|---|
| 28 | 15 | #include <linux/slab.h> |
|---|
| 16 | +#include <linux/fips.h> |
|---|
| 29 | 17 | #include <linux/fs.h> |
|---|
| 30 | 18 | #include <linux/string.h> |
|---|
| 31 | 19 | #include <linux/kernel.h> |
|---|
| 32 | 20 | #include <linux/random.h> |
|---|
| 21 | +#include <crypto/des.h> |
|---|
| 33 | 22 | #include "cifs_fs_sb.h" |
|---|
| 34 | 23 | #include "cifs_unicode.h" |
|---|
| 35 | 24 | #include "cifspdu.h" |
|---|
| .. | .. |
|---|
| 70 | 59 | smbhash(unsigned char *out, const unsigned char *in, unsigned char *key) |
|---|
| 71 | 60 | { |
|---|
| 72 | 61 | unsigned char key2[8]; |
|---|
| 73 | | - struct crypto_cipher *tfm_des; |
|---|
| 62 | + struct des_ctx ctx; |
|---|
| 74 | 63 | |
|---|
| 75 | 64 | str_to_key(key, key2); |
|---|
| 76 | 65 | |
|---|
| 77 | | - tfm_des = crypto_alloc_cipher("des", 0, 0); |
|---|
| 78 | | - if (IS_ERR(tfm_des)) { |
|---|
| 79 | | - cifs_dbg(VFS, "could not allocate des crypto API\n"); |
|---|
| 80 | | - return PTR_ERR(tfm_des); |
|---|
| 66 | + if (fips_enabled) { |
|---|
| 67 | + cifs_dbg(VFS, "FIPS compliance enabled: DES not permitted\n"); |
|---|
| 68 | + return -ENOENT; |
|---|
| 81 | 69 | } |
|---|
| 82 | 70 | |
|---|
| 83 | | - crypto_cipher_setkey(tfm_des, key2, 8); |
|---|
| 84 | | - crypto_cipher_encrypt_one(tfm_des, out, in); |
|---|
| 85 | | - crypto_free_cipher(tfm_des); |
|---|
| 71 | + des_expand_key(&ctx, key2, DES_KEY_SIZE); |
|---|
| 72 | + des_encrypt(&ctx, out, in); |
|---|
| 73 | + memzero_explicit(&ctx, sizeof(ctx)); |
|---|
| 86 | 74 | |
|---|
| 87 | 75 | return 0; |
|---|
| 88 | 76 | } |
|---|