Diffstat (limited to 'frontend/gamma/tests/tests/Clipperz/PM/Crypto_test.html') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/tests/tests/Clipperz/PM/Crypto_test.html | 169 |
1 files changed, 169 insertions, 0 deletions
diff --git a/frontend/gamma/tests/tests/Clipperz/PM/Crypto_test.html b/frontend/gamma/tests/tests/Clipperz/PM/Crypto_test.html new file mode 100644 index 0000000..f5b0a60 --- a/dev/null +++ b/frontend/gamma/tests/tests/Clipperz/PM/Crypto_test.html | |||
@@ -0,0 +1,169 @@ | |||
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 | <title>Clipperz.PM.Crypto - TEST</title> | ||
32 | |||
33 | <script type="text/javascript" src="../../../../js/MochiKit/MochiKit.js"></script> | ||
34 | |||
35 | <script type='text/javascript' src='../../../../js/JSON/json2.js'></script> | ||
36 | <script type='text/javascript' src='../../../../js/Clipperz/YUI/Utils.js'></script> | ||
37 | <script type='text/javascript' src='../../../../js/Clipperz/YUI/DomHelper.js'></script> | ||
38 | |||
39 | <script type='text/javascript' src='../../../../js/Clipperz/ByteArray.js'></script> | ||
40 | <script type='text/javascript' src='../../../../js/Clipperz/Base.js'></script> | ||
41 | <script type='text/javascript' src='../../../../js/Clipperz/Async.js'></script> | ||
42 | <script type='text/javascript' src='../../../../js/Clipperz/DOM.js'></script> | ||
43 | <script type='text/javascript' src='../../../../js/Clipperz/Logging.js'></script> | ||
44 | |||
45 | <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SHA.js'></script> | ||
46 | <script type='text/javascript' src='../../../../js/Clipperz/Crypto/AES.js'></script> | ||
47 | <script type='text/javascript' src='../../../../js/Clipperz/Crypto/PRNG.js'></script> | ||
48 | <script type='text/javascript' src='../../../../js/Clipperz/Crypto/BigInt.js'></script> | ||
49 | <script type='text/javascript' src='../../../../js/Clipperz/Crypto/Base.js'></script> | ||
50 | <script type='text/javascript' src='../../../../js/Clipperz/Crypto/SRP.js'></script> | ||
51 | |||
52 | <script type='text/javascript' src='../../../../js/Clipperz/PM/Proxy.js'></script> | ||
53 | <script type='text/javascript' src='../../../../js/Clipperz/PM/Connection.js'></script> | ||
54 | <script type='text/javascript' src='../../../../js/Clipperz/PM/Crypto.js'></script> | ||
55 | |||
56 | |||
57 | <!-- ================================================================================ --> <script> | ||
58 | //MochiKit.DOM.addLoadEvent(MochiKit.Base.partial(MochiKit.LoggingPane.createLoggingPane, true)); | ||
59 | //MochiKit.Logging.logger.useNativeConsole = true; | ||
60 | |||
61 | //----------------------------------------------------------------------------- | ||
62 | |||
63 | encodePassword = function (anEvent) { | ||
64 | varusername; | ||
65 | var password; | ||
66 | var encodedPassword; | ||
67 | var srpConnection; | ||
68 | |||
69 | anEvent.stop(); | ||
70 | |||
71 | srpConnection = new Clipperz.PM.Connection.SRP['1.1'](); | ||
72 | |||
73 | username = MochiKit.DOM.getElement('username').value; | ||
74 | passphrase = MochiKit.DOM.getElement('passphrase').value; | ||
75 | encodedPassword = srpConnection.normalizedCredentials({'username':username , 'password':passphrase })['password']; | ||
76 | |||
77 | MochiKit.DOM.getElement('encodedPassword').value = encodedPassword; | ||
78 | } | ||
79 | |||
80 | //----------------------------------------------------------------------------- | ||
81 | |||
82 | decryptData = function (anEvent) { | ||
83 | vardeferredResult; | ||
84 | varkey; | ||
85 | varversion; | ||
86 | var value; | ||
87 | |||
88 | key = MochiKit.DOM.getElement('key').value; | ||
89 | version = MochiKit.DOM.getElement('version').value; | ||
90 | value = MochiKit.DOM.getElement('encryptedText').value; | ||
91 | |||
92 | anEvent.stop(); | ||
93 | |||
94 | deferredResult = new Clipperz.Async.Deferred("Decrypted data", {trace:false}); | ||
95 | deferredResult.addCallback(Clipperz.PM.Crypto.deferredDecrypt, {key:key, version:version, value:value}); | ||
96 | deferredResult.addCallback(Clipperz.Base.serializeJSON); | ||
97 | deferredResult.addCallback(function (aValue) { | ||
98 | MochiKit.DOM.getElement('decryptedText').value = aValue; | ||
99 | }); | ||
100 | deferredResult.addErrback(alert); | ||
101 | |||
102 | deferredResult.callback(); | ||
103 | } | ||
104 | |||
105 | //----------------------------------------------------------------------------- | ||
106 | |||
107 | encryptData = function (anEvent) { | ||
108 | vardeferredResult; | ||
109 | varkey; | ||
110 | varversion; | ||
111 | var value; | ||
112 | |||
113 | key = MochiKit.DOM.getElement('key').value; | ||
114 | version = MochiKit.DOM.getElement('version').value; | ||
115 | value = Clipperz.Base.evalJSON(MochiKit.DOM.getElement('decryptedText').value); | ||
116 | |||
117 | anEvent.stop(); | ||
118 | |||
119 | deferredResult = new Clipperz.Async.Deferred("Encrypted data", {trace:false}); | ||
120 | deferredResult.addCallback(Clipperz.PM.Crypto.deferredEncrypt, {key:key, version:version, value:value}); | ||
121 | deferredResult.addCallback(function (aValue) { | ||
122 | MochiKit.DOM.getElement('encryptedText').value = aValue; | ||
123 | }); | ||
124 | deferredResult.addErrback(alert); | ||
125 | |||
126 | deferredResult.callback(); | ||
127 | } | ||
128 | |||
129 | //----------------------------------------------------------------------------- | ||
130 | |||
131 | init = function () { | ||
132 | Clipperz.Crypto.PRNG.defaultRandomGenerator().fastEntropyAccumulationForTestingPurpose(); | ||
133 | |||
134 | |||
135 | MochiKit.Signal.connect('decryptForm', 'onsubmit', decryptData) | ||
136 | MochiKit.Signal.connect('decryptButton', 'onclick', decryptData) | ||
137 | MochiKit.Signal.connect('encryptButton', 'onclick', encryptData) | ||
138 | |||
139 | //MochiKit.Signal.connect('encodePassword', 'onclick', encodePassword) | ||
140 | } | ||
141 | |||
142 | //----------------------------------------------------------------------------- | ||
143 | |||
144 | MochiKit.DOM.addLoadEvent(init); | ||
145 | |||
146 | </script> <!-- =============================================================================== --> | ||
147 | |||
148 | </head> | ||
149 | <body> | ||
150 | <!-- | ||
151 | <form id='computeKey'> | ||
152 | <input type='text' name='username' value='' id='username' size='30'/> | ||
153 | <input type='text' name='passphrase' value='' id='passphrase' size='30'/> | ||
154 | <input type='button' name='encode' value='encode' id='encodePassword'> | ||
155 | <input type='text' name='encodedPassword' value='' id='encodedPassword' size='30'/> | ||
156 | </form> | ||
157 | <hr> | ||
158 | --> | ||
159 | <form id='decryptForm'> | ||
160 | <div><textarea id='encryptedText' cols='80' rows='20'></textarea></div> | ||
161 | <div><input type='text' name='key' value='' id='key' size='30'/></div> | ||
162 | <div><input type='text' name='version' value='0.3' id='version' /></div> | ||
163 | <div><input type='button' name='decrypt' value='decrypt' id='decryptButton'> <input type='button' name='encrypt' value='encrypt' id='encryptButton'></div> | ||
164 | <hr> | ||
165 | <div><textarea id='decryptedText' cols='80' rows='20' style="background-color: lightgrey;"><result></textarea></div> | ||
166 | </form> | ||
167 | |||
168 | </body> | ||
169 | </html> \ No newline at end of file | ||