3 * @author Jan Altensen (Stricted)
4 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
5 * @copyright 2015 Jan Altensen (Stricted)
9 * decrypt data from router
14 private function decrypt ($data) {
15 $iv = hex2bin(substr($this->challenge
, 16, 16));
16 $adata = hex2bin(substr($this->challenge
, 32, 16));
17 $key = hex2bin($this->derivedk
);
18 $enc = hex2bin($data);
20 $factory = new CryptLib\Cipher\
Factory();
21 $aes = $factory->getBlockCipher('rijndael-128');
23 $mode = $factory->getMode('ccm', $aes, $iv, [ 'adata' => $adata, 'lSize' => 7]);
27 return $mode->finish();
31 * decrypt data for the router
36 private function encrypt ($data) {
37 $iv = hex2bin(substr($this->challenge
, 16, 16));
38 $adata = hex2bin(substr($this->challenge
, 32, 16));
39 $key = hex2bin($this->derivedk
);
41 $factory = new CryptLib\Cipher\
Factory();
42 $aes = $factory->getBlockCipher('rijndael-128');
44 $mode = $factory->getMode('ccm', $aes, $iv, [ 'adata' => $adata, 'lSize' => 7]);
45 $mode->encrypt($data);
47 return bin2hex($mode->finish());