EncryptionContext: provide the packet ID in the exception message

This commit is contained in:
Dylan K. Taylor 2020-11-10 14:45:19 +00:00
parent 6a266bcbd1
commit e23379c34b

View File

@ -75,8 +75,10 @@ class EncryptionContext{
$decrypted = $this->decryptCipher->decryptUpdate($encrypted);
$payload = substr($decrypted, 0, -8);
if(($expected = $this->calculateChecksum($this->decryptCounter++, $payload)) !== ($actual = substr($decrypted, -8))){
throw new DecryptionException("Encrypted payload has invalid checksum (expected " . bin2hex($expected) . ", got " . bin2hex($actual) . ")");
$packetCounter = $this->decryptCounter++;
if(($expected = $this->calculateChecksum($packetCounter, $payload)) !== ($actual = substr($decrypted, -8))){
throw new DecryptionException("Encrypted packet $packetCounter has invalid checksum (expected " . bin2hex($expected) . ", got " . bin2hex($actual) . ")");
}
return $payload;