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