‪TYPO3CMS  ‪main
TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash Class Reference
Inheritance diagram for TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash:

Public Member Functions

 __construct (array $options=[])
bool checkPassword (string $plainPW, string $saltedHashPW)
bool isAvailable ()
 getHashedPassword (string $password)
bool isHashUpdateNeeded (string $saltedPW)
bool isValidSaltedPW (string $saltedPW)

Protected Member Functions

string getGeneratedSalt ()
string applySettingsToSalt (string $salt)
int getCountLog2 (string $setting)
string getItoa64 ()
bool isValidSalt (string $salt)
string base64Encode (string $input, int $count)
int getLengthBase64FromBytes (int $byteLength)

Protected Attributes

const PREFIX = '$2a$'
array $options

Detailed Description

Class that implements Blowfish salted hashing based on PHP's crypt() function.

Warning: Blowfish salted hashing with PHP's crypt() is not available on every system.

Definition at line 30 of file BlowfishPasswordHash.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash::__construct ( array  $options = [])

Constructor sets options if given


Definition at line 48 of file BlowfishPasswordHash.php.

References TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash\$options.

Member Function Documentation

◆ applySettingsToSalt()

string TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash::applySettingsToSalt ( string  $salt)

Method applies settings (prefix, hash count) to a salt.

string$salt‪A salt to apply setting to
‪string Salt with setting

Definition at line 156 of file BlowfishPasswordHash.php.

References TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash\getLengthBase64FromBytes().

Referenced by TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash\getHashedPassword().

◆ base64Encode()

string TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash::base64Encode ( string  $input,
int  $count 

Encodes bytes into printable base 64 using the *nix standard from crypt().

string$input‪The string containing bytes to encode.
int$count‪The number of characters (bytes) to encode.
‪string Encoded string

Definition at line 232 of file BlowfishPasswordHash.php.

References TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash\getItoa64().

Referenced by TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash\getGeneratedSalt().

◆ checkPassword()

bool TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash::checkPassword ( string  $plainPW,
string  $saltedHashPW 

Method checks if a given plaintext password is correct by comparing it with a given salted hashed password.

string$plainPW‪plain-text password to compare with salted hash
string$saltedHashPW‪salted hash to compare plain-text password with
‪bool TRUE, if plain-text password matches the salted hash, otherwise FALSE

Implements TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashInterface.

Definition at line 71 of file BlowfishPasswordHash.php.

References TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash\isValidSalt().

◆ getCountLog2()

int TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash::getCountLog2 ( string  $setting)

Parses the log2 iteration count from a stored hash or setting string.

string$setting‪Complete hash or a hash's setting string or to get log2 iteration count from
‪int Used hashcount for given hash string

Definition at line 173 of file BlowfishPasswordHash.php.

Referenced by TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash\isHashUpdateNeeded().

◆ getGeneratedSalt()

string TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash::getGeneratedSalt ( )

Generates a random base 64-encoded salt prefixed and suffixed with settings for the hash.

Proper use of salts may defeat a number of attacks, including:

  • ‪The ability to try candidate passwords against multiple hashes at once.
  • ‪The ability to use pre-hashed lists of candidate passwords.
  • ‪The ability to determine whether two users have the same (or different) password without actually having to guess one of the passwords.
‪string A character string containing settings and a random salt

Definition at line 144 of file BlowfishPasswordHash.php.

References TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash\base64Encode().

Referenced by TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash\getHashedPassword().

◆ getHashedPassword()

TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash::getHashedPassword ( string  $password)

Method creates a hash for a given plaintext password

string$password‪Plaintext password to create a hash from
‪string|null Hashed password or null on empty password

Implements TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashInterface.

Definition at line 90 of file BlowfishPasswordHash.php.

References TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash\applySettingsToSalt(), and TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash\getGeneratedSalt().

◆ getItoa64()

string TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash::getItoa64 ( )

Returns a string for mapping an int to the corresponding base 64 character.

‪string String for mapping an int to the corresponding base 64 character

Definition at line 190 of file BlowfishPasswordHash.php.

Referenced by TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash\base64Encode(), and TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash\isValidSalt().

◆ getLengthBase64FromBytes()

int TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash::getLengthBase64FromBytes ( int  $byteLength)

Method determines required length of base64 characters for a given length of a byte string.

int$byteLength‪Length of bytes to calculate in base64 chars
‪int Required length of base64 characters

Definition at line 266 of file BlowfishPasswordHash.php.

Referenced by TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash\applySettingsToSalt(), and TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash\isValidSalt().

◆ isAvailable()

bool TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash::isAvailable ( )

Returns whether all prerequisites for the hashing methods are matched

‪bool Method available

Implements TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashInterface.

Definition at line 85 of file BlowfishPasswordHash.php.

◆ isHashUpdateNeeded()

bool TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash::isHashUpdateNeeded ( string  $saltedPW)

Checks whether a user's hashed password needs to be replaced with a new hash.

This is typically called during the login process when the plain text password is available. A new hash is needed when the desired iteration count has changed through a change in the variable $hashCount or HASH_COUNT.

string$saltedPW‪Salted hash to check if it needs an update
‪bool TRUE if salted hash needs an update, otherwise FALSE

Implements TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashInterface.

Definition at line 111 of file BlowfishPasswordHash.php.

References TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash\getCountLog2().

◆ isValidSalt()

bool TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash::isValidSalt ( string  $salt)

Method determines if a given string is a valid salt.

string$salt‪String to check
‪bool TRUE if it's valid salt, otherwise FALSE

Definition at line 201 of file BlowfishPasswordHash.php.

References TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash\getItoa64(), and TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash\getLengthBase64FromBytes().

Referenced by TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash\checkPassword(), and TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash\isValidSaltedPW().

◆ isValidSaltedPW()

bool TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash::isValidSaltedPW ( string  $saltedPW)

Method determines if a given string is a valid salted hashed password.

string$saltedPW‪String to check
‪bool TRUE if it's valid salted hashed password, otherwise FALSE

Implements TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashInterface.

Definition at line 124 of file BlowfishPasswordHash.php.

References TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash\isValidSalt().

Member Data Documentation

◆ $options

array TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash::$options
Initial value:
= array(
'hash_count' => 7,

The default log2 number of iterations for password stretching.

Definition at line 39 of file BlowfishPasswordHash.php.

Referenced by TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash\__construct().


const TYPO3\CMS\Core\Crypto\PasswordHashing\BlowfishPasswordHash::PREFIX = '$2a$'

Prefix for the password hash.

Definition at line 35 of file BlowfishPasswordHash.php.