ILIAS  release_7 Revision v7.30-3-g800a261c036
ilBasePasswordEncoder Class Reference
+ Inheritance diagram for ilBasePasswordEncoder:
+ Collaboration diagram for ilBasePasswordEncoder:

Public Member Functions

 isSupportedByRuntime ()
 @inheritDoc More...
 
 requiresSalt ()
 @inheritDoc More...
 
 requiresReencoding (string $encoded)
 @inheritDoc More...
 
- Public Member Functions inherited from ilPasswordEncoder
 encodePassword (string $raw, string $salt)
 Encodes the raw password. More...
 
 isPasswordValid (string $encoded, string $raw, string $salt)
 Checks a raw password against an encoded password. More...
 
 getName ()
 Returns a unique name/id of the concrete password encoder. More...
 
 requiresSalt ()
 Returns whether or not the encoder requires a salt. More...
 
 requiresReencoding (string $encoded)
 Returns whether or not the a encoded password needs to be re-encoded. More...
 
 isSupportedByRuntime ()
 Returns whether or not the encoder is supported by the runtime (PHP, HHVM, ...) More...
 

Data Fields

const MAX_PASSWORD_LENGTH = 4096
 

Protected Member Functions

 comparePasswords (string $knownString, string $userString)
 Compares two passwords. More...
 
 isPasswordTooLong (string $password)
 Checks if the password is too long. More...
 

Detailed Description

Definition at line 9 of file class.ilBasePasswordEncoder.php.

Member Function Documentation

◆ comparePasswords()

ilBasePasswordEncoder::comparePasswords ( string  $knownString,
string  $userString 
)
protected

Compares two passwords.

This method implements a constant-time algorithm to compare passwords to avoid (remote) timing attacks. @url http://codahale.com/a-lesson-in-timing-attacks/

Parameters
string$knownStringThe first password
string$userStringThe second password
Returns
Boolean true if the two passwords are the same, false otherwise

Definition at line 23 of file class.ilBasePasswordEncoder.php.

23 : bool
24 {
25 $knownString .= chr(0);
26 $userString .= chr(0);
27
28 $known_string_length = strlen($knownString);
29 $user_string_length = strlen($userString);
30
31 $result = $known_string_length - $user_string_length;
32
33 for ($i = 0; $i < $user_string_length; $i++) {
34 $result |= (ord($knownString[$i % $known_string_length]) ^ ord($userString[$i]));
35 }
36
37 // They are only identical strings if $result is exactly 0...
38 return 0 === $result;
39 }
$result
$i
Definition: metadata.php:24

References $i, and $result.

Referenced by ilBcryptPasswordEncoder\check(), and ilMd5PasswordEncoder\isPasswordValid().

+ Here is the caller graph for this function:

◆ isPasswordTooLong()

ilBasePasswordEncoder::isPasswordTooLong ( string  $password)
protected

Checks if the password is too long.

Parameters
string$passwordThe password
Returns
bool true if the password is too long, false otherwise

Definition at line 46 of file class.ilBasePasswordEncoder.php.

46 : bool
47 {
48 return strlen($password) > self::MAX_PASSWORD_LENGTH;
49 }
$password
Definition: cron.php:14

References $password, and MAX_PASSWORD_LENGTH.

Referenced by ilBcryptPasswordEncoder\encodePassword(), ilBcryptPhpPasswordEncoder\encodePassword(), ilMd5PasswordEncoder\encodePassword(), ilBcryptPasswordEncoder\isPasswordValid(), and ilMd5PasswordEncoder\isPasswordValid().

+ Here is the caller graph for this function:

◆ isSupportedByRuntime()

ilBasePasswordEncoder::isSupportedByRuntime ( )

@inheritDoc

Implements ilPasswordEncoder.

Reimplemented in ilBcryptPhpPasswordEncoder.

Definition at line 54 of file class.ilBasePasswordEncoder.php.

54 : bool
55 {
56 return true;
57 }

◆ requiresReencoding()

ilBasePasswordEncoder::requiresReencoding ( string  $encoded)

@inheritDoc

Implements ilPasswordEncoder.

Reimplemented in ilBcryptPasswordEncoder, and ilBcryptPhpPasswordEncoder.

Definition at line 70 of file class.ilBasePasswordEncoder.php.

70 : bool
71 {
72 return false;
73 }

Referenced by ilMd5PasswordEncoderTest\testEncoderDoesNotSupportReencoding().

+ Here is the caller graph for this function:

◆ requiresSalt()

ilBasePasswordEncoder::requiresSalt ( )

@inheritDoc

Implements ilPasswordEncoder.

Reimplemented in ilBcryptPasswordEncoder.

Definition at line 62 of file class.ilBasePasswordEncoder.php.

62 : bool
63 {
64 return false;
65 }

Referenced by ilBcryptPhpPasswordEncoderTest\testEncoderDoesNotRelyOnSalts(), and ilMd5PasswordEncoderTest\testEncoderDoesNotRelyOnSalts().

+ Here is the caller graph for this function:

Field Documentation

◆ MAX_PASSWORD_LENGTH

const ilBasePasswordEncoder::MAX_PASSWORD_LENGTH = 4096

Definition at line 12 of file class.ilBasePasswordEncoder.php.

Referenced by isPasswordTooLong().


The documentation for this class was generated from the following file: