diff options
author | Jeremy Allison <jra@samba.org> | 2001-07-30 20:25:35 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2001-07-30 20:25:35 +0000 |
commit | d17d9bee6f3d23f31f6b408e7b80630d4602c9c2 (patch) | |
tree | d0f99322e5260983b77b86a985f8e12f1cfb1ee9 | |
parent | f31a7ab1e27898f2c24da62d3a37da42849cdde4 (diff) | |
download | samba-d17d9bee6f3d23f31f6b408e7b80630d4602c9c2.tar.gz samba-d17d9bee6f3d23f31f6b408e7b80630d4602c9c2.tar.bz2 samba-d17d9bee6f3d23f31f6b408e7b80630d4602c9c2.zip |
Throw out crappy (non-ascii unaware) mbtows stuff and use proper unicode
push calls. If this breaks authentication then good, it needed fixing anyway :-).
Jeremy.
(This used to be commit e3580b4033c551e215cb246d4e36c4870cb4a582)
-rw-r--r-- | source3/libsmb/smbencrypt.c | 63 |
1 files changed, 6 insertions, 57 deletions
diff --git a/source3/libsmb/smbencrypt.c b/source3/libsmb/smbencrypt.c index e7ebd4c000..95d21dc772 100644 --- a/source3/libsmb/smbencrypt.c +++ b/source3/libsmb/smbencrypt.c @@ -53,56 +53,6 @@ void SMBencrypt(uchar *passwd, uchar *c8, uchar *p24) #endif } -/* Routines for Windows NT MD4 Hash functions. */ -static int _my_wcslen(int16 *str) -{ - int len = 0; - while(*str++ != 0) - len++; - return len; -} - -/* - * Convert a string into an NT UNICODE string. - * Note that regardless of processor type - * this must be in intel (little-endian) - * format. - */ - -static int _my_mbstowcs(int16 *dst, uchar *src, int len) -{ - int i; - int16 val; - - for(i = 0; i < len; i++) { - val = *src; - SSVAL(dst,0,val); - dst++; - src++; - if(val == 0) - break; - } - return i; -} - -static int _my_mbstowcsupper(int16 * dst, const uchar * src, int len) -{ - int i; - int16 val; - - for (i = 0; i < len; i++) - { - val = toupper(*src); - SSVAL(dst, 0, val); - dst++; - src++; - if (val == 0) - break; - } - return i; -} - - /* * Creates the MD4 Hash of the users password in NT UNICODE. */ @@ -110,17 +60,16 @@ static int _my_mbstowcsupper(int16 * dst, const uchar * src, int len) void E_md4hash(uchar *passwd, uchar *p16) { int len; - int16 wpwd[129]; + smb_ucs2_t wpwd[129]; /* Password cannot be longer than 128 characters */ len = strlen((char *)passwd); if(len > 128) len = 128; - /* Password must be converted to NT unicode */ - _my_mbstowcs(wpwd, passwd, len); - wpwd[len] = 0; /* Ensure string is null terminated */ + /* Password must be converted to NT unicode - null terminated. */ + push_ucs2(NULL, wpwd, passwd, 256, STR_UNICODE|STR_NOALIGN|STR_TERMINATE); /* Calculate length in bytes */ - len = _my_wcslen(wpwd) * sizeof(int16); + len = strlen_w(wpwd) * sizeof(int16); mdfour(p16, (unsigned char *)wpwd, len); } @@ -172,8 +121,8 @@ void ntv2_owf_gen(const uchar owf[16], int user_l = strlen(user_n); int domain_l = strlen(domain_n); - _my_mbstowcsupper((int16 *) user_u, user_n, user_l * 2); - _my_mbstowcsupper((int16 *) dom_u, domain_n, domain_l * 2); + 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); hmac_md5_init_limK_to_64(owf, 16, &ctx); hmac_md5_update(user_u, user_l * 2, &ctx); |