private function PHPExcel_Reader_Excel5::_verifyPassword in Loft Data Grids 7.2
Same name and namespace in other branches
- 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel5.php \PHPExcel_Reader_Excel5::_verifyPassword()
* Verify RC4 file password * * * @var string $docid Document id * @var string $salt_data Salt data * @var string $hashedsalt_data Hashed salt data * @var string &$valContext Set to the MD5 context of the value * *
Return value
bool Success
1 call to PHPExcel_Reader_Excel5::_verifyPassword()
- PHPExcel_Reader_Excel5::_readFilepass in vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Reader/ Excel5.php - * FILEPASS * * This record is part of the File Protection Block. It * contains information about the read/write password of the * file. All record contents following this record will be * encrypted. * * -- "OpenOffice.org's…
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Reader/ Excel5.php, line 1742
Class
- PHPExcel_Reader_Excel5
- PHPExcel_Reader_Excel5
Code
private function _verifyPassword($password, $docid, $salt_data, $hashedsalt_data, &$valContext) {
$pwarray = str_repeat("\0", 64);
for ($i = 0; $i < strlen($password); $i++) {
$o = ord(substr($password, $i, 1));
$pwarray[2 * $i] = chr($o & 0xff);
$pwarray[2 * $i + 1] = chr($o >> 8 & 0xff);
}
$pwarray[2 * $i] = chr(0x80);
$pwarray[56] = chr($i << 4 & 0xff);
$md5 = new PHPExcel_Reader_Excel5_MD5();
$md5
->add($pwarray);
$mdContext1 = $md5
->getContext();
$offset = 0;
$keyoffset = 0;
$tocopy = 5;
$md5
->reset();
while ($offset != 16) {
if (64 - $offset < 5) {
$tocopy = 64 - $offset;
}
for ($i = 0; $i <= $tocopy; $i++) {
$pwarray[$offset + $i] = $mdContext1[$keyoffset + $i];
}
$offset += $tocopy;
if ($offset == 64) {
$md5
->add($pwarray);
$keyoffset = $tocopy;
$tocopy = 5 - $tocopy;
$offset = 0;
continue;
}
$keyoffset = 0;
$tocopy = 5;
for ($i = 0; $i < 16; $i++) {
$pwarray[$offset + $i] = $docid[$i];
}
$offset += 16;
}
$pwarray[16] = "";
for ($i = 0; $i < 47; $i++) {
$pwarray[17 + $i] = "\0";
}
$pwarray[56] = "";
$pwarray[57] = "\n";
$md5
->add($pwarray);
$valContext = $md5
->getContext();
$key = $this
->_makeKey(0, $valContext);
$salt = $key
->RC4($salt_data);
$hashedsalt = $key
->RC4($hashedsalt_data);
$salt .= "" . str_repeat("\0", 47);
$salt[56] = "";
$md5
->reset();
$md5
->add($salt);
$mdContext2 = $md5
->getContext();
return $mdContext2 == $hashedsalt;
}