Skip to content

Commit

Permalink
Fix issues with line-length and whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
ircmaxell committed Jul 6, 2012
1 parent 0ab3dc4 commit a7de5c8
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/CryptLib/Password/Implementation/Blowfish.php
Expand Up @@ -63,7 +63,7 @@ public static function getPrefix() {
return '$2y$';
} else {
return '$2a$';
}
}
}

/**
Expand Down Expand Up @@ -116,15 +116,18 @@ public function create($password) {
/**
* Check for security flaw in the bcrypt implementation used by crypt()
* @see http://php.net/security/crypt_blowfish.php
*/
if (version_compare(PHP_VERSION, '5.3.7', '<') && preg_match('/[\x80-\xFF]/', $password)) {
*/
$match = preg_match('/[\x80-\xFF]/', $password);
if (version_compare(PHP_VERSION, '5.3.7', '<') && $match) {

This comment has been minimized.

Copy link
@nikic

nikic Jul 7, 2012

Wouldn't it be better the other way around? Now you're always preg_matching, regardless of the version.

throw new \RuntimeException(
'The bcrypt implementation used by PHP contains a security flaw for password with 8-bit character. ' .
'We suggest to upgrade to PHP 5.3.7+ or use passwords with only 7-bit characters'
'The bcrypt implementation used by PHP contains a security flaw for ' .
'password with 8-bit character. We suggest to upgrade to PHP 5.3.7+ ' .
'or use passwords with only 7-bit characters'
);
}
$salt = $this->to64($this->generator->generate(16));
$prefix = self::getPrefix() . str_pad($this->iterations, 2, '0', STR_PAD_LEFT);
$prefix = static::getPrefix();
$prefix .= str_pad($this->iterations, 2, '0', STR_PAD_LEFT);
$saltstring = $prefix . '$' . $salt;
$result = crypt($password, $saltstring);
if ($result[0] == '*') {
Expand Down

0 comments on commit a7de5c8

Please sign in to comment.