/** * @dataProvider provideTestDecryptVectors * @group Vectors */ public function testDecrypt($cipher, $key, $initv, $data, $adata, $expected, $result, $asize, $psize, $nsize, $tsize) { $cipher = new \CryptLib\Cipher\Block\Cipher\AES($cipher); $cipher->setKey(pack('H*', $key)); if ($asize == 0) { $adata = ''; } if ($psize == 0) { $data = 0; } $options = array('adata' => pack('H*', $adata), 'lSize' => 15 - $nsize, 'aSize' => $tsize); $mode = new \CryptLib\Cipher\Block\Mode\CCM($cipher, pack('H*', $initv), $options); $mode->decrypt(pack('H*', $expected)); $enc = $mode->finish(); if ($enc === false) { $this->assertEquals('Fail', $result); } else { $this->assertEquals('Pass', $result); } }
/** * @expectedException InvalidArgumentException */ public function testSetLSizeFailure() { $factory = new \CryptLib\Cipher\Factory(); $aes = $factory->getBlockCipher('rijndael-128'); $iv = 'FEDERATEDBLOCKDATATOOLONG'; $adata = 'Some Other Text'; $mode = new CryptLib\Cipher\Block\Mode\CCM($aes, $iv, array('adata' => $adata)); $mode->setLSize(13); }