mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-17 02:35:10 +00:00
DES: Fixed CFB decrypt() using MODE_MCRYPT and ContinuousBuffer
DES: Fixed small bug from commit d94f1b252d
(DES.php in line 739-740)
in CFB decrypt() using CRYPT_DES_MODE_MCRYPT and enableContinuousBuffer()
This commit is contained in:
parent
882e019062
commit
bfab4c47f9
@ -536,7 +536,6 @@ class Crypt_DES {
|
|||||||
}
|
}
|
||||||
$ciphertext.= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % 8));
|
$ciphertext.= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % 8));
|
||||||
$iv = substr($ciphertext, -8);
|
$iv = substr($ciphertext, -8);
|
||||||
$i = strlen($ciphertext);
|
|
||||||
$len%= 8;
|
$len%= 8;
|
||||||
} else {
|
} else {
|
||||||
while ($len >= 8) {
|
while ($len >= 8) {
|
||||||
@ -549,7 +548,7 @@ class Crypt_DES {
|
|||||||
}
|
}
|
||||||
if ($len) {
|
if ($len) {
|
||||||
$iv = mcrypt_generic($this->ecb, $iv);
|
$iv = mcrypt_generic($this->ecb, $iv);
|
||||||
$block = $iv ^ substr($plaintext, $i);
|
$block = $iv ^ substr($plaintext, -$len);
|
||||||
$iv = substr_replace($iv, $block, 0, $len);
|
$iv = substr_replace($iv, $block, 0, $len);
|
||||||
$ciphertext.= $block;
|
$ciphertext.= $block;
|
||||||
$pos = $len;
|
$pos = $len;
|
||||||
@ -726,7 +725,6 @@ class Crypt_DES {
|
|||||||
}
|
}
|
||||||
$plaintext = substr($iv, $orig_pos) ^ $ciphertext;
|
$plaintext = substr($iv, $orig_pos) ^ $ciphertext;
|
||||||
$iv = substr_replace($iv, substr($ciphertext, 0, $i), $orig_pos, $i);
|
$iv = substr_replace($iv, substr($ciphertext, 0, $i), $orig_pos, $i);
|
||||||
$this->debuffer['demcrypt_init'] = true;
|
|
||||||
}
|
}
|
||||||
if ($len >= 8) {
|
if ($len >= 8) {
|
||||||
$cb = substr($ciphertext, $i, $len - $len % 8);
|
$cb = substr($ciphertext, $i, $len - $len % 8);
|
||||||
@ -736,8 +734,8 @@ class Crypt_DES {
|
|||||||
}
|
}
|
||||||
if ($len) {
|
if ($len) {
|
||||||
$iv = mcrypt_generic($this->ecb, $iv);
|
$iv = mcrypt_generic($this->ecb, $iv);
|
||||||
$plaintext.= $iv ^ substr($ciphertext, $i);
|
$plaintext.= $iv ^ substr($ciphertext, -$len);
|
||||||
$iv = substr_replace($iv, substr($ciphertext, $i, $len), 0, $len);
|
$iv = substr_replace($iv, substr($ciphertext, -$len), 0, $len);
|
||||||
$pos = $len;
|
$pos = $len;
|
||||||
}
|
}
|
||||||
return $plaintext;
|
return $plaintext;
|
||||||
@ -833,7 +831,7 @@ class Crypt_DES {
|
|||||||
if ($len) {
|
if ($len) {
|
||||||
$iv = $this->_processBlock($iv, CRYPT_DES_ENCRYPT);
|
$iv = $this->_processBlock($iv, CRYPT_DES_ENCRYPT);
|
||||||
$plaintext.= $iv ^ substr($ciphertext, $i);
|
$plaintext.= $iv ^ substr($ciphertext, $i);
|
||||||
$iv = substr_replace($iv, substr($ciphertext, $i, $len), 0, $len);
|
$iv = substr_replace($iv, substr($ciphertext, $i), 0, $len);
|
||||||
$pos = $len;
|
$pos = $len;
|
||||||
}
|
}
|
||||||
return $plaintext;
|
return $plaintext;
|
||||||
|
Loading…
Reference in New Issue
Block a user