diff --git a/ciform/trunk/test/ciform.css b/ciform/trunk/test/ciform.css new file mode 100644 index 0000000..4595abf --- /dev/null +++ b/ciform/trunk/test/ciform.css @@ -0,0 +1,5 @@ +/* A very simple style for demo purpose */ +body { background:white; } +code, pre { background:#DDEEEE; } +.txt { background:#CCFF99;} +.b64, .bin, .hex { background:#EEEEAA; } diff --git a/ciform/trunk/test/ciform.html b/ciform/trunk/test/ciform.html new file mode 100644 index 0000000..aca7c97 --- /dev/null +++ b/ciform/trunk/test/ciform.html @@ -0,0 +1,32 @@ + + + Test Page for Ciform + + + + + + +

Test Page for Ciform

+ +

This page is a unit test.
+ It must be open with JsUnit's TestRunner.

+ + \ No newline at end of file diff --git a/ciform/trunk/test/demo.php b/ciform/trunk/test/demo.php new file mode 100644 index 0000000..ad5ae49 --- /dev/null +++ b/ciform/trunk/test/demo.php @@ -0,0 +1,71 @@ + + + + + + + + + + +

Demo page for CiForm

+ +

1. Fill in the following form

+ +

On submit, a hidden output field takes the value of the encrypted password, + and the password field is emptied so it is not transmitted.

+ +
+ + login :
+ password : + + + Encrypt using SHA-1 : +
+ Preview of the encrypted text * : +
+ +
+ +

* On-the-fly encryption may slow down typing, the usual case is to encrypt only on form submit.

+ +

2. The form is submitted with the encrypted password

+ +

Here is what the received response looks like :

+
+ +

And after decryption :

+
+ + \ No newline at end of file diff --git a/ciform/trunk/test/test.php b/ciform/trunk/test/test.php new file mode 100644 index 0000000..5dff26a --- /dev/null +++ b/ciform/trunk/test/test.php @@ -0,0 +1,150 @@ + + + + + + + + + + +

Test page for Ciform

+ +

1. Key generation

+ + getPublicKey(); + $math = $keyPair->_math_obj; + ?> + +

The key is either read from a file or generated on the fly if no file was found.
+ It is served to the client as JSON data :

+ + + + +

2. Encryption on the client side

+ + getKeyLength(),'BCMath'); + + $plain_data = isset($_REQUEST['out']) ? ciform_decryptParam($_REQUEST['out'],$keyPair) : "password"; + + // encryption (usually using public key) + $enc_data_base64 = $rsa->encrypt($plain_data, $keyPair->getPublicKey()); + $enc_data_bin = base64_decode($enc_data_base64); + $enc_data_hex = bin2hex($enc_data_base64); + + // decryption (usually using private key) + $dec_data = $rsa->decrypt($enc_data_base64, $keyPair->getPrivateKey()); + ?> + +

The user types in a password, and Javascript encodes it. +

+ +

On the server side, the message "" would be encoded this way :

+
    +
  1. Original : +
  2. Encrypted (ciphertext in base 64) : +
  3. Decoded : + +
+

Extra :

+ + +

On the client side, it's the same, handled in Javascript :

+
+
    +
  1. The public key in Multi-Precision Integer (MPI), base64-encoded, which is going to be used for encryption :
    + +

    + +
  2. Type your message :
    characters maximum. + +

    + +
  3. Encrypt the message on the client side (nothing is transmitted over the network yet) :
    + + =>
    + The encoded value also holds meta-data about the exact encoding algorithm. +

    + +
  4. Send the encrypted data to the server : + +

    + +
+
+ + + +

3. Decrypted on the server side using the same key pair

+ +

The generated keypair was stored and retrieved for decoding :

+ +

Each parameter of the request is decrypted if required :

+

+ + $val ) + { + $dec = ciform_decryptParam($val,$keyPair); + if ( $key == "out" ) + { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + else + { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + } + ?>
KEYVALUEDECRYPTED
$key" . chunk_split($val,76,"\n") . "$dec
$key$val$dec

+ +


+ + + + + + + \ No newline at end of file