Exemplo n.º 1
0
 public function testDecrypt()
 {
     $factory = new \CryptLib\Cipher\Factory();
     $aes = $factory->getBlockCipher('aes-128');
     $aes->setKey('foobarbafoobarba');
     $mode = new \CryptLib\Cipher\Block\Mode\NOFB($aes, 'bazbsomemoreizbu');
     $expect = $mode->decrypt(pack('H*', '780be9c7da419db4b2c722f3e37d90b6'));
     $expect .= $mode->decrypt(pack('H*', '96410bdbd795dae5b54386079d25d697'));
     $expect .= $mode->finish();
     $this->assertEquals('bazbizbusomemoresomemorebazbizbu', $expect);
 }
Exemplo n.º 2
0
 /**
  * @dataProvider provideTestEncryptVectors
  * @group Vectors
  */
 public function testDecrypt($cipher, $key, $iv, $expected, $data)
 {
     $cipher = new \CryptLib\Cipher\Block\Cipher\AES($cipher);
     $cipher->setKey(pack('H*', $key));
     $mode = new \CryptLib\Cipher\Block\Mode\NOFB($cipher, pack('H*', $iv));
     $dec = $mode->decrypt(pack('H*', $data));
     $dec .= $mode->finish();
     $this->assertEquals($expected, strtoupper(bin2hex($dec)));
 }