+ unit tests

+ rsatool.php : holds the function to create keys
This commit is contained in:
cbonar 2008-07-02 23:22:08 +00:00
parent ae371e5364
commit 2898e9ffdc
2 changed files with 73 additions and 0 deletions

View file

@ -0,0 +1,45 @@
<html>
<head>
<title>Ciform basic non-regression tests</title>
</head>
<body><pre>
<?php
ini_set("include_path", ini_get("include_path").PATH_SEPARATOR."/home/cbonar/src/ciform/src" );
require_once 'PHPUnit/Framework.php';
require_once "ciform/schemes/core.php";
class CiformTest extends PHPUnit_Framework_TestCase
{
protected function setUp()
{
$this->p = "base64:aGVsbG8=";
$this->p2 = "0x6e69636f";
$this->p3 = "b64:MHg2ZTY5NjM2ZjBh";
}
public function testBase64()
{
$s = new Ciform_schemes_Base64();
$this->assertEquals("hello", $s->decode($this->p));
}
public function testBase16()
{
$s = new Ciform_schemes_Base16();
$this->assertEquals("nico", $s->decode($this->p2));
}
public function testChain()
{
$s = new Ciform_CipherChain( array(
new Ciform_schemes_Base16(),
new Ciform_schemes_Base64()
) );
$this->assertEquals("nico\n", $s->decode($this->p3));
}
}
?>

View file

@ -0,0 +1,28 @@
<?php
//
// Ciform
//
// Copyright © 2008 Nicolas BONARDELLE <http://nicobo.net/contact>
//
require_once "ciform/schemes/rsa.php";
/** If the request contains a parameter with this name, this script will force the generation of a new RSA key pair */
define("CIFORM_RSA_REQUEST_GENKEY","ciform-genkey");
//
// Keypair generation is forced if this parameter is set
//
if ( isset($_REQUEST[CIFORM_RSA_REQUEST_GENKEY]) )
{
$keySize = isset($_REQUEST['keySize']) ? $_REQUEST['keySize'] : CIFORM_RSA_DEAULT_KEYSIZE;
$pemFile = isset($_REQUEST['pemFile']) ? $_REQUEST['pemFile'] : CIFORM_RSA_DEFAULT_PEMFILE;
$jsFile = isset($_REQUEST['jsFile']) ? $_REQUEST['jsFile'] : CIFORM_RSA_DEFAULT_JSFILE;
$forceGen = isset($_REQUEST['forceGen']) ? $_REQUEST['forceGen'] : TRUE;
ciform_schemes_rsa_KeyPair::getInstance(NULL, $keySize, $pemFile, $jsFile, $forceGen);
}
?>