X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=fs%2Fcifs%2Fsmbencrypt.c;h=ff3232fa1015b4bebdcfeaa5d49a4bc365b21276;hb=6050247d8089037d6d8ea0f3c62fe4a931c1ab14;hp=f518c5e45035c50955b51c55d08ab86b66127842;hpb=3979877e5606ecc58c5a31bd0078c6d80ba9cbe7;p=safe%2Fjmp%2Flinux-2.6 diff --git a/fs/cifs/smbencrypt.c b/fs/cifs/smbencrypt.c index f518c5e..ff3232f 100644 --- a/fs/cifs/smbencrypt.c +++ b/fs/cifs/smbencrypt.c @@ -1,4 +1,4 @@ -/* +/* Unix SMB/Netbios implementation. Version 1.9. SMB parameters and setup @@ -7,17 +7,17 @@ Modified by Jeremy Allison 1995. Copyright (C) Andrew Bartlett 2002-2003 Modified by Steve French (sfrench@us.ibm.com) 2002-2003 - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -35,11 +35,11 @@ #include "cifs_debug.h" #include "cifsencrypt.h" -#ifndef FALSE -#define FALSE 0 +#ifndef false +#define false 0 #endif -#ifndef TRUE -#define TRUE 1 +#ifndef true +#define true 1 #endif /* following came from the other byteorder.h to avoid include conflicts */ @@ -51,16 +51,13 @@ void SMBencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24); void E_md4hash(const unsigned char *passwd, unsigned char *p16); -void nt_lm_owf_gen(char *pwd, unsigned char nt_p16[16], unsigned char p16[16]); static void SMBOWFencrypt(unsigned char passwd[16], unsigned char *c8, unsigned char p24[24]); -void NTLMSSPOWFencrypt(unsigned char passwd[8], - unsigned char *ntlmchalresp, unsigned char p24[24]); void SMBNTencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24); /* This implements the X/Open SMB password encryption - It takes a password, a 8 byte "crypt key" and puts 24 bytes of + It takes a password, a 8 byte "crypt key" and puts 24 bytes of encrypted password into p24 */ /* Note that password must be uppercased and null terminated */ void @@ -76,14 +73,14 @@ SMBencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24) E_P16(p14, p21); SMBOWFencrypt(p21, c8, p24); - - memset(p14,0,15); - memset(p21,0,21); + + memset(p14, 0, 15); + memset(p21, 0, 21); } /* Routines for Windows NT MD4 Hash functions. */ static int -_my_wcslen(__u16 * str) +_my_wcslen(__u16 *str) { int len = 0; while (*str++ != 0) @@ -93,14 +90,14 @@ _my_wcslen(__u16 * str) /* * Convert a string into an NT UNICODE string. - * Note that regardless of processor type + * Note that regardless of processor type * this must be in intel (little-endian) * format. */ static int -_my_mbstowcs(__u16 * dst, const unsigned char *src, int len) -{ /* not a very good conversion routine - change/fix */ +_my_mbstowcs(__u16 *dst, const unsigned char *src, int len) +{ /* BB not a very good conversion routine - change/fix */ int i; __u16 val; @@ -115,7 +112,7 @@ _my_mbstowcs(__u16 * dst, const unsigned char *src, int len) return i; } -/* +/* * Creates the MD4 Hash of the users password in NT UNICODE. */ @@ -126,11 +123,11 @@ E_md4hash(const unsigned char *passwd, unsigned char *p16) __u16 wpwd[129]; /* Password cannot be longer than 128 characters */ - if(passwd) { + if (passwd) { len = strlen((char *) passwd); - if (len > 128) { + if (len > 128) len = 128; - } + /* Password must be converted to NT unicode */ _my_mbstowcs(wpwd, passwd, len); } else @@ -138,14 +135,15 @@ E_md4hash(const unsigned char *passwd, unsigned char *p16) wpwd[len] = 0; /* Ensure string is null terminated */ /* Calculate length in bytes */ - len = _my_wcslen(wpwd) * sizeof (__u16); + len = _my_wcslen(wpwd) * sizeof(__u16); mdfour(p16, (unsigned char *) wpwd, len); - memset(wpwd,0,129 * 2); + memset(wpwd, 0, 129 * 2); } +#if 0 /* currently unused */ /* Does both the NT and LM owfs of a user's password */ -void +static void nt_lm_owf_gen(char *pwd, unsigned char nt_p16[16], unsigned char p16[16]) { char passwd[514]; @@ -169,8 +167,9 @@ nt_lm_owf_gen(char *pwd, unsigned char nt_p16[16], unsigned char p16[16]) E_P16((unsigned char *) passwd, (unsigned char *) p16); /* clear out local copy of user's password (just being paranoid). */ - memset(passwd, '\0', sizeof (passwd)); + memset(passwd, '\0', sizeof(passwd)); } +#endif /* Does the NTLMv2 owfs of a user's password */ #if 0 /* function not needed yet - but will be soon */ @@ -179,19 +178,21 @@ ntv2_owf_gen(const unsigned char owf[16], const char *user_n, const char *domain_n, unsigned char kr_buf[16], const struct nls_table *nls_codepage) { - wchar_t * user_u; - wchar_t * dom_u; + wchar_t *user_u; + wchar_t *dom_u; int user_l, domain_l; struct HMACMD5Context ctx; /* might as well do one alloc to hold both (user_u and dom_u) */ - user_u = kmalloc(2048 * sizeof(wchar_t),GFP_KERNEL); - if(user_u == NULL) + user_u = kmalloc(2048 * sizeof(wchar_t), GFP_KERNEL); + if (user_u == NULL) return; dom_u = user_u + 1024; - - /* push_ucs2(NULL, user_u, user_n, (user_l+1)*2, STR_UNICODE|STR_NOALIGN|STR_TERMINATE|STR_UPPER); - push_ucs2(NULL, dom_u, domain_n, (domain_l+1)*2, STR_UNICODE|STR_NOALIGN|STR_TERMINATE|STR_UPPER); */ + + /* push_ucs2(NULL, user_u, user_n, (user_l+1)*2, + STR_UNICODE|STR_NOALIGN|STR_TERMINATE|STR_UPPER); + push_ucs2(NULL, dom_u, domain_n, (domain_l+1)*2, + STR_UNICODE|STR_NOALIGN|STR_TERMINATE|STR_UPPER); */ /* BB user and domain may need to be uppercased */ user_l = cifs_strtoUCS(user_u, user_n, 511, nls_codepage); @@ -207,7 +208,7 @@ ntv2_owf_gen(const unsigned char owf[16], const char *user_n, kfree(user_u); } -#endif +#endif /* Does the des encryption from the NT or LM MD4 hash. */ static void @@ -223,7 +224,8 @@ SMBOWFencrypt(unsigned char passwd[16], unsigned char *c8, } /* Does the des encryption from the FIRST 8 BYTES of the NT or LM MD4 hash. */ -void +#if 0 /* currently unused */ +static void NTLMSSPOWFencrypt(unsigned char passwd[8], unsigned char *ntlmchalresp, unsigned char p24[24]) { @@ -235,6 +237,7 @@ NTLMSSPOWFencrypt(unsigned char passwd[8], E_P24(p21, ntlmchalresp, p24); } +#endif /* Does the NT MD4 hash then des encryption. */ @@ -255,15 +258,15 @@ SMBNTencrypt(unsigned char *passwd, unsigned char *c8, unsigned char *p24) #if 0 static void SMBOWFencrypt_ntv2(const unsigned char kr[16], - const struct data_blob * srv_chal, - const struct data_blob * cli_chal, unsigned char resp_buf[16]) + const struct data_blob *srv_chal, + const struct data_blob *cli_chal, unsigned char resp_buf[16]) { - struct HMACMD5Context ctx; + struct HMACMD5Context ctx; - hmac_md5_init_limK_to_64(kr, 16, &ctx); - hmac_md5_update(srv_chal->data, srv_chal->length, &ctx); - hmac_md5_update(cli_chal->data, cli_chal->length, &ctx); - hmac_md5_final(resp_buf, &ctx); + hmac_md5_init_limK_to_64(kr, 16, &ctx); + hmac_md5_update(srv_chal->data, srv_chal->length, &ctx); + hmac_md5_update(cli_chal->data, cli_chal->length, &ctx); + hmac_md5_final(resp_buf, &ctx); } static void