ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilBasePasswordEncoder Class Reference
+ Inheritance diagram for ilBasePasswordEncoder:
+ Collaboration diagram for ilBasePasswordEncoder:

Public Member Functions

 isSupportedByRuntime ()
 Returns whether the encoder is supported by the runtime (PHP, HHVM, ...) More...
 
 requiresSalt ()
 Returns whether the encoder requires a salt. More...
 
 requiresReencoding (string $encoded)
 Returns whether the encoded password needs to be re-encoded. 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 the encoder requires a salt. More...
 
 requiresReencoding (string $encoded)
 Returns whether the encoded password needs to be re-encoded. More...
 
 isSupportedByRuntime ()
 Returns whether the encoder is supported by the runtime (PHP, HHVM, ...) More...
 

Protected Member Functions

 comparePasswords (string $knownString, string $userString)
 Compares two passwords. More...
 
 isPasswordTooLong (string $password)
 

Private Attributes

const MAX_PASSWORD_LENGTH = 4096
 

Detailed Description

Definition at line 26 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
bool true if the two passwords are the same, false otherwise

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

40 : bool
41 {
42 $knownString .= chr(0);
43 $userString .= chr(0);
44
45 $known_string_length = strlen($knownString);
46 $user_string_length = strlen($userString);
47
48 $result = $known_string_length - $user_string_length;
49
50 for ($i = 0; $i < $user_string_length; ++$i) {
51 $result |= (ord($knownString[$i % $known_string_length]) ^ ord($userString[$i]));
52 }
53
54 return 0 === $result;
55 }

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

+ Here is the caller graph for this function:

◆ isPasswordTooLong()

ilBasePasswordEncoder::isPasswordTooLong ( string  $password)
protected

◆ isSupportedByRuntime()

ilBasePasswordEncoder::isSupportedByRuntime ( )

Returns whether the encoder is supported by the runtime (PHP, HHVM, ...)

Implements ilPasswordEncoder.

Reimplemented in ilArgon2idPasswordEncoder.

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

62 : bool
63 {
64 return true;
65 }

◆ requiresReencoding()

ilBasePasswordEncoder::requiresReencoding ( string  $encoded)

Returns whether the encoded password needs to be re-encoded.

Implements ilPasswordEncoder.

Reimplemented in ilArgon2idPasswordEncoder, ilBcryptPasswordEncoder, and ilBcryptPhpPasswordEncoder.

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

72 : bool
73 {
74 return false;
75 }

Referenced by ilMd5PasswordEncoderTest\testEncoderDoesNotSupportReencoding().

+ Here is the caller graph for this function:

◆ requiresSalt()

ilBasePasswordEncoder::requiresSalt ( )

Returns whether the encoder requires a salt.

Implements ilPasswordEncoder.

Reimplemented in ilBcryptPasswordEncoder.

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

67 : bool
68 {
69 return false;
70 }

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

+ Here is the caller graph for this function:

Field Documentation

◆ MAX_PASSWORD_LENGTH

const ilBasePasswordEncoder::MAX_PASSWORD_LENGTH = 4096
private

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

Referenced by isPasswordTooLong().


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