Apply fixes from StyleCI

This commit is contained in:
Daniil Gentili 2017-12-09 11:40:05 +00:00 committed by StyleCI Bot
parent 29a19c173c
commit 09b9ff319c
2 changed files with 4 additions and 3 deletions

View File

@ -35,7 +35,6 @@ trait Crypt
$aes_key = substr($sha1_a, 0, 8).substr($sha1_b, 8, 12).substr($sha1_c, 4, 12); $aes_key = substr($sha1_a, 0, 8).substr($sha1_b, 8, 12).substr($sha1_c, 4, 12);
$aes_iv = substr($sha1_a, 8, 12).substr($sha1_b, 0, 8).substr($sha1_c, 16, 4).substr($sha1_d, 0, 8); $aes_iv = substr($sha1_a, 8, 12).substr($sha1_b, 0, 8).substr($sha1_c, 16, 4).substr($sha1_d, 0, 8);
return [$aes_key, $aes_iv]; return [$aes_key, $aes_iv];
} }

View File

@ -39,7 +39,9 @@ trait MessageHandler
$seq_no = $this->generate_out_seq_no($aargs['datacenter'], $content_related); $seq_no = $this->generate_out_seq_no($aargs['datacenter'], $content_related);
$plaintext = $this->datacenter->sockets[$aargs['datacenter']]->temp_auth_key['server_salt'].$this->datacenter->sockets[$aargs['datacenter']]->session_id.$message_id.pack('VV', $seq_no, strlen($message_data)).$message_data; $plaintext = $this->datacenter->sockets[$aargs['datacenter']]->temp_auth_key['server_salt'].$this->datacenter->sockets[$aargs['datacenter']]->session_id.$message_id.pack('VV', $seq_no, strlen($message_data)).$message_data;
$padding = $this->posmod(-strlen($plaintext), 16); $padding = $this->posmod(-strlen($plaintext), 16);
if ($padding < 12) $padding += 16; if ($padding < 12) {
$padding += 16;
}
$padding = $this->random($padding); $padding = $this->random($padding);
$message_key = substr(hash('sha256', substr($this->datacenter->sockets[$aargs['datacenter']]->temp_auth_key['auth_key'], 88, 32).$plaintext.$padding, true), 8, 16); $message_key = substr(hash('sha256', substr($this->datacenter->sockets[$aargs['datacenter']]->temp_auth_key['auth_key'], 88, 32).$plaintext.$padding, true), 8, 16);