ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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...
 

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

References $i.

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

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  }
$i
Definition: metadata.php:41
+ Here is the caller graph for this function:

◆ isPasswordTooLong()

ilBasePasswordEncoder::isPasswordTooLong ( string  $password)
protected

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

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

57  : bool
58  {
59  return strlen($password) > self::MAX_PASSWORD_LENGTH;
60  }
+ Here is the caller graph for this function:

◆ isSupportedByRuntime()

ilBasePasswordEncoder::isSupportedByRuntime ( )

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

Implements ilPasswordEncoder.

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.

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

Referenced by ilMd5PasswordEncoderTest\testEncoderDoesNotSupportReencoding().

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

◆ requiresSalt()

ilBasePasswordEncoder::requiresSalt ( )

Returns whether the encoder requires a salt.

Implements ilPasswordEncoder.

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

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

67  : bool
68  {
69  return false;
70  }
+ 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.


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