summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b87a5cb)
raw | patch | inline | side by side (parent: b87a5cb)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 6 Dec 2007 10:00:08 +0000 (10:00 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 6 Dec 2007 10:00:08 +0000 (10:00 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8040 594d385d-05f5-0310-b6e9-bd551577e9d8
contrib/socket_server/client.php | patch | blob | history | |
contrib/socket_server/server.php | patch | blob | history | |
include/class_socketClient.inc | patch | blob | history |
index 97cd490a071e586ac0f6939c5cca2e3c83d19600..8cf8f2f2eb70ab5e563274139bf9882d3d0d38ee 100755 (executable)
error_reporting(E_ALL);
echo "\n\nTry to connect";
-$sock = new Socket_Client("localhost","10000",TRUE,1);
-$sock->SetEncryptionKey("Hallo hier bin ich.");
+$sock = new Socket_Client("10.89.1.182","10000",TRUE,1);
+$sock->SetEncryptionKey("ferdinand_frost");
if($sock->connected()){
echo "... successful\n";
echo "|--Reading welcome message : \n";
echo $sock->read();
/* Prepare a hunge bunch of data to be send */
- $data = "a";
- for($i = 0 ; $i < (12 * 1); $i++){
- $data .= "a\n";
- }
+ $data = "HullaHorst";
echo "|--Sending ".strlen($data)."bytes of data to socket.\n";
$sock->send($data);
echo "|--Done!\n";
index bc65fab161d06b600c122daa0aa98f81b00851a3..29a0736cae9c3abe5f51a3b5cff6cf78018e7c0e 100755 (executable)
// Rijndal encrypt key
$enable_encryption = TRUE;
-$encrypt_key = "Hallo hier bin ich.";
-
+$encrypt_key = "ferdinand_frostferdinand_frostfe";
/* Create Socket -
* AF_INET means IPv4 Socket
socket_write($clients[$i]['socket'],encrypt(
"Welcome to GOsa Test Server
============================
-Type some text here:",$encrypt_key)."\n");
+Type some text here:",$encrypt_key));
echo("New client connected: " . $clients[$i]['ipaddy'] . " \n");
break;
function encrypt($data,$key)
{
global $enable_encryption;
+
+ $data= str_repeat("0", 16 - strlen($data)%16).$data;
+ echo "1EEE>>>>>>>>>>>>>>>>>".strlen($data)."\n";
+
/* Encrypt data */
if($enable_encryption){
- $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
+ $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
- $data = mcrypt_encrypt (MCRYPT_RIJNDAEL_256, $key, $data, MCRYPT_MODE_ECB, $iv);
+ echo "Size: $iv_size\n";
+ $data = mcrypt_encrypt (MCRYPT_RIJNDAEL_256, $key, $data, MCRYPT_MODE_CBC, $iv);
}
- return(base64_encode($data));
+ echo "2EEE>>>>>>>>>>>>>>>>>".strlen($data)."\n";
+ return($data);
}
function decrypt($data,$key)
{
global $enable_encryption;
- $data = base64_decode($data);
/* Decrypt data */
if($enable_encryption){
- $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
+ $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
- $data = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $data, MCRYPT_MODE_ECB, $iv);
- $data = rtrim($data,"\x00");
+ $data = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $data, MCRYPT_MODE_CBC, $iv);
+ $data = ltrim($data,"0");
}
return($data);
}
index bf0b79522dcc2033d16bd07c85e42553155928c4..b2957e450626fcfc0c3fa6822b8fcfb74bd4181c 100755 (executable)
public function SetEncryptionKey($data)
{
- $data= str_pad($data, 32, $data);
if(!function_exists("mcrypt_get_iv_size")){
$this->error = _("The mcrypt module was not found. Please install php5-mcrypt.") ;
return(FALSE);
}else{
$this->encrypt = TRUE;
- $this->crypt_key= $data;
- $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
- $this->iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
+ $this->iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
+ $this->crypt_key= str_pad($data, $this->iv_size, $data);
+ echo "Setting key to $this->crypt_key\n";
+ $this->iv = mcrypt_create_iv($this->iv_size, MCRYPT_RAND);
return(TRUE);
}
}
if($this->encrypt){
$data = mcrypt_encrypt (MCRYPT_RIJNDAEL_256, $this->crypt_key, $data, MCRYPT_MODE_CBC, $this->iv);
}
+ echo "EEEE>>>>>>>>>>>>>>>>>>>>>>>>> ".strlen($data)."\n";
return($data);
}
private function decrypt($data)
{
+ echo "DDDD>>>>>>>>>>>>>>>>>>>>>>>>> ".strlen($data)."\n";
/* decrypt data */
- if($this->encrypt){
- $data = mcrypt_decrypt (MCRYPT_RIJNDAEL_256, $this->crypt_key, $data, MCRYPT_MODE_CBC, $this->iv);
- $data = rtrim($data,"\x00");
- }
+ $data = mcrypt_decrypt (MCRYPT_RIJNDAEL_256, $this->crypt_key, rtrim($data), MCRYPT_MODE_CBC, $this->iv);
+ $data = ltrim($data,"0");
return($data);
}
$this->b_data_send = FALSE;
$str = $this->decrypt($str);
}
- return(preg_replace('/^0*/', '', $str));
+ return($str);
}
public function read()