mirror of
https://github.com/Ne-Lexa/php-zip.git
synced 2025-10-19 09:06:17 +02:00
Fixed bug from issues 1
- Fixed encryption and decryption Traditional PKWARE Encryption - add casting to 32-bit integer. - The restriction on the length of the password to 99 characters for the WinZIP AES Encryption method.
This commit is contained in:
@@ -105,9 +105,26 @@ class TraditionalPkwareEncryptionEngine
|
||||
private function updateKeys($charAt)
|
||||
{
|
||||
$this->keys[0] = self::crc32($this->keys[0], $charAt);
|
||||
$this->keys[1] = ($this->keys[1] + ($this->keys[0] & 0xff)) & 4294967295;
|
||||
$this->keys[1] = ($this->keys[1] * 134775813 + 1) & 4294967295;
|
||||
$this->keys[2] = self::crc32($this->keys[2], ($this->keys[1] >> 24) & 0xff);
|
||||
$this->keys[1] = $this->keys[1] + ($this->keys[0] & 0xff);
|
||||
$this->keys[1] = self::toInt($this->keys[1] * 134775813 + 1);
|
||||
$this->keys[2] = self::toInt(self::crc32($this->keys[2], ($this->keys[1] >> 24) & 0xff));
|
||||
}
|
||||
|
||||
/**
|
||||
* Cast to int
|
||||
*
|
||||
* @param $i
|
||||
* @return int
|
||||
*/
|
||||
private static function toInt($i)
|
||||
{
|
||||
$i = (int)($i & 0xffffffff);
|
||||
if ($i > 2147483647) {
|
||||
return -(-$i & 0xffffffff);
|
||||
} elseif ($i < -2147483648) {
|
||||
return $i & -2147483648;
|
||||
}
|
||||
return $i;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user