projects
/
core.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use of the FrameworkFeature class (which is a manager somehow) +
[core.git]
/
inc
/
classes
/
main
/
scrypt
/
class_Scrypt.php
diff --git
a/inc/classes/main/scrypt/class_Scrypt.php
b/inc/classes/main/scrypt/class_Scrypt.php
index 8f4891d06bfe5c657fc7fe942a1669d5d757b1c7..e1c7cb9c307abca6b73289c6d52c3a937de527f6 100644
(file)
--- a/
inc/classes/main/scrypt/class_Scrypt.php
+++ b/
inc/classes/main/scrypt/class_Scrypt.php
@@
-51,7
+51,7
@@
abstract class Scrypt extends BaseFrameworkSystem
*
* @return int
*/
*
* @return int
*/
- protected static function strlen
( $str
) {
+ protected static function strlen
($str
) {
static $isShadowed = null;
if ($isShadowed === null) {
static $isShadowed = null;
if ($isShadowed === null) {
@@
-73,7
+73,7
@@
abstract class Scrypt extends BaseFrameworkSystem
*
* @return string The salt
*/
*
* @return string The salt
*/
- public static function generateScryptSalt($length = 8)
+ public static function generateScryptSalt
($length = 8)
{
$buffer = '';
$buffer_valid = false;
{
$buffer = '';
$buffer_valid = false;
@@
-90,7
+90,7
@@
abstract class Scrypt extends BaseFrameworkSystem
$buffer_valid = true;
}
}
$buffer_valid = true;
}
}
- if (!$buffer_valid &&
is_readab
le('/dev/urandom')) {
+ if (!$buffer_valid &&
BaseFrameworkSystem::isReadableFi
le('/dev/urandom')) {
$f = fopen('/dev/urandom', 'r');
$read = static::strlen($buffer);
while ($read < $length) {
$f = fopen('/dev/urandom', 'r');
$read = static::strlen($buffer);
while ($read < $length) {
@@
-128,18
+128,23
@@
abstract class Scrypt extends BaseFrameworkSystem
*
* @return string The hashed password
*/
*
* @return string The hashed password
*/
- public static function hashScrypt($password, $salt = false, $N = 16384, $r = 8, $p = 1)
+ public static function hashScrypt
($password, $salt = false, $N = 16384, $r = 8, $p = 1)
{
{
+ if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) {
+ // Feature has been disabled
+ throw new \InvalidArgumentException('Feature "scrypt" disabled.');
+ }
+
if ($N == 0 || ($N & ($N - 1)) != 0) {
if ($N == 0 || ($N & ($N - 1)) != 0) {
- throw new \InvalidArgumentException(
"N must be > 0 and a power of 2"
);
+ throw new \InvalidArgumentException(
'N must be > 0 and a power of 2'
);
}
if ($N > PHP_INT_MAX / 128 / $r) {
}
if ($N > PHP_INT_MAX / 128 / $r) {
- throw new \InvalidArgumentException(
"Parameter N is too large"
);
+ throw new \InvalidArgumentException(
'Parameter N is too large'
);
}
if ($r > PHP_INT_MAX / 128 / $p) {
}
if ($r > PHP_INT_MAX / 128 / $p) {
- throw new \InvalidArgumentException(
"Parameter r is too large"
);
+ throw new \InvalidArgumentException(
'Parameter r is too large'
);
}
if ($salt === false) {
}
if ($salt === false) {
@@
-162,13
+167,18
@@
abstract class Scrypt extends BaseFrameworkSystem
*
* @return boolean If the clear text matches
*/
*
* @return boolean If the clear text matches
*/
- public static function checkScrypt($password, $hash)
+ public static function checkScrypt
($password, $hash)
{
// Is there actually a hash?
if (!$hash) {
return false;
}
{
// Is there actually a hash?
if (!$hash) {
return false;
}
+ if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) {
+ // Feature has been disabled
+ throw new \InvalidArgumentException('Feature "scrypt" disabled.');
+ }
+
list ($N, $r, $p, $salt, $hash) = explode('$', $hash);
// No empty fields?
list ($N, $r, $p, $salt, $hash) = explode('$', $hash);
// No empty fields?
@@
-206,7
+216,7
@@
abstract class Scrypt extends BaseFrameworkSystem
*
* @return boolean If the two strings match.
*/
*
* @return boolean If the two strings match.
*/
- public static function compareScryptHashes($expected, $actual)
+ public static function compareScryptHashes
($expected, $actual)
{
$expected = (string) $expected;
$actual = (string) $actual;
{
$expected = (string) $expected;
$actual = (string) $actual;