2011-10-03 00:56:18 +01:00
|
|
|
<!--
|
|
|
|
|
|
|
|
Copyright 2008-2011 Clipperz Srl
|
|
|
|
|
2011-10-06 01:36:10 +01:00
|
|
|
This file is part of Clipperz Community Edition.
|
|
|
|
Clipperz Community Edition is an online password manager.
|
2011-10-03 00:56:18 +01:00
|
|
|
For further information about its features and functionalities please
|
2011-10-06 01:36:10 +01:00
|
|
|
refer to http://www.clipperz.com.
|
2011-10-03 00:56:18 +01:00
|
|
|
|
2011-10-06 01:36:10 +01:00
|
|
|
* Clipperz Community Edition is free software: you can redistribute
|
2011-10-03 00:56:18 +01:00
|
|
|
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.
|
|
|
|
|
2011-10-06 01:36:10 +01:00
|
|
|
* Clipperz Community Edition is distributed in the hope that it will
|
2011-10-03 00:56:18 +01:00
|
|
|
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
|
2011-10-06 01:36:10 +01:00
|
|
|
License along with Clipperz Community Edition. If not, see
|
2011-10-03 00:56:18 +01:00
|
|
|
<http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
-->
|
|
|
|
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<script type="text/javascript" src="../../../../js/MochiKit/MochiKit.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>
|