mirror of
https://github.com/danog/tgseclib.git
synced 2024-11-27 12:44:38 +01:00
CFB didn't always work in continuous mode
This commit is contained in:
parent
61ad80fd64
commit
c1244dd339
@ -777,12 +777,14 @@ class Crypt_DES {
|
|||||||
if (strlen($buffer['ciphertext'])) {
|
if (strlen($buffer['ciphertext'])) {
|
||||||
$plaintext = $ciphertext ^ substr($this->decryptIV, strlen($buffer['ciphertext']));
|
$plaintext = $ciphertext ^ substr($this->decryptIV, strlen($buffer['ciphertext']));
|
||||||
$buffer['ciphertext'].= substr($ciphertext, 0, strlen($plaintext));
|
$buffer['ciphertext'].= substr($ciphertext, 0, strlen($plaintext));
|
||||||
if (strlen($buffer['ciphertext']) == 8) {
|
if (strlen($buffer['ciphertext']) != 8) {
|
||||||
|
$block = $this->decryptIV;
|
||||||
|
} else {
|
||||||
|
$block = $buffer['ciphertext'];
|
||||||
$xor = $this->_processBlock($buffer['ciphertext'], CRYPT_DES_ENCRYPT);
|
$xor = $this->_processBlock($buffer['ciphertext'], CRYPT_DES_ENCRYPT);
|
||||||
$buffer['ciphertext'] = '';
|
$buffer['ciphertext'] = '';
|
||||||
}
|
}
|
||||||
$start = strlen($plaintext);
|
$start = strlen($plaintext);
|
||||||
$block = $this->decryptIV;
|
|
||||||
} else {
|
} else {
|
||||||
$plaintext = '';
|
$plaintext = '';
|
||||||
$xor = $this->_processBlock($this->decryptIV, CRYPT_DES_ENCRYPT);
|
$xor = $this->_processBlock($this->decryptIV, CRYPT_DES_ENCRYPT);
|
||||||
|
@ -887,12 +887,14 @@ class Crypt_Rijndael {
|
|||||||
if (strlen($buffer['ciphertext'])) {
|
if (strlen($buffer['ciphertext'])) {
|
||||||
$plaintext = $ciphertext ^ substr($this->decryptIV, strlen($buffer['ciphertext']));
|
$plaintext = $ciphertext ^ substr($this->decryptIV, strlen($buffer['ciphertext']));
|
||||||
$buffer['ciphertext'].= substr($ciphertext, 0, strlen($plaintext));
|
$buffer['ciphertext'].= substr($ciphertext, 0, strlen($plaintext));
|
||||||
if (strlen($buffer['ciphertext']) == $block_size) {
|
if (strlen($buffer['ciphertext']) != $block_size) {
|
||||||
|
$block = $this->decryptIV;
|
||||||
|
} else {
|
||||||
|
$block = $buffer['ciphertext'];
|
||||||
$xor = $this->_encryptBlock($buffer['ciphertext']);
|
$xor = $this->_encryptBlock($buffer['ciphertext']);
|
||||||
$buffer['ciphertext'] = '';
|
$buffer['ciphertext'] = '';
|
||||||
}
|
}
|
||||||
$start = strlen($plaintext);
|
$start = strlen($plaintext);
|
||||||
$block = $this->decryptIV;
|
|
||||||
} else {
|
} else {
|
||||||
$plaintext = '';
|
$plaintext = '';
|
||||||
$xor = $this->_encryptBlock($this->decryptIV);
|
$xor = $this->_encryptBlock($this->decryptIV);
|
||||||
|
@ -825,14 +825,16 @@ class Crypt_TripleDES {
|
|||||||
if (strlen($buffer['ciphertext'])) {
|
if (strlen($buffer['ciphertext'])) {
|
||||||
$plaintext = $ciphertext ^ substr($this->decryptIV, strlen($buffer['ciphertext']));
|
$plaintext = $ciphertext ^ substr($this->decryptIV, strlen($buffer['ciphertext']));
|
||||||
$buffer['ciphertext'].= substr($ciphertext, 0, strlen($plaintext));
|
$buffer['ciphertext'].= substr($ciphertext, 0, strlen($plaintext));
|
||||||
if (strlen($buffer['ciphertext']) == 8) {
|
if (strlen($buffer['ciphertext']) != 8) {
|
||||||
|
$block = $this->decryptIV;
|
||||||
|
} else {
|
||||||
|
$block = $buffer['ciphertext'];
|
||||||
$xor = $des[0]->_processBlock($buffer['ciphertext'], CRYPT_DES_ENCRYPT);
|
$xor = $des[0]->_processBlock($buffer['ciphertext'], CRYPT_DES_ENCRYPT);
|
||||||
$xor = $des[1]->_processBlock($xor, CRYPT_DES_DECRYPT);
|
$xor = $des[1]->_processBlock($xor, CRYPT_DES_DECRYPT);
|
||||||
$xor = $des[2]->_processBlock($xor, CRYPT_DES_ENCRYPT);
|
$xor = $des[2]->_processBlock($xor, CRYPT_DES_ENCRYPT);
|
||||||
$buffer['ciphertext'] = '';
|
$buffer['ciphertext'] = '';
|
||||||
}
|
}
|
||||||
$start = strlen($plaintext);
|
$start = strlen($plaintext);
|
||||||
$block = $this->decryptIV;
|
|
||||||
} else {
|
} else {
|
||||||
$plaintext = '';
|
$plaintext = '';
|
||||||
$xor = $des[0]->_processBlock($this->decryptIV, CRYPT_DES_ENCRYPT);
|
$xor = $des[0]->_processBlock($this->decryptIV, CRYPT_DES_ENCRYPT);
|
||||||
|
Loading…
Reference in New Issue
Block a user