ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilBasePasswordEncoder Class Reference
+ Inheritance diagram for ilBasePasswordEncoder:
+ Collaboration diagram for ilBasePasswordEncoder:

Public Member Functions

 isSupportedByRuntime ()
 
 requiresSalt ()
 
 requiresReencoding (string $encoded)
 
- 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...
 

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. 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.

References $i, and $result.

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

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
+ 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.

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

46  : bool
47  {
48  return strlen($password) > self::MAX_PASSWORD_LENGTH;
49  }
$password
Definition: cron.php:14
+ Here is the caller graph for this function:

◆ isSupportedByRuntime()

ilBasePasswordEncoder::isSupportedByRuntime ( )

Implements ilPasswordEncoder.

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

54  : bool
55  {
56  return true;
57  }

◆ requiresReencoding()

ilBasePasswordEncoder::requiresReencoding ( string  $encoded)

Implements ilPasswordEncoder.

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

Referenced by ilMd5PasswordEncoderTest\testEncoderDoesNotSupportReencoding().

70  : bool
71  {
72  return false;
73  }
+ Here is the caller graph for this function:

◆ requiresSalt()

ilBasePasswordEncoder::requiresSalt ( )

Implements ilPasswordEncoder.

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

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

62  : bool
63  {
64  return false;
65  }
+ 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.


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