cvs: pear /Crypt_CBC CBC.php package.xml
| From: | Colin Viebrock | Date: | Fri, 10 May 2002 16:30:25 +0000 |
| Subject: | cvs: pear /Crypt_CBC CBC.php package.xml | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-3749@lists.php.net to get a copy of this message | ||
cmv Fri May 10 12:30:25 2002 EDT
Modified files:
/pear/Crypt_CBC CBC.php package.xml
Log:
bug fix for backwards compat
Index: pear/Crypt_CBC/CBC.php
diff -u pear/Crypt_CBC/CBC.php:1.2 pear/Crypt_CBC/CBC.php:1.3
--- pear/Crypt_CBC/CBC.php:1.2 Thu May 9 14:34:32 2002
+++ pear/Crypt_CBC/CBC.php Fri May 10 12:30:25 2002
@@ -16,7 +16,7 @@
// | Authors: Colin Viebrock <colin@easydns.com> |
// +----------------------------------------------------------------------+
//
-// $Id: CBC.php,v 1.2 2002/05/09 18:34:32 cmv Exp $
+// $Id: CBC.php,v 1.3 2002/05/10 16:30:25 cmv Exp $
//
require_once 'PEAR.php';
@@ -25,24 +25,22 @@
/**
* Class to emulate Perl's Crypt::CBC module
*
- * Blowfish support is not completely working, mainly because of a bug
- * discovered in libmcrypt (version 2.4.8 and earlier). If you are running
- * a later version of libmcrypt > 2.4.8, you can do Blowfish encryption
- * that is compatable with Perl. However, check the libmcrypt documenation
- * as to whether you should use 'BLOWFISH' or 'BLOWFISH-COMPAT' when
- * specifying the cipher.
- *
+ * Blowfish support that is compatable with Perl requires libmcrypt >= 2.4.9.
* If you are using libmcrypt <= 2.4.8, Blowfish encryption will work,
* but your data will not be readable by Perl scripts. It will work
* "internally" .. i.e. this class will be able to encode/decode the data.
*
+ * Blowfish support that is compatable with PHP applications using
+ * libmcrypt <= 2.4.8 requies you to use 'BLOWFISH-COMPAT' when
+ * specifying the cipher. Check the libmcrypt docs when in doubt.
+ *
* This class no longer works with libmcrypt 2.2.x versions.
*
* NOTE: the cipher names in this class may change depending on how
* the author of libcrypt decides to name things internally.
*
*
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
* @author Colin Viebrock <colin@easydns.com>
* @access public
* @package Crypt
@@ -73,6 +71,12 @@
var $TD;
/**
+ * crypt deinit function, for backwards compatability
+ * @var string
+ */
+ var $deinit_function;
+
+ /**
* blocksize of cipher
* @var string
*/
@@ -136,9 +140,17 @@
return $this->raiseError('mcrypt module is not compiled into PHP', null,
PEAR_ERROR_DIE, null, 'compile PHP using "--with-mcrypt"' );
}
- if (!function_exists('mcrypt_module_open') ||
!function_exists('mcrypt_generic_deinit')) {
- return $this->raiseError('libmcrypt/PHP version insufficient', null,
- PEAR_ERROR_DIE, null, 'this class only works with libmcrypt >= 2.4.x and
later, and PHP >= 4.1.1' );
+ if (!function_exists('mcrypt_module_open')) {
+ return $this->raiseError('libmcrypt version insufficient', null,
+ PEAR_ERROR_DIE, null, 'this class requires libmcrypt >= 2.4.x, preferably
>= 2.4.18' );
+ }
+ if (function_exists('mcrypt_generic_deinit')) {
+ $this->deinit_function = 'mcrypt_generic_deinit';
+ } else if (function_exists('mcrypt_generic_end')) {
+ $this->deinit_function = 'mcrypt_generic_end';
+ } else {
+ return $this->raiseError('PHP version insufficient', null,
+ PEAR_ERROR_DIE, null, 'this class requires PHP >= 4.0.2, preferably >=
4.1.1' );
}
@@ -238,7 +250,7 @@
$cblock = mcrypt_generic($this->TD, $iv^$block );
$iv = $cblock;
$crypt .= $cblock;
- mcrypt_generic_deinit($this->TD);
+ call_user_func($this->deinit_function, $this->TD);
}
$this->last_crypt = $crypt;
@@ -287,7 +299,7 @@
$block = $iv ^ mdecrypt_generic($this->TD, $cblock);
$iv = $cblock;
$clear .= $block;
- mcrypt_generic_deinit($this->TD);
+ call_user_func($this->deinit_function, $this->TD);
}
/* remove the padding from the end of the cleartext */
Index: pear/Crypt_CBC/package.xml
diff -u pear/Crypt_CBC/package.xml:1.4 pear/Crypt_CBC/package.xml:1.5
--- pear/Crypt_CBC/package.xml:1.4 Thu May 9 14:38:44 2002
+++ pear/Crypt_CBC/package.xml Fri May 10 12:30:25 2002
@@ -18,12 +18,13 @@
</maintainer>
</maintainers>
<release>
- <version>0.2</version>
+ <version>0.3</version>
<state>stable</state>
<license>PHP 2.02</license>
- <date>2002-05-09</date>
+ <date>2002-05-10</date>
<notes>
- Bug fix for a pretty bad memory leak.
+ Previous bug fixed worked, but required PHP 4.2.0. The class has been changed
+ to allow for more backwards compatability (back to 4.0.2)
</notes>
<filelist>
<dir name="/" baseinstalldir="Crypt">