<?php
	if (!extension_loaded('infosec'))
	{
		if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
  		{
			dl('php_infosec.dll');
		}
   		else
		{
			dl('infosec.so');
		}
 	}
	else
	{
		echo "loaded infosec module success <br/>";
	}

	if(isset($_POST["genrsa"]))
	{
		$pass=$_POST["pass"];
		if(strlen($pass) <= 0)
		{
			echo "WARNING : no input password<br/>";
			exit();
		}
		$seed=$_POST["seed"];
		if(strlen($seed) <= 0)
		{
			echo "WARNING : no input seed<br/>";
			exit();
		}
		$keylen=$_POST["keylen"];
		if(strlen($keylen) <= 0)
		{
			echo "WARNING : no input keylwn<br/>";
			exit();
		}

		$rsa = genRSAKeyPwd($keylen,$seed,$pass);
		$pubkey = current($rsa);
		$pubkeylen = next($rsa);
		$prikey = next($rsa);
		$prikeylen = next($rsa);

		echo "RSA public key : ",current(base64enc($pubkey)),"<br/>";
		echo "RSA public key len: ",$pubkeylen,"<br/>";
		echo "RSA private key : ",current(base64enc($prikey)),"<br/>";
		echo "RSA private key len: ",$prikeylen,"<br/>";
	}
	exit();
?>
