From 6bd4e6018edecc27e8e76a3e8409ab1a161140b2 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sun, 29 Mar 2015 15:26:15 -0500 Subject: [PATCH] Crypt/Base: rm redundant null padding --- phpseclib/Crypt/Base.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/phpseclib/Crypt/Base.php b/phpseclib/Crypt/Base.php index 73886502..5bd50862 100644 --- a/phpseclib/Crypt/Base.php +++ b/phpseclib/Crypt/Base.php @@ -979,7 +979,8 @@ class Crypt_Base function decrypt($ciphertext) { if ($this->paddable) { - // we pad with chr(0) since that's what mcrypt_generic does [...] + // we pad with chr(0) since that's what mcrypt_generic does. to quote from {@link http://www.php.net/function.mcrypt-generic}: + // "The data is padded with "\0" to make sure the length of the data is n * blocksize." $ciphertext = str_pad($ciphertext, strlen($ciphertext) + ($this->block_size - strlen($ciphertext) % $this->block_size) % $this->block_size, chr(0)); } @@ -1112,12 +1113,6 @@ class Crypt_Base return $plaintext; } - if ($this->paddable) { - // we pad with chr(0) since that's what mcrypt_generic does. to quote from {@link http://www.php.net/function.mcrypt-generic}: - // "The data is padded with "\0" to make sure the length of the data is n * blocksize." - $ciphertext = str_pad($ciphertext, strlen($ciphertext) + ($block_size - strlen($ciphertext) % $block_size) % $block_size, chr(0)); - } - $plaintext = mdecrypt_generic($this->demcrypt, $ciphertext); if (!$this->continuousBuffer) {