mirror of
https://github.com/danog/tgseclib.git
synced 2024-11-30 04:39:02 +01:00
- change $ecb to $this->ecb
git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@124 21d32557-59b3-4da0-833f-c5933fad653e
This commit is contained in:
parent
2140de74d0
commit
a15cf62d3a
@ -56,7 +56,7 @@
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright MMVIII Jim Wigginton
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt
|
||||
* @version $Id: AES.php,v 1.9 2010-09-26 03:10:20 terrafrost Exp $
|
||||
* @version $Id: AES.php,v 1.10 2010-09-26 05:24:52 terrafrost Exp $
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
@ -151,6 +151,16 @@ class Crypt_AES extends Crypt_Rijndael {
|
||||
*/
|
||||
var $demcrypt;
|
||||
|
||||
/**
|
||||
* mcrypt resource for CFB mode
|
||||
*
|
||||
* @see Crypt_AES::encrypt()
|
||||
* @see Crypt_AES::decrypt()
|
||||
* @var String
|
||||
* @access private
|
||||
*/
|
||||
var $ecb;
|
||||
|
||||
/**
|
||||
* Default Constructor.
|
||||
*
|
||||
@ -282,11 +292,9 @@ class Crypt_AES extends Crypt_Rijndael {
|
||||
// using mcrypt's default handing of CFB the above would output two different things. using phpseclib's
|
||||
// rewritten CFB implementation the above outputs the same thing twice.
|
||||
if ($this->mode == 'ncfb') {
|
||||
static $ecb;
|
||||
|
||||
if ($changed) {
|
||||
$ecb = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_ECB, '');
|
||||
mcrypt_generic_init($ecb, $this->key, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");
|
||||
$this->ecb = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_ECB, '');
|
||||
mcrypt_generic_init($this->ecb, $this->key, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");
|
||||
}
|
||||
|
||||
if (strlen($this->enbuffer)) {
|
||||
@ -309,7 +317,7 @@ class Crypt_AES extends Crypt_Rijndael {
|
||||
if (strlen($ciphertext)) {
|
||||
$this->encryptIV = substr($ciphertext, -16);
|
||||
}
|
||||
$this->encryptIV = mcrypt_generic($ecb, $this->encryptIV);
|
||||
$this->encryptIV = mcrypt_generic($this->ecb, $this->encryptIV);
|
||||
$this->enbuffer = substr($plaintext, $last_pos) ^ $this->encryptIV;
|
||||
$ciphertext.= $this->enbuffer;
|
||||
}
|
||||
@ -359,11 +367,9 @@ class Crypt_AES extends Crypt_Rijndael {
|
||||
}
|
||||
*/
|
||||
if ($this->mode == 'ncfb') {
|
||||
static $ecb;
|
||||
|
||||
if ($changed) {
|
||||
$ecb = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_ECB, '');
|
||||
mcrypt_generic_init($ecb, $this->key, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");
|
||||
$this->ecb = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_ECB, '');
|
||||
mcrypt_generic_init($this->ecb, $this->key, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");
|
||||
}
|
||||
|
||||
if (strlen($this->debuffer)) {
|
||||
@ -387,7 +393,7 @@ class Crypt_AES extends Crypt_Rijndael {
|
||||
if (strlen($plaintext)) {
|
||||
$this->decryptIV = substr($ciphertext, $last_pos - 16, 16);
|
||||
}
|
||||
$this->decryptIV = mcrypt_generic($ecb, $this->decryptIV);
|
||||
$this->decryptIV = mcrypt_generic($this->ecb, $this->decryptIV);
|
||||
$this->debuffer = substr($ciphertext, $last_pos);
|
||||
$plaintext.= $this->debuffer ^ $this->decryptIV;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright MMVII Jim Wigginton
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt
|
||||
* @version $Id: DES.php,v 1.15 2010-09-26 03:10:20 terrafrost Exp $
|
||||
* @version $Id: DES.php,v 1.16 2010-09-26 05:24:52 terrafrost Exp $
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
@ -268,6 +268,16 @@ class Crypt_DES {
|
||||
*/
|
||||
var $debuffer = '';
|
||||
|
||||
/**
|
||||
* mcrypt resource for CFB mode
|
||||
*
|
||||
* @see Crypt_DES::encrypt()
|
||||
* @see Crypt_DES::decrypt()
|
||||
* @var String
|
||||
* @access private
|
||||
*/
|
||||
var $ecb;
|
||||
|
||||
/**
|
||||
* Default Constructor.
|
||||
*
|
||||
@ -446,11 +456,9 @@ class Crypt_DES {
|
||||
if ($this->mode != 'ncfb') {
|
||||
$ciphertext = mcrypt_generic($this->enmcrypt, $plaintext);
|
||||
} else {
|
||||
static $ecb;
|
||||
|
||||
if ($this->enchanged) {
|
||||
$ecb = mcrypt_module_open(MCRYPT_DES, '', MCRYPT_MODE_ECB, '');
|
||||
mcrypt_generic_init($ecb, $this->keys, "\0\0\0\0\0\0\0\0");
|
||||
$this->ecb = mcrypt_module_open(MCRYPT_DES, '', MCRYPT_MODE_ECB, '');
|
||||
mcrypt_generic_init($this->ecb, $this->keys, "\0\0\0\0\0\0\0\0");
|
||||
$this->enchanged = false;
|
||||
}
|
||||
|
||||
@ -474,7 +482,7 @@ class Crypt_DES {
|
||||
if (strlen($ciphertext)) {
|
||||
$this->encryptIV = substr($ciphertext, -8);
|
||||
}
|
||||
$this->encryptIV = mcrypt_generic($ecb, $this->encryptIV);
|
||||
$this->encryptIV = mcrypt_generic($this->ecb, $this->encryptIV);
|
||||
$this->enbuffer = substr($plaintext, $last_pos) ^ $this->encryptIV;
|
||||
$ciphertext.= $this->enbuffer;
|
||||
}
|
||||
@ -623,11 +631,9 @@ class Crypt_DES {
|
||||
if ($this->mode != 'ncfb') {
|
||||
$plaintext = mdecrypt_generic($this->demcrypt, $ciphertext);
|
||||
} else {
|
||||
static $ecb;
|
||||
|
||||
if ($this->dechanged) {
|
||||
$ecb = mcrypt_module_open(MCRYPT_DES, '', MCRYPT_MODE_ECB, '');
|
||||
mcrypt_generic_init($ecb, $this->keys, "\0\0\0\0\0\0\0\0");
|
||||
$this->ecb = mcrypt_module_open(MCRYPT_DES, '', MCRYPT_MODE_ECB, '');
|
||||
mcrypt_generic_init($this->ecb, $this->keys, "\0\0\0\0\0\0\0\0");
|
||||
$this->dechanged = false;
|
||||
}
|
||||
|
||||
@ -652,7 +658,7 @@ class Crypt_DES {
|
||||
if (strlen($plaintext)) {
|
||||
$this->decryptIV = substr($ciphertext, $last_pos - 8, 8);
|
||||
}
|
||||
$this->decryptIV = mcrypt_generic($ecb, $this->decryptIV);
|
||||
$this->decryptIV = mcrypt_generic($this->ecb, $this->decryptIV);
|
||||
$this->debuffer = substr($ciphertext, $last_pos);
|
||||
$plaintext.= $this->debuffer ^ $this->decryptIV;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@
|
||||
* @author Jim Wigginton <terrafrost@php.net>
|
||||
* @copyright MMVII Jim Wigginton
|
||||
* @license http://www.gnu.org/licenses/lgpl.txt
|
||||
* @version $Id: TripleDES.php,v 1.16 2010-09-26 03:10:20 terrafrost Exp $
|
||||
* @version $Id: TripleDES.php,v 1.17 2010-09-26 05:24:52 terrafrost Exp $
|
||||
* @link http://phpseclib.sourceforge.net
|
||||
*/
|
||||
|
||||
@ -221,6 +221,16 @@ class Crypt_TripleDES {
|
||||
*/
|
||||
var $debuffer = '';
|
||||
|
||||
/**
|
||||
* mcrypt resource for CFB mode
|
||||
*
|
||||
* @see Crypt_TripleDES::encrypt()
|
||||
* @see Crypt_TripleDES::decrypt()
|
||||
* @var String
|
||||
* @access private
|
||||
*/
|
||||
var $ecb;
|
||||
|
||||
/**
|
||||
* Default Constructor.
|
||||
*
|
||||
@ -439,11 +449,9 @@ class Crypt_TripleDES {
|
||||
if ($this->mode != 'ncfb') {
|
||||
$ciphertext = mcrypt_generic($this->enmcrypt, $plaintext);
|
||||
} else {
|
||||
static $ecb;
|
||||
|
||||
if ($this->enchanged) {
|
||||
$ecb = mcrypt_module_open(MCRYPT_3DES, '', MCRYPT_MODE_ECB, '');
|
||||
mcrypt_generic_init($ecb, $this->key, "\0\0\0\0\0\0\0\0");
|
||||
$this->ecb = mcrypt_module_open(MCRYPT_3DES, '', MCRYPT_MODE_ECB, '');
|
||||
mcrypt_generic_init($this->ecb, $this->key, "\0\0\0\0\0\0\0\0");
|
||||
$this->enchanged = false;
|
||||
}
|
||||
|
||||
@ -467,7 +475,7 @@ class Crypt_TripleDES {
|
||||
if (strlen($ciphertext)) {
|
||||
$this->encryptIV = substr($ciphertext, -8);
|
||||
}
|
||||
$this->encryptIV = mcrypt_generic($ecb, $this->encryptIV);
|
||||
$this->encryptIV = mcrypt_generic($this->ecb, $this->encryptIV);
|
||||
$this->enbuffer = substr($plaintext, $last_pos) ^ $this->encryptIV;
|
||||
$ciphertext.= $this->enbuffer;
|
||||
}
|
||||
@ -649,11 +657,9 @@ class Crypt_TripleDES {
|
||||
if ($this->mode != 'ncfb') {
|
||||
$plaintext = mdecrypt_generic($this->demcrypt, $ciphertext);
|
||||
} else {
|
||||
static $ecb;
|
||||
|
||||
if ($this->dechanged) {
|
||||
$ecb = mcrypt_module_open(MCRYPT_3DES, '', MCRYPT_MODE_ECB, '');
|
||||
mcrypt_generic_init($ecb, $this->key, "\0\0\0\0\0\0\0\0");
|
||||
$this->ecb = mcrypt_module_open(MCRYPT_3DES, '', MCRYPT_MODE_ECB, '');
|
||||
mcrypt_generic_init($this->ecb, $this->key, "\0\0\0\0\0\0\0\0");
|
||||
$this->dechanged = false;
|
||||
}
|
||||
|
||||
@ -678,7 +684,7 @@ class Crypt_TripleDES {
|
||||
if (strlen($plaintext)) {
|
||||
$this->decryptIV = substr($ciphertext, $last_pos - 8, 8);
|
||||
}
|
||||
$this->decryptIV = mcrypt_generic($ecb, $this->decryptIV);
|
||||
$this->decryptIV = mcrypt_generic($this->ecb, $this->decryptIV);
|
||||
$this->debuffer = substr($ciphertext, $last_pos);
|
||||
$plaintext.= $this->debuffer ^ $this->decryptIV;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user