TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
BlowfishSalt Class Reference
Inheritance diagram for BlowfishSalt:
Md5Salt AbstractSalt SaltInterface

Public Member Functions

 getHashCount ()
 
 getMaxHashCount ()
 
 isAvailable ()
 
 getMinHashCount ()
 
 getSaltLength ()
 
 getSetting ()
 
 isHashUpdateNeeded ($saltedPW)
 
 isValidSalt ($salt)
 
 isValidSaltedPW ($saltedPW)
 
 setHashCount ($hashCount=null)
 
 setMaxHashCount ($maxHashCount=null)
 
 setMinHashCount ($minHashCount=null)
 
- Public Member Functions inherited from Md5Salt
 checkPassword ($plainPW, $saltedHashPW)
 
 getHashedPassword ($password, $salt=null)
 
 isAvailable ()
 
 getSaltLength ()
 
 getSetting ()
 
 isHashUpdateNeeded ($passString)
 
 isValidSalt ($salt)
 
 isValidSaltedPW ($saltedPW)
 
- Public Member Functions inherited from AbstractSalt
 base64Encode ($input, $count)
 

Public Attributes

const HASH_COUNT = 7
 
const MAX_HASH_COUNT = 17
 
const MIN_HASH_COUNT = 4
 
- Public Attributes inherited from Md5Salt
const ITOA64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
 

Protected Member Functions

 applySettingsToSalt ($salt)
 
 getCountLog2 ($setting)
 
- Protected Member Functions inherited from Md5Salt
 applySettingsToSalt ($salt)
 
 getGeneratedSalt ()
 
 getItoa64 ()
 
 getSaltSuffix ()
 
- Protected Member Functions inherited from AbstractSalt
 applySettingsToSalt ($salt)
 
 getGeneratedSalt ()
 
 getItoa64 ()
 
 getSetting ()
 
 getLengthBase64FromBytes ($byteLength)
 

Static Protected Attributes

static $hashCount
 
static $maxHashCount
 
static $minHashCount
 
static $saltLengthBlowfish = 16
 
static $settingBlowfish = '$2a$'
 
- Static Protected Attributes inherited from Md5Salt
static $saltLengthMD5 = 6
 
static $saltSuffixMD5 = '$'
 
static $settingMD5 = '$1$'
 

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 24 of file BlowfishSalt.php.

Member Function Documentation

applySettingsToSalt (   $salt)
protected

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

Overwrites Md5Salt::applySettingsToSalt() with Blowfish specifics.

Parameters
string$saltA salt to apply setting to
Returns
string Salt with setting

Definition at line 90 of file BlowfishSalt.php.

References BlowfishSalt\getHashCount(), AbstractSalt\getLengthBase64FromBytes(), BlowfishSalt\getSaltLength(), and BlowfishSalt\getSetting().

getCountLog2 (   $setting)
protected

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

Parameters
string$settingComplete hash or a hash's setting string or to get log2 iteration count from
Returns
int Used hashcount for given hash string

Definition at line 107 of file BlowfishSalt.php.

References BlowfishSalt\getSetting().

Referenced by BlowfishSalt\isHashUpdateNeeded().

getHashCount ( )

Method returns log2 number of iterations for password stretching.

Returns
int log2 number of iterations for password stretching
See also
HASH_COUNT
$hashCount
setHashCount()

Definition at line 127 of file BlowfishSalt.php.

Referenced by BlowfishSalt\applySettingsToSalt(), and BlowfishSalt\isHashUpdateNeeded().

getMaxHashCount ( )

Method returns maximum allowed log2 number of iterations for password stretching.

Returns
int Maximum allowed log2 number of iterations for password stretching
See also
MAX_HASH_COUNT
$maxHashCount
setMaxHashCount()

Definition at line 140 of file BlowfishSalt.php.

Referenced by BlowfishSalt\setHashCount().

getMinHashCount ( )

Method returns minimum allowed log2 number of iterations for password stretching.

Returns
int Minimum allowed log2 number of iterations for password stretching
See also
MIN_HASH_COUNT
$minHashCount
setMinHashCount()

Definition at line 163 of file BlowfishSalt.php.

Referenced by BlowfishSalt\setHashCount().

getSaltLength ( )

Returns length of a Blowfish salt in bytes.

Overwrites Md5Salt::getSaltLength() with Blowfish specifics.

Returns
int Length of a Blowfish salt in bytes

Implements SaltInterface.

