~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/smb/client/smbencrypt.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /fs/smb/client/smbencrypt.c (Version linux-6.12-rc7) and /fs/smb/client/smbencrypt.c (Version linux-6.5.13)


  1 // SPDX-License-Identifier: GPL-2.0-or-later        1 // SPDX-License-Identifier: GPL-2.0-or-later
  2 /*                                                  2 /*
  3    Unix SMB/Netbios implementation.                 3    Unix SMB/Netbios implementation.
  4    Version 1.9.                                     4    Version 1.9.
  5    SMB parameters and setup                         5    SMB parameters and setup
  6    Copyright (C) Andrew Tridgell 1992-2000          6    Copyright (C) Andrew Tridgell 1992-2000
  7    Copyright (C) Luke Kenneth Casson Leighton       7    Copyright (C) Luke Kenneth Casson Leighton 1996-2000
  8    Modified by Jeremy Allison 1995.                 8    Modified by Jeremy Allison 1995.
  9    Copyright (C) Andrew Bartlett <abartlet@sam      9    Copyright (C) Andrew Bartlett <abartlet@samba.org> 2002-2003
 10    Modified by Steve French (sfrench@us.ibm.co     10    Modified by Steve French (sfrench@us.ibm.com) 2002-2003
 11                                                    11 
 12 */                                                 12 */
 13                                                    13 
 14 #include <linux/module.h>                          14 #include <linux/module.h>
 15 #include <linux/slab.h>                            15 #include <linux/slab.h>
 16 #include <linux/fips.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 "cifs_fs_sb.h"                            21 #include "cifs_fs_sb.h"
 22 #include "cifs_unicode.h"                          22 #include "cifs_unicode.h"
 23 #include "cifspdu.h"                               23 #include "cifspdu.h"
 24 #include "cifsglob.h"                              24 #include "cifsglob.h"
 25 #include "cifs_debug.h"                            25 #include "cifs_debug.h"
 26 #include "cifsproto.h"                             26 #include "cifsproto.h"
 27 #include "../common/md4.h"                         27 #include "../common/md4.h"
 28                                                    28 
                                                   >>  29 #ifndef false
                                                   >>  30 #define false 0
                                                   >>  31 #endif
                                                   >>  32 #ifndef true
                                                   >>  33 #define true 1
                                                   >>  34 #endif
                                                   >>  35 
 29 /* following came from the other byteorder.h t     36 /* following came from the other byteorder.h to avoid include conflicts */
 30 #define CVAL(buf,pos) (((unsigned char *)(buf)     37 #define CVAL(buf,pos) (((unsigned char *)(buf))[pos])
 31 #define SSVALX(buf,pos,val) (CVAL(buf,pos)=(va     38 #define SSVALX(buf,pos,val) (CVAL(buf,pos)=(val)&0xFF,CVAL(buf,pos+1)=(val)>>8)
 32 #define SSVAL(buf,pos,val) SSVALX((buf),(pos),     39 #define SSVAL(buf,pos,val) SSVALX((buf),(pos),((__u16)(val)))
 33                                                    40 
 34 /* produce a md4 message digest from data of l     41 /* produce a md4 message digest from data of length n bytes */
 35 static int                                         42 static int
 36 mdfour(unsigned char *md4_hash, unsigned char      43 mdfour(unsigned char *md4_hash, unsigned char *link_str, int link_len)
 37 {                                                  44 {
 38         int rc;                                    45         int rc;
 39         struct md4_ctx mctx;                       46         struct md4_ctx mctx;
 40                                                    47 
 41         rc = cifs_md4_init(&mctx);                 48         rc = cifs_md4_init(&mctx);
 42         if (rc) {                                  49         if (rc) {
 43                 cifs_dbg(VFS, "%s: Could not i     50                 cifs_dbg(VFS, "%s: Could not init MD4\n", __func__);
 44                 goto mdfour_err;                   51                 goto mdfour_err;
 45         }                                          52         }
 46         rc = cifs_md4_update(&mctx, link_str,      53         rc = cifs_md4_update(&mctx, link_str, link_len);
 47         if (rc) {                                  54         if (rc) {
 48                 cifs_dbg(VFS, "%s: Could not u     55                 cifs_dbg(VFS, "%s: Could not update MD4\n", __func__);
 49                 goto mdfour_err;                   56                 goto mdfour_err;
 50         }                                          57         }
 51         rc = cifs_md4_final(&mctx, md4_hash);      58         rc = cifs_md4_final(&mctx, md4_hash);
 52         if (rc)                                    59         if (rc)
 53                 cifs_dbg(VFS, "%s: Could not f     60                 cifs_dbg(VFS, "%s: Could not finalize MD4\n", __func__);
 54                                                    61 
 55                                                    62 
 56 mdfour_err:                                        63 mdfour_err:
 57         return rc;                                 64         return rc;
 58 }                                                  65 }
 59                                                    66 
 60 /*                                                 67 /*
 61  * Creates the MD4 Hash of the users password      68  * Creates the MD4 Hash of the users password in NT UNICODE.
 62  */                                                69  */
 63                                                    70 
 64 int                                                71 int
 65 E_md4hash(const unsigned char *passwd, unsigne     72 E_md4hash(const unsigned char *passwd, unsigned char *p16,
 66         const struct nls_table *codepage)          73         const struct nls_table *codepage)
 67 {                                                  74 {
 68         int rc;                                    75         int rc;
 69         int len;                                   76         int len;
 70         __le16 wpwd[129];                          77         __le16 wpwd[129];
 71                                                    78 
 72         /* Password cannot be longer than 128      79         /* Password cannot be longer than 128 characters */
 73         if (passwd) /* Password must be conver     80         if (passwd) /* Password must be converted to NT unicode */
 74                 len = cifs_strtoUTF16(wpwd, pa     81                 len = cifs_strtoUTF16(wpwd, passwd, 128, codepage);
 75         else {                                     82         else {
 76                 len = 0;                           83                 len = 0;
 77                 *wpwd = 0; /* Ensure string is     84                 *wpwd = 0; /* Ensure string is null terminated */
 78         }                                          85         }
 79                                                    86 
 80         rc = mdfour(p16, (unsigned char *) wpw     87         rc = mdfour(p16, (unsigned char *) wpwd, len * sizeof(__le16));
 81         memzero_explicit(wpwd, sizeof(wpwd));      88         memzero_explicit(wpwd, sizeof(wpwd));
 82                                                    89 
 83         return rc;                                 90         return rc;
 84 }                                                  91 }
 85                                                    92 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php