This commit is contained in:
danogentili 2016-08-06 00:45:17 +02:00
parent b6aed57a46
commit 1ae804dfce

View File

@ -319,11 +319,11 @@ class Session
public function aes_calculate($msg_key, $direction = 'to server')
{
$x = ($direction == 'to server') ? 0 : 8;
$sha1_a = sha1($msg_key . substr($this->auth_key, $x, ($x + 32) - $x)), true);
$sha1_a = sha1($msg_key . substr($this->auth_key, $x, ($x + 32) - $x), true);
$sha1_b = sha1(substr($this->auth_key, ($x + 32), ($x + 48) - ($x + 32)) . $msg_key . substr($this->auth_key, (48 + $x), (64 + $x) - (48 + $x)), true);
$sha1_c = sha1(substr($this->auth_key, ($x + 64), ($x + 96) - ($x + 64)) . $msg_key, true);
$sha1_d = sha1($msg_key . substr($this->auth_key, ($x + 96), ($x + 128) - ($x + 96)), true);
$aes_key = substr($sha1_a, 0, 8 - 0) . substr($sha1_b, 8, 20 - 8)) . substr($sha1_c, 4, 16 - 4;
$aes_key = substr($sha1_a, 0, 8 - 0) . substr($sha1_b, 8, 20 - 8) . substr($sha1_c, 4, 16 - 4);
$aes_iv = substr($sha1_a, 8, 20 - 8) . substr($sha1_b, 0, 8 - 0) . substr($sha1_c, 16, 20 - 16) . substr($sha1_d, 0, 8 - 0);
return [$aes_key, $aes_iv];