Conditions | 1 |
Paths | 1 |
Total Lines | 20 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
10 | public function testValues() |
||
11 | { |
||
12 | |||
13 | $salt = new Buffer(random_bytes(4)); |
||
14 | $iterations = 10; |
||
15 | |||
16 | $pw = new Buffer("passwords can be long, and even consist of unprintable characters \x01\x90"); |
||
17 | |||
18 | $headerBlob = new HeaderBlob($salt->getSize(), $salt, $iterations); |
||
19 | $this->assertEquals($salt->getSize(), $headerBlob->getSaltLen()); |
||
20 | $this->assertEquals($salt->getBinary(), $headerBlob->getSalt()->getBinary()); |
||
21 | $this->assertEquals($iterations, $headerBlob->getIterations()); |
||
22 | $this->assertTrue($salt->equals($headerBlob->getSalt())); |
||
23 | |||
24 | $expectedBinary = pack('c', $salt->getSize()) . $salt->getBinary() . pack('V', $headerBlob->getIterations()); |
||
25 | $this->assertEquals($expectedBinary, $headerBlob->getBinary()); |
||
26 | |||
27 | $expectedKey = hash_pbkdf2('sha512', $pw->getBinary(), $salt->getBinary(), $iterations, 32, true); |
||
28 | $this->assertEquals($expectedKey, $headerBlob->deriveKey($pw)->getBinary()); |
||
29 | } |
||
30 | } |
||
31 |