fixed NT hash

This commit is contained in:
Roland Gruber 2006-03-08 19:36:01 +00:00
parent b2c178c42e
commit c0e3d21ca7
2 changed files with 26 additions and 2 deletions

View File

@ -1,5 +1,7 @@
??? 1.0.1
- merged password hash settings for Unix users and groups
- fixed bugs:
-> Samba hash values were wrong in some rare cases (1440021)
01.03.2006 1.0.0

View File

@ -133,6 +133,14 @@ var $sbox = array(array(array(14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5
array( 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8),
array( 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11)));
/**
* Fixes too large numbers
*/
function x($i) {
if ($i < 0) return 4294967296 - $i;
else return $i;
}
/**
* @param integer count
* @param array $data
@ -335,7 +343,11 @@ var $sbox = array(array(array(14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5
# Support functions
# Ported from SAMBA/source/lib/md4.c:F,G and H respectfully
function F($X, $Y, $Z) {
return ($X&$Y) | ((~$X)&$Z);
$ret = (($X&$Y) | ((~((int)$X))&$Z));
if ($this->x($ret) > 4294967296) {
$ret = (2*4294967296) - $this->x($ret);
}
return $ret;
}
function G($X, $Y, $Z) {
@ -467,6 +479,9 @@ var $sbox = array(array(array(14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5
$sum[1] &= 0xffff;
$sum[0] &= 0xffff;
$ret = ($sum[0]<<16) | $sum[1];
if ($this->x($ret) > 4294967296) {
$ret = (2*4294967296) - $this->x($ret);
}
return $ret;
}
@ -492,7 +507,14 @@ var $sbox = array(array(array(14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5
# Renamed to prevent clash with SAMBA/source/libsmb/smbdes.c:lshift
function md4lshift($x, $s) {
$x &= 0xFFFFFFFF;
return ((($x<<$s)&0xFFFFFFFF) | $this->unsigned_shift_r($x, (32-$s)));
if ($this->x($x) > 4294967296) {
$x = (2*4294967296) - $this->x($x);
}
$ret = ((($x<<$s)&0xFFFFFFFF) | $this->unsigned_shift_r($x, (32-$s)));
if ($this->x($ret) > 4294967296) {
$ret = (2*4294967296) - $this->x($ret);
}
return $ret;
}
/**