1 // SPDX-License-Identifier: GPL-2.0-or-later 1 2 /* 3 Unix SMB/Netbios implementation. 4 Version 1.9. 5 SMB parameters and setup 6 Copyright (C) Andrew Tridgell 1992-2000 7 Copyright (C) Luke Kenneth Casson Leighton 8 Modified by Jeremy Allison 1995. 9 Copyright (C) Andrew Bartlett <abartlet@sam 10 Modified by Steve French (sfrench@us.ibm.co 11 12 */ 13 14 #include <linux/module.h> 15 #include <linux/slab.h> 16 #include <linux/fips.h> 17 #include <linux/fs.h> 18 #include <linux/string.h> 19 #include <linux/kernel.h> 20 #include <linux/random.h> 21 #include "cifs_fs_sb.h" 22 #include "cifs_unicode.h" 23 #include "cifspdu.h" 24 #include "cifsglob.h" 25 #include "cifs_debug.h" 26 #include "cifsproto.h" 27 #include "../common/md4.h" 28 29 /* following came from the other byteorder.h t 30 #define CVAL(buf,pos) (((unsigned char *)(buf) 31 #define SSVALX(buf,pos,val) (CVAL(buf,pos)=(va 32 #define SSVAL(buf,pos,val) SSVALX((buf),(pos), 33 34 /* produce a md4 message digest from data of l 35 static int 36 mdfour(unsigned char *md4_hash, unsigned char 37 { 38 int rc; 39 struct md4_ctx mctx; 40 41 rc = cifs_md4_init(&mctx); 42 if (rc) { 43 cifs_dbg(VFS, "%s: Could not i 44 goto mdfour_err; 45 } 46 rc = cifs_md4_update(&mctx, link_str, 47 if (rc) { 48 cifs_dbg(VFS, "%s: Could not u 49 goto mdfour_err; 50 } 51 rc = cifs_md4_final(&mctx, md4_hash); 52 if (rc) 53 cifs_dbg(VFS, "%s: Could not f 54 55 56 mdfour_err: 57 return rc; 58 } 59 60 /* 61 * Creates the MD4 Hash of the users password 62 */ 63 64 int 65 E_md4hash(const unsigned char *passwd, unsigne 66 const struct nls_table *codepage) 67 { 68 int rc; 69 int len; 70 __le16 wpwd[129]; 71 72 /* Password cannot be longer than 128 73 if (passwd) /* Password must be conver 74 len = cifs_strtoUTF16(wpwd, pa 75 else { 76 len = 0; 77 *wpwd = 0; /* Ensure string is 78 } 79 80 rc = mdfour(p16, (unsigned char *) wpw 81 memzero_explicit(wpwd, sizeof(wpwd)); 82 83 return rc; 84 } 85
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.