Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use SecurityLib\Util #35

Merged
merged 1 commit into from
Mar 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"phpunit/phpunit": "3.7.*"
},
"require": {
"ircmaxell/security-lib": "1.0.*@dev",
"ircmaxell/security-lib": "1.1.*@dev",
"php": ">=5.3.2"
},
"autoload": {
Expand Down
124 changes: 62 additions & 62 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/RandomLib/Mixer/Hash.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
namespace RandomLib\Mixer;

use \SecurityLib\Strength;
use \SecurityLib\Util;

/**
* The Hash medium strength mixer class
Expand Down Expand Up @@ -75,7 +76,7 @@ public static function test() {
* @return int The block size
*/
protected function getPartSize() {
return strlen(hash($this->hash, '', true));
return Util::safeStrlen(hash($this->hash, '', true));
}

/**
Expand Down
9 changes: 5 additions & 4 deletions lib/RandomLib/Source/MicroTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
namespace RandomLib\Source;

use SecurityLib\Strength;
use SecurityLib\Util;

/**
* The Microtime Random Number Source
Expand Down Expand Up @@ -74,8 +75,8 @@ public function __construct() {
$state .= count(debug_backtrace(false));
self::$state = hash('sha512', $state, true);
if (is_null(self::$counter)) {
list( , self::$counter) = unpack("i", substr(self::$state, 0, 4));
$seed = $this->generate(strlen(dechex(PHP_INT_MAX)));
list( , self::$counter) = unpack("i", Util::safeSubstr(self::$state, 0, 4));
$seed = $this->generate(Util::safeStrlen(dechex(PHP_INT_MAX)));
list( , self::$counter) = unpack("i", $seed);
}
}
Expand Down Expand Up @@ -108,9 +109,9 @@ public function generate($size) {
* in its entirety, which could potentially expose other random
* generations in the future (in the same process)...
*/
$result .= substr(self::$state, 0, 8);
$result .= Util::safeSubstr(self::$state, 0, 8);
}
return substr($result, 0, $size);
return Util::safeSubstr($result, 0, $size);
}

private static function counter() {
Expand Down
5 changes: 3 additions & 2 deletions lib/RandomLib/Source/UniqID.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
namespace RandomLib\Source;

use SecurityLib\Strength;
use SecurityLib\Util;

/**
* The UniqID Random Number Source
Expand Down Expand Up @@ -52,10 +53,10 @@ public static function getStrength() {
*/
public function generate($size) {
$result = '';
while (strlen($result) < $size) {
while (Util::safeStrlen($result) < $size) {
$result = uniqid($result, true);
}
return substr($result, 0, $size);
return Util::safeSubstr($result, 0, $size);
}

}