Ejemplo n.º 1
0
 public function testGetMode()
 {
     $factory = new \CryptLib\Cipher\Factory();
     $aes = $factory->getBlockCipher('rijndael-128');
     $mode = new CryptLib\Cipher\Block\Mode\CTR($aes, 'foobarbazbizbuz');
     $this->assertEquals('ctr', $mode->getMode());
 }
Ejemplo n.º 2
0
 /**
  * @dataProvider provideTestEncryptVectors
  * @group Vectors
  */
 public function testDecrypt(array $vectors)
 {
     list($cipher, $key, $iv) = $vectors[0];
     $cipher = new \CryptLib\Cipher\Block\Cipher\AES($cipher);
     $cipher->setKey(pack('H*', $key));
     $mode = new \CryptLib\Cipher\Block\Mode\CTR($cipher, pack('H*', $iv));
     foreach ($vectors as $vector) {
         list(, , , $data, $expected) = $vector;
         $dec = $mode->decrypt(pack('H*', $data));
         $dec .= $mode->finish();
         $this->assertEquals($expected, strtoupper(bin2hex($dec)));
     }
 }