Source for file PAPICrypt.php
Documentation is available at PAPICrypt.php
* @copyright Copyright 2005-2011 RedIRIS, http://www.rediris.es/
* This file is part of phpPoA2.
* phpPoA2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* phpPoA2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with phpPoA2. If not, see <http://www.gnu.org/licenses/>.
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License
* Cryptographic routines for PAPI protocol v1.
public function __construct($symmetric = "", $pubkey = "", $privkey = "", $passphrase = "") {
if (!empty($privkey)) $this->setPrivateKey($privkey, $passphrase);
throw new PoAException('pubkey-error', E_USER_ERROR, array($pubkey));
throw new PoAException('pubkey-error', E_USER_ERROR, array($pubkey));
throw new PoAException('privkey-error', E_USER_ERROR, array($privkey));
throw new PoAException('privkey-error', E_USER_ERROR, array($privkey));
$module = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_ECB, '');
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($module), MCRYPT_RAND);
if (mcrypt_generic_init($module, $key, $iv) === 0) {
$module = mcrypt_module_open('tripledes', '', 'ecb', '');
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($module), MCRYPT_RAND);
if (mcrypt_generic_init($module, $key, $iv) === 0) {
mcrypt_generic_deinit($module);
mcrypt_module_close($module);
$result = mcrypt_generic($module, $input);
$result = mcrypt_generic($module, $input);
// get total no. of blocks
$block_total = ceil(strlen($input) / $block_size);
for ($i = 0; $i < $block_total; $i++ ) {
$index = $i * $block_size;
$block = substr($input, $index, $block_size);
// get expected no. of blocks
$block_total = ceil(strlen($input) / $block_size);
for ($i = 0; $i < $block_total; $i++ ) {
$index = $i * $block_size;
$block = substr($input, $index, $block_size);
|