mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-27 03:42:40 +00:00
- if padding is disabled and the length of the text-to-be-encrypted isn't a multiple of the block size, padding will be automatically enabled
git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@19 21d32557-59b3-4da0-833f-c5933fad653e
This commit is contained in:
parent
69c639d845
commit
a78d7df660
@ -53,7 +53,7 @@
|
|||||||
* @author Jim Wigginton <terrafrost@php.net>
|
* @author Jim Wigginton <terrafrost@php.net>
|
||||||
* @copyright MMVII Jim Wigginton
|
* @copyright MMVII Jim Wigginton
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt
|
* @license http://www.gnu.org/licenses/lgpl.txt
|
||||||
* @version $Id: DES.php,v 1.4 2008-03-31 00:49:09 terrafrost Exp $
|
* @version $Id: DES.php,v 1.5 2008-08-04 17:59:12 terrafrost Exp $
|
||||||
* @link http://phpseclib.sourceforge.net
|
* @link http://phpseclib.sourceforge.net
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -496,13 +496,20 @@ class Crypt_DES {
|
|||||||
* Pads a string using the RSA PKCS padding standards so that its length is a multiple of the blocksize (8).
|
* Pads a string using the RSA PKCS padding standards so that its length is a multiple of the blocksize (8).
|
||||||
* 8 - (strlen($text) & 7) bytes are added, each of which is equal to chr(8 - (strlen($text) & 7)
|
* 8 - (strlen($text) & 7) bytes are added, each of which is equal to chr(8 - (strlen($text) & 7)
|
||||||
*
|
*
|
||||||
|
* If padding is disabled and $text is not a multiple of the blocksize, the string will be padded regardless
|
||||||
|
* and padding will, hence forth, be enabled.
|
||||||
|
*
|
||||||
* @see Crypt_DES::_unpad()
|
* @see Crypt_DES::_unpad()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _pad($text)
|
function _pad($text)
|
||||||
{
|
{
|
||||||
if (!$this->padding) {
|
if (!$this->padding) {
|
||||||
|
if (strlen($text) & 7 == 0) {
|
||||||
return $text;
|
return $text;
|
||||||
|
} else {
|
||||||
|
$this->padding = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$length = 8 - (strlen($text) & 7);
|
$length = 8 - (strlen($text) & 7);
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
* @author Jim Wigginton <terrafrost@php.net>
|
* @author Jim Wigginton <terrafrost@php.net>
|
||||||
* @copyright MMVII Jim Wigginton
|
* @copyright MMVII Jim Wigginton
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt
|
* @license http://www.gnu.org/licenses/lgpl.txt
|
||||||
* @version $Id: TripleDES.php,v 1.3 2007-07-25 21:56:14 terrafrost Exp $
|
* @version $Id: TripleDES.php,v 1.4 2008-08-04 17:59:12 terrafrost Exp $
|
||||||
* @link http://phpseclib.sourceforge.net
|
* @link http://phpseclib.sourceforge.net
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -552,13 +552,20 @@ class Crypt_TripleDES {
|
|||||||
* Pads a string using the RSA PKCS padding standards so that its length is a multiple of the blocksize (8).
|
* Pads a string using the RSA PKCS padding standards so that its length is a multiple of the blocksize (8).
|
||||||
* 8 - (strlen($text) & 7) bytes are added, each of which is equal to chr(8 - (strlen($text) & 7)
|
* 8 - (strlen($text) & 7) bytes are added, each of which is equal to chr(8 - (strlen($text) & 7)
|
||||||
*
|
*
|
||||||
|
* If padding is disabled and $text is not a multiple of the blocksize, the string will be padded regardless
|
||||||
|
* and padding will, hence forth, be enabled.
|
||||||
|
*
|
||||||
* @see Crypt_TripleDES::_unpad()
|
* @see Crypt_TripleDES::_unpad()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _pad($text)
|
function _pad($text)
|
||||||
{
|
{
|
||||||
if (!$this->padding) {
|
if (!$this->padding) {
|
||||||
|
if (strlen($text) & 7 == 0) {
|
||||||
return $text;
|
return $text;
|
||||||
|
} else {
|
||||||
|
$this->padding = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$length = 8 - (strlen($text) & 7);
|
$length = 8 - (strlen($text) & 7);
|
||||||
|
Loading…
Reference in New Issue
Block a user