steffen: server/kolab-horde-framework/kolab-horde-framework/Cipher/Cipher/BlockMode cbc.php, NONE, 1.1 cfb64.php, NONE, 1.1 ecb.php, NONE, 1.1 ofb64.php, NONE, 1.1
cvs at intevation.de
cvs at intevation.de
Fri Oct 14 16:33:05 CEST 2005
- Previous message: steffen: server/kolab-horde-framework/kolab-horde-framework/Cipher/Cipher BlockMode.php, NONE, 1.1 blowfish.php, NONE, 1.1 cast128.php, NONE, 1.1 des.php, NONE, 1.1 rc2.php, NONE, 1.1 rc4.php, NONE, 1.1
- Next message: steffen: server/kolab-horde-framework/kolab-horde-framework/Compress Compress.php, NONE, 1.1 package.xml, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Author: steffen
Update of /kolabrepository/server/kolab-horde-framework/kolab-horde-framework/Cipher/Cipher/BlockMode
In directory doto:/tmp/cvs-serv28903/kolab-horde-framework/kolab-horde-framework/Cipher/Cipher/BlockMode
Added Files:
cbc.php cfb64.php ecb.php ofb64.php
Log Message:
Separated Horde Framework from kolab-resource-handlers
--- NEW FILE: cbc.php ---
<?php
/**
* The Horde_Cipher_BlockMode_cbc:: This class implements the
* Horde_Cipher_BlockMode using the Cipher Block Chaininng method of
* encrypting blocks of data.
*
* $Horde: framework/Cipher/Cipher/BlockMode/cbc.php,v 1.7 2004/01/01 15:14:11 jan Exp $
*
* Copyright 2002-2004 Mike Cochrane <mike at graftonhall.co.nz>
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* @author Mike Cochrane <mike at graftonhall.co.nz>
* @version $Revision: 1.1 $
* @since Horde 2.2
* @package Horde_Cipher
*/
class Horde_Cipher_BlockMode_cbc extends Horde_Cipher_BlockMode {
function encrypt(&$cipher, $plaintext)
{
$encrypted = '';
$blocksize = $cipher->getBlockSize();
$previousCipher = $this->_iv;
$jMax = strlen($plaintext);
for ($j = 0; $j < $jMax; $j += $blocksize) {
$plain = substr($plaintext, $j, $blocksize);
if (strlen($plain) < $blocksize) {
// pad the block with \0's if it's not long enough
$plain = str_pad($plain, 8, "\0");
}
$plain = $plain ^ $previousCipher;
$previousCipher = $cipher->encryptBlock($plain);
$encrypted .= $previousCipher;
}
return $encrypted;
}
function decrypt(&$cipher, $ciphertext)
{
$decrypted = '';
$blocksize = $cipher->getBlockSize();
$previousCipher = $this->_iv;
$jMax = strlen($ciphertext);
for ($j = 0; $j < $jMax; $j += $blocksize) {
$plain = substr($ciphertext, $j, $blocksize);
$decrypted .= $cipher->decryptBlock($plain) ^ $previousCipher;
$previousCipher = $plain;
}
// remove trailing \0's used to pad the last block
while (substr($decrypted, -1, 1) == "\0") {
$decrypted = substr($decrypted, 0, -1);
}
return $decrypted;
}
}
--- NEW FILE: cfb64.php ---
<?php
/**
* The Horde_Cipher_BlockMode_cfb64:: This class implements the
* Horde_Cipher_BlockMode using a 64 bit cipher feedback. This can
* used to encypt any length string and the encrypted version will be
* the same length.
*
* $Horde: framework/Cipher/Cipher/BlockMode/cfb64.php,v 1.7 2004/01/01 15:14:11 jan Exp $
*
* Copyright 2002-2004 Mike Cochrane <mike at graftonhall.co.nz>
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* @author Mike Cochrane <mike at graftonhall.co.nz>
* @version $Revision: 1.1 $
* @since Horde 2.2
* @package Horde_Cipher
*/
class Horde_Cipher_BlockMode_cfb64 extends Horde_Cipher_BlockMode {
function encrypt(&$cipher, $plaintext)
{
$encrypted = '';
$n = 0;
$jMax = strlen($plaintext);
for ($j = 0; $j < $jMax; $j++) {
if ($n == 0) {
$this->_iv = $cipher->encryptBlock($this->_iv);
}
$c = $plaintext[$j] ^ $this->_iv[$n];
$this->_iv = substr($this->_iv, 0, $n) . $c . substr($this->_iv, $n + 1);
$encrypted .= $c;
$n = (++$n) & 0x07;
}
return $encrypted;
}
function decrypt(&$cipher, $ciphertext)
{
$decrypted = '';
$n = 0;
$jMax = strlen($ciphertext);
for ($j = 0; $j < $jMax; $j++) {
if ($n == 0) {
$this->_iv = $cipher->encryptBlock($this->_iv);
}
$c = $ciphertext[$j] ^ $this->_iv[$n];
$this->_iv = substr($this->_iv, 0, $n) . substr($ciphertext, $j, 1) . substr($this->_iv, $n + 1);
$decrypted .= $c;
$n = (++$n) & 0x07;
}
// remove trailing \0's used to pad the last block
while (substr($decrypted, -1, 1) == "\0") {
$decrypted = substr($decrypted, 0, -1);
}
return $decrypted;
}
}
--- NEW FILE: ecb.php ---
<?php
/**
* The Horde_Cipher_BlockMode_ecb:: This class implements the
* Horde_Cipher_BlockMode using the Electronic Code Book method of
* encrypting blocks of data.
*
* $Horde: framework/Cipher/Cipher/BlockMode/ecb.php,v 1.7 2004/01/01 15:14:11 jan Exp $
*
* Copyright 2002-2004 Mike Cochrane <mike at graftonhall.co.nz>
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* @author Mike Cochrane <mike at graftonhall.co.nz>
* @version $Revision: 1.1 $
* @since Horde 2.2
* @package Horde_Cipher
*/
class Horde_Cipher_BlockMode_ecb extends Horde_Cipher_BlockMode {
function encrypt(&$cipher, $plaintext)
{
$encrypted = '';
$blocksize = $cipher->getBlockSize();
$jMax = strlen($plaintext);
for ($j = 0; $j < $jMax; $j += $blocksize) {
$plain = substr($plaintext, $j, $blocksize);
if (strlen($plain) < $blocksize) {
// pad the block with \0's if it's not long enough
$plain = str_pad($plain, 8, "\0");
}
$encrypted .= $cipher->encryptBlock($plain);
}
return $encrypted;
}
function decrypt(&$cipher, $ciphertext)
{
$decrypted = '';
$blocksize = $cipher->getBlockSize();
$jMax = strlen($ciphertext);
for ($j = 0; $j < $jMax; $j += $blocksize) {
$plain = substr($ciphertext, $j, $blocksize);
$decrypted .= $cipher->decryptBlock($plain);
}
// remove trailing \0's used to pad the last block
while (substr($decrypted, -1, 1) == "\0") {
$decrypted = substr($decrypted, 0, -1);
}
return $decrypted;
}
}
--- NEW FILE: ofb64.php ---
<?php
/**
* The Horde_Cipher_BlockMode_ofb64:: This class implements the
* Horde_Cipher_BlockMode using a 64 bit output feedback. This can
* used to encypt any length string and the encrypted version will be
* the same length.
*
* $Horde: framework/Cipher/Cipher/BlockMode/ofb64.php,v 1.7 2004/01/01 15:14:11 jan Exp $
*
* Copyright 2002-2004 Mike Cochrane <mike at graftonhall.co.nz>
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* @author Mike Cochrane <mike at graftonhall.co.nz>
* @version $Revision: 1.1 $
* @since Horde 2.2
* @package Horde_Cipher
*/
class Horde_Cipher_BlockMode_ofb64 extends Horde_Cipher_BlockMode {
function encrypt(&$cipher, $plaintext)
{
$encrypted = '';
$n = 0;
$jMax = strlen($plaintext);
for ($j = 0; $j < $jMax; $j++) {
if ($n == 0) {
$this->_iv = $cipher->encryptBlock($this->_iv);
}
$c = $plaintext[$j] ^ $this->_iv[$n];
$encrypted .= $c;
$n = (++$n) & 0x07;
}
return $encrypted;
}
function decrypt(&$cipher, $ciphertext)
{
$decrypted = '';
$n = 0;
$jMax = strlen($ciphertext);
for ($j = 0; $j < $jMax; $j++) {
if ($n == 0) {
$this->_iv = $cipher->encryptBlock($this->_iv);
}
$c = $ciphertext[$j] ^ $this->_iv[$n];
$decrypted .= $c;
$n = (++$n) & 0x07;
}
return $decrypted;
}
}
- Previous message: steffen: server/kolab-horde-framework/kolab-horde-framework/Cipher/Cipher BlockMode.php, NONE, 1.1 blowfish.php, NONE, 1.1 cast128.php, NONE, 1.1 des.php, NONE, 1.1 rc2.php, NONE, 1.1 rc4.php, NONE, 1.1
- Next message: steffen: server/kolab-horde-framework/kolab-horde-framework/Compress Compress.php, NONE, 1.1 package.xml, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the commits
mailing list