Ejemplo n.º 1
0
 /**
  * @covers CryptLib\Password\Implementation\PBKDF::verify
  * @covers CryptLib\Password\Implementation\PBKDF::hash
  * @dataProvider provideTestVerifyFail
  */
 public function testVerifyFail($password, $expect)
 {
     $mock1 = new MockPBKDF(array('derive' => function ($p, $s, $its, $len) {
         $res = $p ^ $s;
         for ($i = 1; $i < $its; $i++) {
             $res ^= $p . $s;
         }
         return substr(str_pad($res, $len, $s[0]), 0, $len);
     }, 'getSignature' => function () {
         return 'testing';
     }));
     $mock2 = new MockGenerator(array('generate' => function ($size) {
         $res = '';
         for ($i = 0; $i < $size; $i++) {
             $res .= chr($i);
         }
         return $res;
     }));
     $pbkdf = new PBKDF($mock1, 30, 50, $mock2);
     $this->assertFalse($pbkdf->verify($password, $expect));
 }
Ejemplo n.º 2
0
 /**
  * @covers CryptLib\Password\Implementation\PBKDF::verify
  * @dataProvider provideTestVerify
  * @group Vectors
  */
 public function testVerify($pass, $expect, $value)
 {
     $apr = new PBKDF();
     $this->assertEquals($value, $apr->verify($pass, $expect));
 }