mirror of
https://github.com/nicolabs/ciform.git
synced 2026-05-21 12:13:25 +02:00
+ unit tests
+ rsatool.php : holds the function to create keys
This commit is contained in:
parent
ae371e5364
commit
2898e9ffdc
45
ciform/trunk/test/CiformTest.php
Normal file
45
ciform/trunk/test/CiformTest.php
Normal 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));
|
||||
}
|
||||
}
|
||||
?>
|
||||
28
ciform/trunk/test/rsatool.php
Normal file
28
ciform/trunk/test/rsatool.php
Normal 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);
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Reference in a new issue