Definition at line 176 of file BlowfishSalt.php.

Referenced by BlowfishSalt\applySettingsToSalt(), and BlowfishSalt\isValidSalt().

getSetting ( )

Returns setting string of Blowfish salted hashes.

Overwrites Md5Salt::getSetting() with Blowfish specifics.

Returns
string Setting string of Blowfish salted hashes

Definition at line 189 of file BlowfishSalt.php.

Referenced by BlowfishSalt\applySettingsToSalt(), BlowfishSalt\getCountLog2(), BlowfishSalt\isValidSalt(), and BlowfishSalt\isValidSaltedPW().

isAvailable ( )

Returns whether all prerequisites for the hashing methods are matched

Returns
bool Method available

Implements SaltInterface.

Definition at line 150 of file BlowfishSalt.php.

isHashUpdateNeeded (   $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.

Parameters
string$saltedPWSalted hash to check if it needs an update
Returns
bool TRUE if salted hash needs an update, otherwise FALSE

Implements SaltInterface.

Definition at line 205 of file BlowfishSalt.php.

References BlowfishSalt\getCountLog2(), BlowfishSalt\getHashCount(), and BlowfishSalt\isValidSalt().

isValidSalt (   $salt)

Method determines if a given string is a valid salt.

Overwrites Md5Salt::isValidSalt() with Blowfish specifics.

Parameters
string$saltString to check
Returns
bool TRUE if it's valid salt, otherwise FALSE

Implements SaltInterface.

Definition at line 225 of file BlowfishSalt.php.

References Md5Salt\getItoa64(), AbstractSalt\getLengthBase64FromBytes(), BlowfishSalt\getSaltLength(), and BlowfishSalt\getSetting().

Referenced by BlowfishSalt\isHashUpdateNeeded(), and BlowfishSalt\isValidSaltedPW().

isValidSaltedPW (   $saltedPW)

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

Parameters
string$saltedPWString to check
Returns
bool TRUE if it's valid salted hashed password, otherwise FALSE

Implements SaltInterface.

Definition at line 255 of file BlowfishSalt.php.

References BlowfishSalt\getSetting(), and BlowfishSalt\isValidSalt().

setHashCount (   $hashCount = null)

Method sets log2 number of iterations for password stretching.

Parameters
int$hashCountlog2 number of iterations for password stretching to set
See also
HASH_COUNT
$hashCount
getHashCount()

Definition at line 272 of file BlowfishSalt.php.

References BlowfishSalt\$hashCount, BlowfishSalt\getMaxHashCount(), and BlowfishSalt\getMinHashCount().

setMaxHashCount (   $maxHashCount = null)

Method sets maximum allowed log2 number of iterations for password stretching.

Parameters
int$maxHashCountMaximum allowed log2 number of iterations for password stretching to set
See also
MAX_HASH_COUNT
$maxHashCount
getMaxHashCount()

Definition at line 285 of file BlowfishSalt.php.

References BlowfishSalt\$maxHashCount.

setMinHashCount (   $minHashCount = null)

Method sets minimum allowed log2 number of iterations for password stretching.

Parameters
int$minHashCountMinimum allowed log2 number of iterations for password stretching to set
See also
MIN_HASH_COUNT
$minHashCount
getMinHashCount()

Definition at line 298 of file BlowfishSalt.php.

References BlowfishSalt\$minHashCount.

Member Data Documentation

$hashCount
staticprotected

Definition at line 49 of file BlowfishSalt.php.

Referenced by BlowfishSalt\setHashCount().

$maxHashCount
staticprotected

Definition at line 57 of file BlowfishSalt.php.

Referenced by BlowfishSalt\setMaxHashCount().

$minHashCount
staticprotected

Definition at line 65 of file BlowfishSalt.php.

Referenced by BlowfishSalt\setMinHashCount().

$saltLengthBlowfish = 16
staticprotected

Definition at line 72 of file BlowfishSalt.php.

$settingBlowfish = '$2a$'
staticprotected

Definition at line 79 of file BlowfishSalt.php.

const HASH_COUNT = 7

The default log2 number of iterations for password stretching.

Definition at line 29 of file BlowfishSalt.php.

const MAX_HASH_COUNT = 17

The default maximum allowed log2 number of iterations for password stretching.

Definition at line 35 of file BlowfishSalt.php.

const MIN_HASH_COUNT = 4

The default minimum allowed log2 number of iterations for password stretching.

Definition at line 41 of file BlowfishSalt.php.