Merge branch '1.0' into 2.0

This commit is contained in:
terrafrost 2016-03-18 16:34:58 -05:00
commit 75dee927b9

View File

@ -286,7 +286,7 @@ class RC2 extends Base
/** /**
* Sets the key length. * Sets the key length.
* *
* Valid key lengths are 1 to 1024. * Valid key lengths are 8 to 1024.
* Calling this function after setting the key has no effect until the next * Calling this function after setting the key has no effect until the next
* \phpseclib\Crypt\RC2::setKey() call. * \phpseclib\Crypt\RC2::setKey() call.
* *
@ -295,9 +295,16 @@ class RC2 extends Base
*/ */
function setKeyLength($length) function setKeyLength($length)
{ {
if ($length >= 1 && $length <= 1024) { if ($length < 8) {
$this->default_key_length = 8;
} elseif ($length > 1024) {
$this->default_key_length = 128;
} else {
$this->default_key_length = $length; $this->default_key_length = $length;
} }
$this->current_key_length = $this->default_key_length;
parent::setKeyLength($length);
} }
/** /**
@ -314,7 +321,7 @@ class RC2 extends Base
/** /**
* Sets the key. * Sets the key.
* *
* Keys can be of any length. RC2, itself, uses 1 to 1024 bit keys (eg. * Keys can be of any length. RC2, itself, uses 8 to 1024 bit keys (eg.
* strlen($key) <= 128), however, we only use the first 128 bytes if $key * strlen($key) <= 128), however, we only use the first 128 bytes if $key
* has more then 128 bytes in it, and set $key to a single null byte if * has more then 128 bytes in it, and set $key to a single null byte if
* it is empty. * it is empty.