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.html | 90 |
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 @@ | |||
1 | <!-- | ||
2 | |||
3 | Copyright 2008-2011 Clipperz Srl | ||
4 | |||
5 | This file is part of Clipperz's Javascript Crypto Library. | ||
6 | Javascript Crypto Library provides web developers with an extensive | ||
7 | and efficient set of cryptographic functions. The library aims to | ||
8 | obtain maximum execution speed while preserving modularity and | ||
9 | reusability. | ||
10 | For further information about its features and functionalities please | ||
11 | refer to http://www.clipperz.com | ||
12 | |||
13 | * Javascript Crypto Library is free software: you can redistribute | ||
14 | it and/or modify it under the terms of the GNU Affero General Public | ||
15 | License as published by the Free Software Foundation, either version | ||
16 | 3 of the License, or (at your option) any later version. | ||
17 | |||
18 | * Javascript Crypto Library is distributed in the hope that it will | ||
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied | ||
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
21 | See the GNU Affero General Public License for more details. | ||
22 | |||
23 | * You should have received a copy of the GNU Affero General Public | ||
24 | License along with Javascript Crypto Library. If not, see | ||
25 | <http://www.gnu.org/licenses/>. | ||
26 | |||
27 | --> | ||
28 | |||
29 | <html> | ||
30 | <head> | ||
31 | <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script> | ||
32 | <script type="text/javascript" src="../../../../js/JSLog/jslog.js"></script> | ||
33 | <script type="text/javascript" src="../../../SimpleTest/SimpleTest.js"></script> | ||
34 | <link rel="stylesheet" type="text/css" href="../../../SimpleTest/test.css"> | ||
35 | |||
36 | <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script> | ||
37 | <script type='text/javascript' src='../../../../js/Clipperz/DOM.js'></script> | ||
38 | |||
39 | <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script> | ||
40 | <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script> | ||
41 | <script type='text/javascript' src='../../../../js/Clipperz/Crypto/RSA.js'></script> | ||
42 | |||
43 | </head> | ||
44 | <body> | ||
45 | <pre id="test"> | ||
46 | <script type="text/javascript"> | ||
47 | try { | ||
48 | varrsaPublicKey; | ||
49 | varrandomValue; | ||
50 | varpublicEncryptedValue; | ||
51 | var privateEncryptedValue; | ||
52 | |||
53 | varstartTime; | ||
54 | varendTime; | ||
55 | |||
56 | |||
57 | startTime=new Date(); | ||
58 | rsaPublicKey = Clipperz.Crypto.RSA.generatePublicKey(512); | ||
59 | |||
60 | endTime=new Date(); | ||
61 | is(true, true, 'Time to generate the RSA public key (size 512 bit): '+(endTime.getTime()-startTime.getTime())/1000.0); | ||
62 | |||
63 | randomValue = Clipperz.Crypto.Base.generateRandomSeed(); | ||
64 | publicEncryptedValue = Clipperz.Crypto.RSA.encryptUsingPublicKey(rsaPublicKey, randomValue); | ||
65 | privateEncryptedValue = Clipperz.Crypto.RSA.encryptUsingPrivateKey(rsaPublicKey, randomValue); | ||
66 | |||
67 | is(publicEncryptedValue == privateEncryptedValue, false); | ||
68 | is(Clipperz.Crypto.RSA.decryptUsingPrivateKey(rsaPublicKey, publicEncryptedValue), randomValue); | ||
69 | is(Clipperz.Crypto.RSA.decryptUsingPublicKey(rsaPublicKey, privateEncryptedValue), randomValue); | ||
70 | |||
71 | //------------------------------------------------------------------------- | ||
72 | } catch (err) { | ||
73 | |||
74 | var s = "test suite failure!\n"; | ||
75 | var o = {}; | ||
76 | var k = null; | ||
77 | for (k in err) { | ||
78 | // ensure unique keys?! | ||
79 | if (!o[k]) { | ||
80 | s += k + ": " + err[k] + "\n"; | ||
81 | o[k] = err[k]; | ||
82 | } | ||
83 | } | ||
84 | ok ( false, s ); | ||
85 | } | ||
86 | |||
87 | </script> | ||
88 | </pre> | ||
89 | </body> | ||
90 | </html> | ||