Page 1 of 1

Aescrypt code not executing in my linux server

Posted: Fri Feb 20, 2015 5:33 am
by pradeepkondapaka
Hi Guys,

I have tested the aescode in my local wamp server,its working fine, while i am testing in my server the code

Code: Select all

"$openMode = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '','cbc', '');"
is not executed, i have installed aescrypt in my server also, but no use. please any one give me a solution for this

Re: Aescrypt code not executing in my linux server

Posted: Fri Feb 20, 2015 6:56 am
by paulej
It looks like you're trying to use PHP. There are two PHP implementations of AES Crypt written by different authors. I'm not familiar with either, but the links are on the download page.

Are you trying to use either of those or something else?

Re: Aescrypt code not executing in my linux server

Posted: Fri Feb 20, 2015 8:34 am
by pradeepkondapaka
Yes, Here i am using Php, here i want to test my ccavenue, but this php encryption file doesn't run any more.

Code: Select all

function encrypt($plainText,$key)
	{
        echo "1q";
		$secretKey = hextobin(md5($key));
  echo "2";
		$initVector = pack("C*", 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
  echo "3";
	  		  	$openMode = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '','cbc', '');

  echo "4";
	  	$blockSize = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, 'cbc');
  echo "5";
		$plainPad = pkcs5_pad($plainText, $blockSize);
  echo "6";
	  	if (mcrypt_generic_init($openMode, $secretKey, $initVector) != -1) 
		{
		      $encryptedText = mcrypt_generic($openMode, $plainPad);
	      	      mcrypt_generic_deinit($openMode);
		      			
		} 

		return bin2hex($encryptedText);
	}

here i am unable to display echo "4"

Re: Aescrypt code not executing in my linux server

Posted: Fri Feb 20, 2015 8:20 pm
by paulej
What AES Crypt code are you using? I'm not familiar with the php implementations, but there are at least two available from aescrypt.com.

Re: Aescrypt code not executing in my linux server

Posted: Sat Feb 21, 2015 7:04 am
by pradeepkondapaka
Here i am not using the default php crypt functions, the CCAvenue team follows one cryptography, they gave us that file along with test integration kit (crypto.php file). here i am sending the code, please review it and give me some suggetions.

Code: Select all

<?php

	error_reporting(0);

	function encrypt($plainText,$key)
	{
		$secretKey = hextobin(md5($key));
		$initVector = pack("C*", 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
	  	$openMode = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '','cbc', '');
	  	$blockSize = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, 'cbc');
		$plainPad = pkcs5_pad($plainText, $blockSize);
	  	if (mcrypt_generic_init($openMode, $secretKey, $initVector) != -1) 
		{
		      $encryptedText = mcrypt_generic($openMode, $plainPad);
	      	      mcrypt_generic_deinit($openMode);
		      			
		} 
		return bin2hex($encryptedText);
	}

	function decrypt($encryptedText,$key)
	{
		$secretKey = hextobin(md5($key));
		$initVector = pack("C*", 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
		$encryptedText=hextobin($encryptedText);
	  	$openMode = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '','cbc', '');
		mcrypt_generic_init($openMode, $secretKey, $initVector);
		$decryptedText = mdecrypt_generic($openMode, $encryptedText);
		$decryptedText = rtrim($decryptedText, "\0");
	 	mcrypt_generic_deinit($openMode);
		return $decryptedText;
		
	}
	//*********** Padding Function *********************

	 function pkcs5_pad ($plainText, $blockSize)
	{
	    $pad = $blockSize - (strlen($plainText) % $blockSize);
	    return $plainText . str_repeat(chr($pad), $pad);
	}

	//********** Hexadecimal to Binary function for php 4.0 version ********

	function hextobin($hexString) 
   	 { 
        	$length = strlen($hexString); 
        	$binString="";   
        	$count=0; 
        	while($count<$length) 
        	{       
        	    $subString =substr($hexString,$count,2);           
        	    $packedString = pack("H*",$subString); 
        	    if ($count==0)
		    {
				$binString=$packedString;
		    } 
        	    
		    else 
		    {
				$binString.=$packedString;
		    } 
        	    
		    $count+=2; 
        	} 
  	        return $binString; 
    	  } 
?>


Re: Aescrypt code not executing in my linux server

Posted: Sat Feb 21, 2015 8:12 am
by paulej
That code isn't AES Crypt code. It appears to be trying to use the AES algorithm, but AES Crypt isn't just using the AES algorithm.

In AES Crypt, there are a set of procedures for turning a password into a key using SHA256, formatting the output file, protection using HMAC-SHA256, etc. I don't see any of that in this code. In fact, I see use of MD5, which AES Crypt doesn't use.