summaryrefslogtreecommitdiff
path: root/frontend/gamma/tests/tests/Clipperz/Crypto/RSA.html
Side-by-side diff
Diffstat (limited to 'frontend/gamma/tests/tests/Clipperz/Crypto/RSA.html') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/gamma/tests/tests/Clipperz/Crypto/RSA.html90
1 files changed, 90 insertions, 0 deletions
diff --git a/frontend/gamma/tests/tests/Clipperz/Crypto/RSA.html b/frontend/gamma/tests/tests/Clipperz/Crypto/RSA.html
new file mode 100644
index 0000000..468a987
--- a/dev/null
+++ b/frontend/gamma/tests/tests/Clipperz/Crypto/RSA.html
@@ -0,0 +1,90 @@
+<!--
+
+Copyright 2008-2011 Clipperz Srl
+
+This file is part of Clipperz's Javascript Crypto Library.
+Javascript Crypto Library provides web developers with an extensive
+and efficient set of cryptographic functions. The library aims to
+obtain maximum execution speed while preserving modularity and
+reusability.
+For further information about its features and functionalities please
+refer to http://www.clipperz.com
+
+* Javascript Crypto Library is free software: you can redistribute
+ it and/or modify it under the terms of the GNU Affero General Public
+ License as published by the Free Software Foundation, either version
+ 3 of the License, or (at your option) any later version.
+
+* Javascript Crypto Library is distributed in the hope that it will
+ be useful, but WITHOUT ANY WARRANTY; without even the implied
+ warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the GNU Affero General Public License for more details.
+
+* You should have received a copy of the GNU Affero General Public
+ License along with Javascript Crypto Library. If not, see
+ <http://www.gnu.org/licenses/>.
+
+-->
+
+<html>
+<head>
+ <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script>
+ <script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script>
+ <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css">
+
+ <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/DOM.js'></script>
+
+ <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script>
+ <script type='text/javascript' src='../../../../js/Clipperz/Crypto/RSA.js'></script>
+
+</head>
+<body>
+<pre id="test">
+<script type="text/javascript">
+try {
+ var rsaPublicKey;
+ var randomValue;
+ var publicEncryptedValue;
+ var privateEncryptedValue;
+
+ var startTime;
+ var endTime;
+
+
+startTime=new Date();
+ rsaPublicKey = Clipperz.Crypto.RSA.generatePublicKey(512);
+
+endTime=new Date();
+is(true, true, 'Time to generate the RSA public key (size 512 bit): '+(endTime.getTime()-startTime.getTime())/1000.0);
+
+ randomValue = Clipperz.Crypto.Base.generateRandomSeed();
+ publicEncryptedValue = Clipperz.Crypto.RSA.encryptUsingPublicKey(rsaPublicKey, randomValue);
+ privateEncryptedValue = Clipperz.Crypto.RSA.encryptUsingPrivateKey(rsaPublicKey, randomValue);
+
+ is(publicEncryptedValue == privateEncryptedValue, false);
+ is(Clipperz.Crypto.RSA.decryptUsingPrivateKey(rsaPublicKey, publicEncryptedValue), randomValue);
+ is(Clipperz.Crypto.RSA.decryptUsingPublicKey(rsaPublicKey, privateEncryptedValue), randomValue);
+
+ //-------------------------------------------------------------------------
+} catch (err) {
+
+ var s = "test suite failure!\n";
+ var o = {};
+ var k = null;
+ for (k in err) {
+ // ensure unique keys?!
+ if (!o[k]) {
+ s += k + ": " + err[k] + "\n";
+ o[k] = err[k];
+ }
+ }
+ ok ( false, s );
+}
+
+</script>
+</pre>
+</body>
+</html>