| Conditions | 6 |
| Paths | 5 |
| Total Lines | 19 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 20 | public static function compute(BufferInterface $password, BufferInterface $salt, $iterations) { |
||
| 21 | if (!($iterations >= 0 && $iterations < pow(2, 32))) { |
||
| 22 | throw new \RuntimeException('Iterations must be a number between 1 and 2^32'); |
||
| 23 | } |
||
| 24 | |||
| 25 | if ($iterations < 512) { |
||
| 26 | throw new \RuntimeException('Iteration count should be at least 512'); |
||
| 27 | } |
||
| 28 | |||
| 29 | if ($salt->getSize() === 0) { |
||
| 30 | throw new \RuntimeException('Salt must not be empty'); |
||
| 31 | } |
||
| 32 | |||
| 33 | if ($salt->getSize() > 0x80) { |
||
| 34 | throw new \RuntimeException('Sanity check: Invalid salt, length can never be greater than 128'); |
||
| 35 | } |
||
| 36 | |||
| 37 | return new Buffer(hash_pbkdf2(self::HASHER, $password->getBinary(), $salt->getBinary(), $iterations, self::KEYLEN_BITS / 8, true)); |
||
|
|
|||
| 38 | } |
||
| 39 | } |
||
| 40 |
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.