1 | <?php |
||
17 | class Utils |
||
18 | { |
||
19 | /** |
||
20 | * Compare two strings to avoid timing attacks |
||
21 | * |
||
22 | * C function memcmp() internally used by PHP, exits as soon as a difference |
||
23 | * is found in the two buffers. That makes possible of leaking |
||
24 | * timing information useful to an attacker attempting to iteratively guess |
||
25 | * the unknown string (e.g. password). |
||
26 | * The length will leak. |
||
27 | * |
||
28 | * @param string $expected |
||
29 | * @param string $actual |
||
30 | * |
||
31 | * @return bool |
||
32 | */ |
||
33 | public static function compareStrings($expected, $actual) |
||
54 | } |
||
55 |