-rw-r--r-- | frontend/gamma/js/Clipperz/Crypto/AES_2.js | 843 | ||||
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/Crypto.js | 106 | ||||
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/DataModel/User.js | 4 | ||||
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js | 4 | ||||
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Test.js | 5 |
5 files changed, 924 insertions, 38 deletions
diff --git a/frontend/gamma/js/Clipperz/Crypto/AES_2.js b/frontend/gamma/js/Clipperz/Crypto/AES_2.js new file mode 100644 index 0000000..1627f39 --- a/dev/null +++ b/frontend/gamma/js/Clipperz/Crypto/AES_2.js | |||
@@ -0,0 +1,843 @@ | |||
1 | /* | ||
2 | |||
3 | Copyright 2008-2013 Clipperz Srl | ||
4 | |||
5 | This file is part of Clipperz, the online password manager. | ||
6 | For further information about its features and functionalities please | ||
7 | refer to http://www.clipperz.com. | ||
8 | |||
9 | * Clipperz is free software: you can redistribute it and/or modify it | ||
10 | under the terms of the GNU Affero General Public License as published | ||
11 | by the Free Software Foundation, either version 3 of the License, or | ||
12 | (at your option) any later version. | ||
13 | |||
14 | * Clipperz is distributed in the hope that it will be useful, but | ||
15 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
17 | See the GNU Affero General Public License for more details. | ||
18 | |||
19 | * You should have received a copy of the GNU Affero General Public | ||
20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. | ||
21 | |||
22 | */ | ||
23 | |||
24 | try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { | ||
25 | throw "Clipperz.Crypto.AES_2 depends on Clipperz.ByteArray!"; | ||
26 | } | ||
27 | |||
28 | //Dependency commented to avoid a circular reference | ||
29 | //try { if (typeof(Clipperz.Crypto.PRNG) == 'undefined') { throw ""; }} catch (e) { | ||
30 | //throw "Clipperz.Crypto.AES_2 depends on Clipperz.Crypto.PRNG!"; | ||
31 | //} | ||
32 | |||
33 | if (typeof(Clipperz.Crypto.AES_2) == 'undefined') { Clipperz.Crypto.AES_2 = {}; } | ||
34 | |||
35 | //############################################################################# | ||
36 | |||
37 | Clipperz.Crypto.AES_2.DeferredExecutionContext = function(args) { | ||
38 | args = args || {}; | ||
39 | |||
40 | this._key = args.key; | ||
41 | this._message = args.message; | ||
42 | this._result = args.message.clone(); | ||
43 | this._nonce = args.nonce; | ||
44 | this._messageLength = this._message.length(); | ||
45 | |||
46 | this._messageArray = this._message.arrayValues(); | ||
47 | this._resultArray = this._result.arrayValues(); | ||
48 | this._nonceArray = this._nonce.arrayValues(); | ||
49 | |||
50 | this._executionStep = 0; | ||
51 | |||
52 | // this._elaborationChunkSize = 1024; // 4096; // 16384; //4096; | ||
53 | this._elaborationChunks = 10; | ||
54 | this._pauseTime = 0.02; // 0.02 //0.2; | ||
55 | |||
56 | return this; | ||
57 | } | ||
58 | |||
59 | Clipperz.Crypto.AES_2.DeferredExecutionContext.prototype = MochiKit.Base.update(null, { | ||
60 | |||
61 | 'key': function() { | ||
62 | return this._key; | ||
63 | }, | ||
64 | |||
65 | 'message': function() { | ||
66 | return this._message; | ||
67 | }, | ||
68 | |||
69 | 'messageLength': function() { | ||
70 | return this._messageLength; | ||
71 | }, | ||
72 | |||
73 | 'result': function() { | ||
74 | return new Clipperz.ByteArray(this.resultArray()); | ||
75 | }, | ||
76 | |||
77 | 'nonce': function() { | ||
78 | return this._nonce; | ||
79 | }, | ||
80 | |||
81 | 'messageArray': function() { | ||
82 | return this._messageArray; | ||
83 | }, | ||
84 | |||
85 | 'resultArray': function() { | ||
86 | return this._resultArray; | ||
87 | }, | ||
88 | |||
89 | 'nonceArray': function() { | ||
90 | return this._nonceArray; | ||
91 | }, | ||
92 | |||
93 | 'elaborationChunkSize': function() { | ||
94 | // return Clipperz.Crypto.AES_2.DeferredExecution.chunkSize; | ||
95 | // return this._elaborationChunkSize; | ||
96 | return (this._elaborationChunks * 1024); | ||
97 | }, | ||
98 | |||
99 | 'executionStep': function() { | ||
100 | return this._executionStep; | ||
101 | }, | ||
102 | |||
103 | 'setExecutionStep': function(aValue) { | ||
104 | this._executionStep = aValue; | ||
105 | }, | ||
106 | |||
107 | 'tuneExecutionParameters': function (anElapsedTime) { | ||
108 | //var originalChunks = this._elaborationChunks; | ||
109 | if (anElapsedTime > 0) { | ||
110 | this._elaborationChunks = Math.round(this._elaborationChunks * ((anElapsedTime + 1000)/(anElapsedTime * 2))); | ||
111 | } | ||
112 | //Clipperz.log("tuneExecutionParameters - elapsedTime: " + anElapsedTime + /*originalChunks,*/ " chunks # " + this._elaborationChunks + " [" + this._executionStep + " / " + this._messageLength + "]"); | ||
113 | }, | ||
114 | |||
115 | 'pause': function(aValue) { | ||
116 | // return MochiKit.Async.wait(Clipperz.Crypto.AES_2.DeferredExecution.pauseTime, aValue); | ||
117 | return MochiKit.Async.wait(this._pauseTime, aValue); | ||
118 | }, | ||
119 | |||
120 | 'isDone': function () { | ||
121 | return (this._executionStep >= this._messageLength); | ||
122 | }, | ||
123 | |||
124 | //----------------------------------------------------------------------------- | ||
125 | __syntaxFix__: "syntax fix" | ||
126 | |||
127 | }); | ||
128 | |||
129 | //############################################################################# | ||
130 | |||
131 | Clipperz.Crypto.AES_2.Key = function(args) { | ||
132 | args = args || {}; | ||
133 | |||
134 | this._key = args.key; | ||
135 | this._keySize = args.keySize || this.key().length(); | ||
136 | |||
137 | if (this.keySize() == 128/8) { | ||
138 | this._b = 176; | ||
139 | this._numberOfRounds = 10; | ||
140 | } else if (this.keySize() == 256/8) { | ||
141 | this._b = 240; | ||
142 | this._numberOfRounds = 14; | ||
143 | } else { | ||
144 | Clipperz.logError("AES unsupported key size: " + (this.keySize() * 8) + " bits"); | ||
145 | throw Clipperz.Crypto.AES_2.exception.UnsupportedKeySize; | ||
146 | } | ||
147 | |||
148 | this._stretchedKey = null; | ||
149 | |||
150 | return this; | ||
151 | } | ||
152 | |||
153 | Clipperz.Crypto.AES_2.Key.prototype = MochiKit.Base.update(null, { | ||
154 | |||
155 | 'asString': function() { | ||
156 | return "Clipperz.Crypto.AES_2.Key (" + this.key().toHexString() + ")"; | ||
157 | }, | ||
158 | |||
159 | //----------------------------------------------------------------------------- | ||
160 | |||
161 | 'key': function() { | ||
162 | return this._key; | ||
163 | }, | ||
164 | |||
165 | 'keySize': function() { | ||
166 | return this._keySize; | ||
167 | }, | ||
168 | |||
169 | 'b': function() { | ||
170 | return this._b; | ||
171 | }, | ||
172 | |||
173 | 'numberOfRounds': function() { | ||
174 | return this._numberOfRounds; | ||
175 | }, | ||
176 | //========================================================================= | ||
177 | |||
178 | 'keyScheduleCore': function(aWord, aRoundConstantsIndex) { | ||
179 | varresult; | ||
180 | var sbox; | ||
181 | |||
182 | sbox = Clipperz.Crypto.AES_2.sbox(); | ||
183 | |||
184 | result = [sbox[aWord[1]] ^ Clipperz.Crypto.AES_2.roundConstants()[aRoundConstantsIndex], | ||
185 | sbox[aWord[2]], | ||
186 | sbox[aWord[3]], | ||
187 | sbox[aWord[0]]]; | ||
188 | |||
189 | return result; | ||
190 | }, | ||
191 | |||
192 | //----------------------------------------------------------------------------- | ||
193 | |||
194 | 'xorWithPreviousStretchValues': function(aKey, aWord, aPreviousWordIndex) { | ||
195 | varresult; | ||
196 | var i,c; | ||
197 | |||
198 | result = []; | ||
199 | c = 4; | ||
200 | for (i=0; i<c; i++) { | ||
201 | result[i] = aWord[i] ^ aKey.byteAtIndex(aPreviousWordIndex + i); | ||
202 | } | ||
203 | |||
204 | return result; | ||
205 | }, | ||
206 | |||
207 | //----------------------------------------------------------------------------- | ||
208 | |||
209 | 'sboxShakeup': function(aWord) { | ||
210 | var result; | ||
211 | var sbox; | ||
212 | var i,c; | ||
213 | |||
214 | result = []; | ||
215 | sbox = Clipperz.Crypto.AES_2.sbox(); | ||
216 | c =4; | ||
217 | for (i=0; i<c; i++) { | ||
218 | result[i] = sbox[aWord[i]]; | ||
219 | } | ||
220 | |||
221 | return result; | ||
222 | }, | ||
223 | |||
224 | //----------------------------------------------------------------------------- | ||
225 | |||
226 | 'stretchKey': function(aKey) { | ||
227 | varcurrentWord; | ||
228 | varkeyLength; | ||
229 | varpreviousStretchIndex; | ||
230 | var i,c; | ||
231 | |||
232 | keyLength = aKey.length(); | ||
233 | previousStretchIndex = keyLength - this.keySize(); | ||
234 | |||
235 | currentWord = [aKey.byteAtIndex(keyLength - 4), | ||
236 | aKey.byteAtIndex(keyLength - 3), | ||
237 | aKey.byteAtIndex(keyLength - 2), | ||
238 | aKey.byteAtIndex(keyLength - 1)]; | ||
239 | currentWord = this.keyScheduleCore(currentWord, keyLength / this.keySize()); | ||
240 | |||
241 | if (this.keySize() == 256/8) { | ||
242 | c = 8; | ||
243 | } else if (this.keySize() == 128/8){ | ||
244 | c = 4; | ||
245 | } | ||
246 | |||
247 | for (i=0; i<c; i++) { | ||
248 | if (i == 4) { | ||
249 | //fifth streatch word | ||
250 | currentWord = this.sboxShakeup(currentWord); | ||
251 | } | ||
252 | |||
253 | currentWord = this.xorWithPreviousStretchValues(aKey, currentWord, previousStretchIndex + (i*4)); | ||
254 | aKey.appendBytes(currentWord); | ||
255 | } | ||
256 | |||
257 | return aKey; | ||
258 | }, | ||
259 | |||
260 | //----------------------------------------------------------------------------- | ||
261 | |||
262 | 'stretchedKey': function() { | ||
263 | if (this._stretchedKey == null) { | ||
264 | var stretchedKey; | ||
265 | |||
266 | stretchedKey = this.key().clone(); | ||
267 | |||
268 | while (stretchedKey.length() < this.keySize()) { | ||
269 | stretchedKey.appendByte(0); | ||
270 | } | ||
271 | |||
272 | while (stretchedKey.length() < this.b()) { | ||
273 | stretchedKey = this.stretchKey(stretchedKey); | ||
274 | } | ||
275 | |||
276 | this._stretchedKey = stretchedKey.split(0, this.b()); | ||
277 | } | ||
278 | |||
279 | return this._stretchedKey; | ||
280 | }, | ||
281 | |||
282 | //========================================================================= | ||
283 | __syntaxFix__: "syntax fix" | ||
284 | }); | ||
285 | |||
286 | //############################################################################# | ||
287 | |||
288 | Clipperz.Crypto.AES_2.State = function(args) { | ||
289 | args = args || {}; | ||
290 | |||
291 | this._data = args.block.slice(0); | ||
292 | this._key = args.key; | ||
293 | |||
294 | return this; | ||
295 | } | ||
296 | |||
297 | Clipperz.Crypto.AES_2.State.prototype = MochiKit.Base.update(null, { | ||
298 | |||
299 | 'key': function() { | ||
300 | return this._key; | ||
301 | }, | ||
302 | |||
303 | //----------------------------------------------------------------------------- | ||
304 | |||
305 | 'data': function() { | ||
306 | return this._data; | ||
307 | }, | ||
308 | |||
309 | 'setData': function(aValue) { | ||
310 | this._data = aValue; | ||
311 | }, | ||
312 | |||
313 | //========================================================================= | ||
314 | |||
315 | 'addRoundKey': function(aRoundNumber) { | ||
316 | //each byte of the state is combined with the round key; each round key is derived from the cipher key using a key schedule. | ||
317 | vardata; | ||
318 | varstretchedKey; | ||
319 | varfirstStretchedKeyIndex; | ||
320 | var i,c; | ||
321 | |||
322 | data = this.data(); | ||
323 | stretchedKey = this.key().stretchedKey(); | ||
324 | firstStretchedKeyIndex = aRoundNumber * (128/8); | ||
325 | c = 128/8; | ||
326 | for (i=0; i<c; i++) { | ||
327 | data[i] = data[i] ^ stretchedKey.byteAtIndex(firstStretchedKeyIndex + i); | ||
328 | } | ||
329 | }, | ||
330 | |||
331 | //----------------------------------------------------------------------------- | ||
332 | |||
333 | 'subBytes': function() { | ||
334 | // a non-linear substitution step where each byte is replaced with another according to a lookup table. | ||
335 | var i,c; | ||
336 | vardata; | ||
337 | var sbox; | ||
338 | |||
339 | data = this.data(); | ||
340 | sbox = Clipperz.Crypto.AES_2.sbox(); | ||
341 | |||
342 | c = 16; | ||
343 | for (i=0; i<c; i++) { | ||
344 | data[i] = sbox[data[i]]; | ||
345 | } | ||
346 | }, | ||
347 | |||
348 | //----------------------------------------------------------------------------- | ||
349 | |||
350 | 'shiftRows': function() { | ||
351 | //a transposition step where each row of the state is shifted cyclically a certain number of steps. | ||
352 | varnewValue; | ||
353 | vardata; | ||
354 | varshiftMapping; | ||
355 | vari,c; | ||
356 | |||
357 | newValue = new Array(16); | ||
358 | data = this.data(); | ||
359 | shiftMapping = Clipperz.Crypto.AES_2.shiftRowMapping(); | ||
360 | // [0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, 1, 6, 11]; | ||
361 | c = 16; | ||
362 | for (i=0; i<c; i++) { | ||
363 | newValue[i] = data[shiftMapping[i]]; | ||
364 | } | ||
365 | for (i=0; i<c; i++) { | ||
366 | data[i] = newValue[i]; | ||
367 | } | ||
368 | }, | ||
369 | |||
370 | //----------------------------------------------------------------------------- | ||
371 | /* | ||
372 | 'mixColumnsWithValues': function(someValues) { | ||
373 | varresult; | ||
374 | vara; | ||
375 | var i,c; | ||
376 | |||
377 | c = 4; | ||
378 | result = []; | ||
379 | a = []; | ||
380 | for (i=0; i<c; i++) { | ||
381 | a[i] = []; | ||
382 | a[i][1] = someValues[i] | ||
383 | if ((a[i][1] & 0x80) == 0x80) { | ||
384 | a[i][2] = (a[i][1] << 1) ^ 0x11b; | ||
385 | } else { | ||
386 | a[i][2] = a[i][1] << 1; | ||
387 | } | ||
388 | |||
389 | a[i][3] = a[i][2] ^ a[i][1]; | ||
390 | } | ||
391 | |||
392 | for (i=0; i<c; i++) { | ||
393 | varx; | ||
394 | |||
395 | x = Clipperz.Crypto.AES_2.mixColumnsMatrix()[i]; | ||
396 | result[i] = a[0][x[0]] ^ a[1][x[1]] ^ a[2][x[2]] ^ a[3][x[3]]; | ||
397 | } | ||
398 | |||
399 | return result; | ||
400 | }, | ||
401 | |||
402 | 'mixColumns': function() { | ||
403 | //a mixing operation which operates on the columns of the state, combining the four bytes in each column using a linear transformation. | ||
404 | var data; | ||
405 | var i, c; | ||
406 | |||
407 | data = this.data(); | ||
408 | c = 4; | ||
409 | for(i=0; i<c; i++) { | ||
410 | varblockIndex; | ||
411 | var mixedValues; | ||
412 | |||
413 | blockIndex = i * 4; | ||
414 | mixedValues = this.mixColumnsWithValues([data[blockIndex + 0], | ||
415 | data[blockIndex + 1], | ||
416 | data[blockIndex + 2], | ||
417 | data[blockIndex + 3]]); | ||
418 | data[blockIndex + 0] = mixedValues[0]; | ||
419 | data[blockIndex + 1] = mixedValues[1]; | ||
420 | data[blockIndex + 2] = mixedValues[2]; | ||
421 | data[blockIndex + 3] = mixedValues[3]; | ||
422 | } | ||
423 | }, | ||
424 | */ | ||
425 | |||
426 | 'mixColumns': function() { | ||
427 | //a mixing operation which operates on the columns of the state, combining the four bytes in each column using a linear transformation. | ||
428 | var data; | ||
429 | var i, c; | ||
430 | var a_1; | ||
431 | var a_2; | ||
432 | |||
433 | a_1 = new Array(4); | ||
434 | a_2 = new Array(4); | ||
435 | |||
436 | data = this.data(); | ||
437 | c = 4; | ||
438 | for(i=0; i<c; i++) { | ||
439 | varblockIndex; | ||
440 | var ii, cc; | ||
441 | |||
442 | blockIndex = i * 4; | ||
443 | |||
444 | cc = 4; | ||
445 | for (ii=0; ii<cc; ii++) { | ||
446 | var value; | ||
447 | |||
448 | value = data[blockIndex + ii]; | ||
449 | a_1[ii] = value; | ||
450 | a_2[ii] = (value & 0x80) ? ((value << 1) ^ 0x011b) : (value << 1); | ||
451 | } | ||
452 | |||
453 | data[blockIndex + 0] = a_2[0] ^ a_1[1] ^ a_2[1] ^ a_1[2] ^ a_1[3]; | ||
454 | data[blockIndex + 1] = a_1[0] ^ a_2[1] ^ a_1[2] ^ a_2[2] ^ a_1[3]; | ||
455 | data[blockIndex + 2] = a_1[0] ^ a_1[1] ^ a_2[2] ^ a_1[3] ^ a_2[3]; | ||
456 | data[blockIndex + 3] = a_1[0] ^ a_2[0] ^ a_1[1] ^ a_1[2] ^ a_2[3]; | ||
457 | } | ||
458 | }, | ||
459 | |||
460 | //========================================================================= | ||
461 | |||
462 | 'spinRound': function(aRoundNumber) { | ||
463 | this.addRoundKey(aRoundNumber); | ||
464 | this.subBytes(); | ||
465 | this.shiftRows(); | ||
466 | this.mixColumns(); | ||
467 | }, | ||
468 | |||
469 | 'spinLastRound': function() { | ||
470 | this.addRoundKey(this.key().numberOfRounds() - 1); | ||
471 | this.subBytes(); | ||
472 | this.shiftRows(); | ||
473 | this.addRoundKey(this.key().numberOfRounds()); | ||
474 | }, | ||
475 | |||
476 | //========================================================================= | ||
477 | |||
478 | 'encrypt': function() { | ||
479 | vari,c; | ||
480 | |||
481 | c = this.key().numberOfRounds() - 1; | ||
482 | for (i=0; i<c; i++) { | ||
483 | this.spinRound(i); | ||
484 | } | ||
485 | |||
486 | this.spinLastRound(); | ||
487 | }, | ||
488 | |||
489 | //========================================================================= | ||
490 | __syntaxFix__: "syntax fix" | ||
491 | }); | ||
492 | |||
493 | //############################################################################# | ||
494 | |||
495 | Clipperz.Crypto.AES_2.VERSION = "0.1"; | ||
496 | Clipperz.Crypto.AES_2.NAME = "Clipperz.Crypto.AES_2"; | ||
497 | |||
498 | MochiKit.Base.update(Clipperz.Crypto.AES_2, { | ||
499 | |||
500 | //http://www.cs.eku.edu/faculty/styer/460/Encrypt/JS-AES.html | ||
501 | //http://en.wikipedia.org/wiki/Advanced_Encryption_Standard | ||
502 | //http://en.wikipedia.org/wiki/Rijndael_key_schedule | ||
503 | //http://en.wikipedia.org/wiki/Rijndael_S-box | ||
504 | |||
505 | '__repr__': function () { | ||
506 | return "[" + this.NAME + " " + this.VERSION + "]"; | ||
507 | }, | ||
508 | |||
509 | 'toString': function () { | ||
510 | return this.__repr__(); | ||
511 | }, | ||
512 | |||
513 | //============================================================================= | ||
514 | |||
515 | '_sbox': null, | ||
516 | 'sbox': function() { | ||
517 | if (Clipperz.Crypto.AES_2._sbox == null) { | ||
518 | Clipperz.Crypto.AES_2._sbox = [ | ||
519 | 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, | ||
520 | 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, | ||
521 | 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, | ||
522 | 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, | ||
523 | 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, | ||
524 | 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, | ||
525 | 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, | ||
526 | 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, | ||
527 | 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, | ||
528 | 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, | ||
529 | 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, | ||
530 | 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, | ||
531 | 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, | ||
532 | 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, | ||
533 | 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, | ||
534 | 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 | ||
535 | ]; | ||
536 | } | ||
537 | |||
538 | return Clipperz.Crypto.AES_2._sbox; | ||
539 | }, | ||
540 | |||
541 | //----------------------------------------------------------------------------- | ||
542 | // | ||
543 | // 0 4 8 12 0 4 812 | ||
544 | // 1 5 9 13 => 5 9 131 | ||
545 | // 2 6 10 14 10 14 26 | ||
546 | // 3 7 11 15 15 3 711 | ||
547 | // | ||
548 | '_shiftRowMapping': null, | ||
549 | 'shiftRowMapping': function() { | ||
550 | if (Clipperz.Crypto.AES_2._shiftRowMapping == null) { | ||
551 | Clipperz.Crypto.AES_2._shiftRowMapping = [0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, 1, 6, 11]; | ||
552 | } | ||
553 | |||
554 | return Clipperz.Crypto.AES_2._shiftRowMapping; | ||
555 | }, | ||
556 | |||
557 | //----------------------------------------------------------------------------- | ||
558 | |||
559 | '_mixColumnsMatrix': null, | ||
560 | 'mixColumnsMatrix': function() { | ||
561 | if (Clipperz.Crypto.AES_2._mixColumnsMatrix == null) { | ||
562 | Clipperz.Crypto.AES_2._mixColumnsMatrix = [[2, 3, 1 ,1], | ||
563 | [1, 2, 3, 1], | ||
564 | [1, 1, 2, 3], | ||
565 | [3, 1, 1, 2] ]; | ||
566 | } | ||
567 | |||
568 | return Clipperz.Crypto.AES_2._mixColumnsMatrix; | ||
569 | }, | ||
570 | |||
571 | '_roundConstants': null, | ||
572 | 'roundConstants': function() { | ||
573 | if (Clipperz.Crypto.AES_2._roundConstants == null) { | ||
574 | Clipperz.Crypto.AES_2._roundConstants = [ , 1, 2, 4, 8, 16, 32, 64, 128, 27, 54, 108, 216, 171, 77, 154]; | ||
575 | // Clipperz.Crypto.AES_2._roundConstants = [ , 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a]; | ||
576 | } | ||
577 | |||
578 | return Clipperz.Crypto.AES_2._roundConstants; | ||
579 | }, | ||
580 | |||
581 | //============================================================================= | ||
582 | |||
583 | 'incrementNonce': function(nonce) { | ||
584 | var i; | ||
585 | var done; | ||
586 | |||
587 | done = false; | ||
588 | i = nonce.length - 1; | ||
589 | |||
590 | while ((i>=0) && (done == false)) { | ||
591 | var currentByteValue; | ||
592 | |||
593 | currentByteValue = nonce[i]; | ||
594 | |||
595 | if (currentByteValue == 0xff) { | ||
596 | nonce[i] = 0; | ||
597 | if (i>= 0) { | ||
598 | i --; | ||
599 | } else { | ||
600 | done = true; | ||
601 | } | ||
602 | } else { | ||
603 | nonce[i] = currentByteValue + 1; | ||
604 | done = true; | ||
605 | } | ||
606 | } | ||
607 | }, | ||
608 | |||
609 | //----------------------------------------------------------------------------- | ||
610 | |||
611 | 'encryptBlock': function(aKey, aBlock) { | ||
612 | varresult; | ||
613 | varstate; | ||
614 | |||
615 | state = new Clipperz.Crypto.AES_2.State({block:aBlock, key:aKey}); | ||
616 | //is(state.data(), 'before'); | ||
617 | state.encrypt(); | ||
618 | result = state.data(); | ||
619 | |||
620 | return result; | ||
621 | }, | ||
622 | |||
623 | //----------------------------------------------------------------------------- | ||
624 | |||
625 | 'encryptBlocks': function(aKey, aMessage, aNonce) { | ||
626 | varresult; | ||
627 | var nonce; | ||
628 | var self; | ||
629 | varmessageIndex; | ||
630 | varmessageLength; | ||
631 | var blockSize; | ||
632 | |||
633 | self = Clipperz.Crypto.AES_2; | ||
634 | blockSize = 128/8; | ||
635 | messageLength = aMessage.length; | ||
636 | nonce = aNonce; | ||
637 | |||
638 | result = aMessage; | ||
639 | messageIndex = 0; | ||
640 | while (messageIndex < messageLength) { | ||
641 | var encryptedBlock; | ||
642 | var i,c; | ||
643 | |||
644 | encryptedBlock = self.encryptBlock(aKey, nonce); | ||
645 | |||
646 | if ((messageLength - messageIndex) > blockSize) { | ||
647 | c = blockSize; | ||
648 | } else { | ||
649 | c = messageLength - messageIndex; | ||
650 | } | ||
651 | |||
652 | for (i=0; i<c; i++) { | ||
653 | result[messageIndex + i] = result[messageIndex + i] ^ encryptedBlock[i]; | ||
654 | } | ||
655 | |||
656 | messageIndex += blockSize; | ||
657 | // nonce = self.incrementNonce(nonce); | ||
658 | self.incrementNonce(nonce) | ||
659 | } | ||
660 | |||
661 | return result; | ||
662 | }, | ||
663 | |||
664 | //----------------------------------------------------------------------------- | ||
665 | |||
666 | 'encrypt': function(aKey, someData, aNonce) { | ||
667 | var result; | ||
668 | var nonce; | ||
669 | varencryptedData; | ||
670 | var key; | ||
671 | |||
672 | key = new Clipperz.Crypto.AES_2.Key({key:aKey}); | ||
673 | nonce = aNonce ? aNonce.clone() : Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(128/8); | ||
674 | |||
675 | encryptedData = Clipperz.Crypto.AES_2.encryptBlocks(key, someData.arrayValues(), nonce.arrayValues()); | ||
676 | |||
677 | result = nonce.appendBytes(encryptedData); | ||
678 | |||
679 | return result; | ||
680 | }, | ||
681 | |||
682 | //----------------------------------------------------------------------------- | ||
683 | |||
684 | 'decrypt': function(aKey, someData) { | ||
685 | var result; | ||
686 | var nonce; | ||
687 | var encryptedData; | ||
688 | var decryptedData; | ||
689 | vardataIterator; | ||
690 | var key; | ||
691 | |||
692 | key = new Clipperz.Crypto.AES_2.Key({key:aKey}); | ||
693 | |||
694 | encryptedData = someData.arrayValues(); | ||
695 | nonce = encryptedData.slice(0, (128/8)); | ||
696 | encryptedData = encryptedData.slice(128/8); | ||
697 | decryptedData = Clipperz.Crypto.AES_2.encryptBlocks(key, encryptedData, nonce); | ||
698 | |||
699 | result = new Clipperz.ByteArray(decryptedData); | ||
700 | |||
701 | return result; | ||
702 | }, | ||
703 | |||
704 | //============================================================================= | ||
705 | |||
706 | 'deferredEncryptExecutionChunk': function(anExecutionContext) { | ||
707 | varresult; | ||
708 | var nonce; | ||
709 | var self; | ||
710 | varmessageIndex; | ||
711 | varmessageLength; | ||
712 | var blockSize; | ||
713 | var executionLimit; | ||
714 | var startTime, endTime; | ||
715 | |||
716 | self = Clipperz.Crypto.AES_2; | ||
717 | startTime = new Date(); | ||
718 | blockSize = 128/8; | ||
719 | messageLength = anExecutionContext.messageArray().length; | ||
720 | nonce = anExecutionContext.nonceArray(); | ||
721 | result = anExecutionContext.resultArray(); | ||
722 | |||
723 | messageIndex = anExecutionContext.executionStep(); | ||
724 | executionLimit = messageIndex + anExecutionContext.elaborationChunkSize(); | ||
725 | executionLimit = Math.min(executionLimit, messageLength); | ||
726 | |||
727 | while (messageIndex < executionLimit) { | ||
728 | var encryptedBlock; | ||
729 | var i,c; | ||
730 | |||
731 | //console.log("+++ nonce: [" + nonce + "]") | ||
732 | encryptedBlock = self.encryptBlock(anExecutionContext.key(), nonce); | ||
733 | |||
734 | if ((executionLimit - messageIndex) > blockSize) { | ||
735 | c = blockSize; | ||
736 | } else { | ||
737 | c = executionLimit - messageIndex; | ||
738 | } | ||
739 | |||
740 | for (i=0; i<c; i++) { | ||
741 | result[messageIndex + i] = result[messageIndex + i] ^ encryptedBlock[i]; | ||
742 | } | ||
743 | |||
744 | messageIndex += blockSize; | ||
745 | // nonce = self.incrementNonce(nonce); | ||
746 | self.incrementNonce(nonce); | ||
747 | } | ||
748 | anExecutionContext.setExecutionStep(messageIndex); | ||
749 | endTime = new Date(); | ||
750 | anExecutionContext.tuneExecutionParameters(endTime - startTime); | ||
751 | |||
752 | return anExecutionContext; | ||
753 | }, | ||
754 | |||
755 | //----------------------------------------------------------------------------- | ||
756 | |||
757 | 'deferredEncryptBlocks': function(anExecutionContext) { | ||
758 | vardeferredResult; | ||
759 | |||
760 | //console.log("executionContext", anExecutionContext) | ||
761 | //console.log(" --- nonce: " + anExecutionContext.nonceArray()) | ||
762 | if (! anExecutionContext.isDone()) { | ||
763 | deferredResult = Clipperz.Async.callbacks("Clipperz.Crypto.AES_2.deferredEncryptBloks", [ | ||
764 | Clipperz.Crypto.AES_2.deferredEncryptExecutionChunk, | ||
765 | MochiKit.Base.method(anExecutionContext, 'pause'), | ||
766 | Clipperz.Crypto.AES_2.deferredEncryptBlocks | ||
767 | ], {trace:false}, anExecutionContext); | ||
768 | } else { | ||
769 | deferredResult = MochiKit.Async.succeed(anExecutionContext); | ||
770 | } | ||
771 | |||
772 | return deferredResult; | ||
773 | }, | ||
774 | |||
775 | //----------------------------------------------------------------------------- | ||
776 | |||
777 | 'deferredEncrypt': function(aKey, someData, aNonce) { | ||
778 | var deferredResult; | ||
779 | varexecutionContext; | ||
780 | var result; | ||
781 | var nonce; | ||
782 | var key; | ||
783 | |||
784 | key = new Clipperz.Crypto.AES_2.Key({key:aKey}); | ||
785 | nonce = aNonce ? aNonce.clone() : Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(128/8); | ||
786 | |||
787 | executionContext = new Clipperz.Crypto.AES_2.DeferredExecutionContext({key:key, message:someData, nonce:nonce}); | ||
788 | |||
789 | deferredResult = new Clipperz.Async.Deferred("AES.deferredEncrypt"); | ||
790 | deferredResult.addCallback(Clipperz.Crypto.AES_2.deferredEncryptBlocks); | ||
791 | deferredResult.addCallback(function(anExecutionContext) { | ||
792 | var result; | ||
793 | |||
794 | result = anExecutionContext.nonce().clone(); | ||
795 | result.appendBytes(anExecutionContext.resultArray()); | ||
796 | |||
797 | return result; | ||
798 | }); | ||
799 | deferredResult.callback(executionContext) | ||
800 | |||
801 | return deferredResult; | ||
802 | }, | ||
803 | |||
804 | //----------------------------------------------------------------------------- | ||
805 | |||
806 | 'deferredDecrypt': function(aKey, someData) { | ||
807 | var deferredResult | ||
808 | var nonce; | ||
809 | var message; | ||
810 | var key; | ||
811 | |||
812 | key = new Clipperz.Crypto.AES_2.Key({key:aKey}); | ||
813 | nonce = someData.split(0, (128/8)); | ||
814 | //console.log("nonce: [" + nonce.arrayValues() + "]") | ||
815 | message = someData.split(128/8); | ||
816 | //console.log("message: [" + message.arrayValues() + "]") | ||
817 | executionContext = new Clipperz.Crypto.AES_2.DeferredExecutionContext({key:key, message:message, nonce:nonce}); | ||
818 | |||
819 | deferredResult = new Clipperz.Async.Deferred("AES.deferredDecrypt"); | ||
820 | deferredResult.addCallback(Clipperz.Crypto.AES_2.deferredEncryptBlocks); | ||
821 | deferredResult.addCallback(function(anExecutionContext) { | ||
822 | return anExecutionContext.result(); | ||
823 | }); | ||
824 | deferredResult.callback(executionContext); | ||
825 | |||
826 | return deferredResult; | ||
827 | }, | ||
828 | |||
829 | //----------------------------------------------------------------------------- | ||
830 | __syntaxFix__: "syntax fix" | ||
831 | |||
832 | }); | ||
833 | |||
834 | //############################################################################# | ||
835 | |||
836 | //Clipperz.Crypto.AES_2.DeferredExecution = { | ||
837 | // 'chunkSize': 16384, // 4096, // 1024 4096 8192 1638432768; | ||
838 | // 'pauseTime': 0.02 //0.2 | ||
839 | //} | ||
840 | |||
841 | Clipperz.Crypto.AES_2.exception = { | ||
842 | 'UnsupportedKeySize': new MochiKit.Base.NamedError("Clipperz.Crypto.AES_2.exception.UnsupportedKeySize") | ||
843 | }; | ||
diff --git a/frontend/gamma/js/Clipperz/PM/Crypto.js b/frontend/gamma/js/Clipperz/PM/Crypto.js index cd10e33..7edf17f 100644 --- a/frontend/gamma/js/Clipperz/PM/Crypto.js +++ b/frontend/gamma/js/Clipperz/PM/Crypto.js | |||
@@ -60,7 +60,7 @@ MochiKit.Base.update(Clipperz.PM.Crypto, { | |||
60 | //------------------------------------------------------------------------- | 60 | //------------------------------------------------------------------------- |
61 | 61 | ||
62 | 'encryptingFunctions': { | 62 | 'encryptingFunctions': { |
63 | 'currentVersion': '0.3', | 63 | 'currentVersion': '0.4', |
64 | 'versions': { | 64 | 'versions': { |
65 | 65 | ||
66 | //##################################################################### | 66 | //##################################################################### |
@@ -320,6 +320,7 @@ MochiKit.Base.update(Clipperz.PM.Crypto, { | |||
320 | deferredResult.addCallback(MochiKit.Async.wait, 0.1); | 320 | deferredResult.addCallback(MochiKit.Async.wait, 0.1); |
321 | deferredResult.addCallback(Clipperz.Base.evalJSON); | 321 | deferredResult.addCallback(Clipperz.Base.evalJSON); |
322 | deferredResult.addErrback(function(anError) { | 322 | deferredResult.addErrback(function(anError) { |
323 | console.log("PIPPO_1", anError) | ||
323 | Clipperz.logError("Error while decrypting data [4]"); | 324 | Clipperz.logError("Error while decrypting data [4]"); |
324 | throw Clipperz.Crypto.Base.exception.CorruptedMessage; | 325 | throw Clipperz.Crypto.Base.exception.CorruptedMessage; |
325 | }) | 326 | }) |
@@ -344,11 +345,10 @@ MochiKit.Base.update(Clipperz.PM.Crypto, { | |||
344 | 345 | ||
345 | return result; | 346 | return result; |
346 | } | 347 | } |
347 | |||
348 | }, | 348 | }, |
349 | 349 | ||
350 | //##################################################################### | 350 | //##################################################################### |
351 | /* | 351 | |
352 | '0.4': { | 352 | '0.4': { |
353 | 'encrypt': function(aKey, aValue, aNonce) { | 353 | 'encrypt': function(aKey, aValue, aNonce) { |
354 | var result; | 354 | var result; |
@@ -357,30 +357,35 @@ MochiKit.Base.update(Clipperz.PM.Crypto, { | |||
357 | var dataToEncrypt; | 357 | var dataToEncrypt; |
358 | var encryptedData; | 358 | var encryptedData; |
359 | 359 | ||
360 | //Clipperz.logDebug(">>> [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt"); | ||
361 | key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey)); | 360 | key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey)); |
362 | //Clipperz.logDebug("--- [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt - 1"); | ||
363 | value = Clipperz.Base.serializeJSON(aValue); | 361 | value = Clipperz.Base.serializeJSON(aValue); |
364 | //Clipperz.logDebug("--- [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt - 2"); | ||
365 | / * | ||
366 | //Clipperz.logDebug("--> encrypt.fullSize: " + value.length); | ||
367 | value = value.replace(/":{"label":"/g, '":{l:"'); | ||
368 | value = value.replace(/":{"key":"/g, '":{k:"'); | ||
369 | value = value.replace(/":{"notes":"/g, '":{n:"'); | ||
370 | value = value.replace(/":{"record":"/g, '":{r:"'); | ||
371 | value = value.replace(/", "label":"/g, '",l:"'); | ||
372 | value = value.replace(/", "favicon":"/g,'",f:"'); | ||
373 | //Clipperz.logDebug("<-- encrypt.compressed: " + value.length); | ||
374 | * / | ||
375 | data = new Clipperz.ByteArray(value); | 362 | data = new Clipperz.ByteArray(value); |
376 | //Clipperz.logDebug("--- [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt - 3"); | 363 | encryptedData = Clipperz.Crypto.AES_2.encrypt(key, data, aNonce); |
377 | encryptedData = Clipperz.Crypto.AES.encrypt(key, data, aNonce); | ||
378 | //Clipperz.logDebug("--- [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt - 4"); | ||
379 | result = encryptedData.toBase64String(); | 364 | result = encryptedData.toBase64String(); |
380 | //Clipperz.logDebug("<<< [" + (new Date()).valueOf() + "] Clipperz.PM.Crypto.versions[0.3].encrypt"); | ||
381 | 365 | ||
382 | return result; | 366 | return result; |
383 | }, | 367 | }, |
368 | |||
369 | 'deferredEncrypt': function(aKey, aValue, aNonce) { | ||
370 | var deferredResult; | ||
371 | varkey, value; | ||
372 | var data; | ||
373 | var dataToEncrypt; | ||
374 | var encryptedData; | ||
375 | |||
376 | key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey)); | ||
377 | value = Clipperz.Base.serializeJSON(aValue); | ||
378 | data = new Clipperz.ByteArray(value); | ||
379 | |||
380 | deferredResult = new Clipperz.Async.Deferred("Crypto[0.4].deferredEncrypt") | ||
381 | deferredResult.addCallback(Clipperz.Crypto.AES_2.deferredEncrypt, key, data, aNonce); | ||
382 | deferredResult.addCallback(function(aResult) { | ||
383 | return aResult.toBase64String(); | ||
384 | }) | ||
385 | deferredResult.callback(); | ||
386 | |||
387 | return deferredResult; | ||
388 | }, | ||
384 | 389 | ||
385 | 'decrypt': function(aKey, aValue) { | 390 | 'decrypt': function(aKey, aValue) { |
386 | var result; | 391 | var result; |
@@ -392,25 +397,16 @@ MochiKit.Base.update(Clipperz.PM.Crypto, { | |||
392 | key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey)); | 397 | key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey)); |
393 | value = new Clipperz.ByteArray().appendBase64String(aValue); | 398 | value = new Clipperz.ByteArray().appendBase64String(aValue); |
394 | 399 | ||
395 | decryptedData = Clipperz.Crypto.AES.decrypt(key, value); | 400 | decryptedData = Clipperz.Crypto.AES_2.decrypt(key, value); |
396 | 401 | ||
397 | value = decryptedData.asString(); | 402 | value = decryptedData.asString(); |
398 | / * | ||
399 | value = value.replace(/":{l:"/g,'":{"label":"'); | ||
400 | value = value.replace(/":{k:"/g,'":{"key":"'); | ||
401 | value = value.replace(/":{n:"/g,'":{"notes":"'); | ||
402 | value = value.replace(/":{r:"/g,'":{"record":"'); | ||
403 | value = value.replace(/",l:"/g, '", "label":"'); | ||
404 | value = value.replace(/",f:"/g, '", "favicon":"'); | ||
405 | * / | ||
406 | try { | 403 | try { |
407 | result = Clipperz.Base.evalJSON(value); | 404 | result = Clipperz.Base.evalJSON(value); |
408 | } catch (exception) { | 405 | } catch (exception) { |
409 | Clipperz.logError("Error while decrypting data"); | 406 | console.log("PIPPO_2", anError) |
407 | Clipperz.logError("Error while decrypting data [4]"); | ||
410 | throw Clipperz.Crypto.Base.exception.CorruptedMessage; | 408 | throw Clipperz.Crypto.Base.exception.CorruptedMessage; |
411 | } | 409 | } |
412 | |||
413 | |||
414 | } else { | 410 | } else { |
415 | result = null; | 411 | result = null; |
416 | } | 412 | } |
@@ -418,9 +414,51 @@ MochiKit.Base.update(Clipperz.PM.Crypto, { | |||
418 | return result; | 414 | return result; |
419 | }, | 415 | }, |
420 | 416 | ||
421 | 'hash': Clipperz.Crypto.SHA.sha_d256 | 417 | 'deferredDecrypt': function(aKey, aValue) { |
418 | var deferredResult; | ||
419 | |||
420 | deferredResult = new Clipperz.Async.Deferred("Crypto[0.4].deferredDecrypt", {trace: false}); | ||
421 | |||
422 | if (aValue != null) { | ||
423 | var key, value; | ||
424 | |||
425 | key = Clipperz.Crypto.SHA.sha_d256(new Clipperz.ByteArray(aKey)); | ||
426 | value = new Clipperz.ByteArray().appendBase64String(aValue); | ||
427 | |||
428 | deferredResult.addCallback(Clipperz.Crypto.AES_2.deferredDecrypt, key, value); | ||
429 | deferredResult.addCallback(MochiKit.Async.wait, 0.1); | ||
430 | deferredResult.addCallback(function(aResult) { | ||
431 | return aResult.asString(); | ||
432 | }); | ||
433 | deferredResult.addCallback(MochiKit.Async.wait, 0.1); | ||
434 | deferredResult.addCallback(Clipperz.Base.evalJSON); | ||
435 | deferredResult.addErrback(function(anError) { | ||
436 | Clipperz.logError("Error while decrypting data [4]"); | ||
437 | throw Clipperz.Crypto.Base.exception.CorruptedMessage; | ||
438 | }) | ||
439 | } else { | ||
440 | deferredResult.addCallback(function() { | ||
441 | return null; | ||
442 | }); | ||
443 | } | ||
444 | deferredResult.callback(); | ||
445 | |||
446 | return deferredResult; | ||
447 | }, | ||
448 | |||
449 | 'hash': Clipperz.Crypto.SHA.sha_d256, | ||
450 | |||
451 | 'deriveKey': function(aStringValue) { | ||
452 | varbyteData; | ||
453 | var result; | ||
454 | |||
455 | byteData = new Clipperz.ByteArray(aStringValue); | ||
456 | result = Clipperz.Crypto.SHA.sha_d256(byteData); | ||
457 | |||
458 | return result; | ||
459 | } | ||
422 | }, | 460 | }, |
423 | */ | 461 | |
424 | //##################################################################### | 462 | //##################################################################### |
425 | __syntaxFix__: "syntax fix" | 463 | __syntaxFix__: "syntax fix" |
426 | } | 464 | } |
diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/User.js b/frontend/gamma/js/Clipperz/PM/DataModel/User.js index fd18faf..b94fe4c 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/User.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/User.js | |||
@@ -726,8 +726,8 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, { | |||
726 | header = {}; | 726 | header = {}; |
727 | header['records'] = someHeaderPackedData['recordIndex']['records']; | 727 | header['records'] = someHeaderPackedData['recordIndex']['records']; |
728 | header['directLogins'] = someHeaderPackedData['recordIndex']['directLogins']; | 728 | header['directLogins'] = someHeaderPackedData['recordIndex']['directLogins']; |
729 | header['preferences'] = {'data': someHeaderPackedData['preferences']['data']}; // this._serverData['header']['preferences']; // Clipperz.Base.evalJSON(this._serverData['header']['data'])['preferences']; //??????????? | 729 | header['preferences'] = {'data': someHeaderPackedData['preferences']['data']}; |
730 | header['oneTimePasswords'] = {'data': someHeaderPackedData['oneTimePasswords']['data']}; // this._serverData['header']['oneTimePasswords']; // Clipperz.Base.evalJSON(this._serverData['header']['data'])['oneTimePasswords']; //??????????? | 730 | header['oneTimePasswords']= {'data': someHeaderPackedData['oneTimePasswords']['data']}; |
731 | header['version'] = '0.1'; | 731 | header['version'] = '0.1'; |
732 | 732 | ||
733 | aResult['header'] = Clipperz.Base.serializeJSON(header); | 733 | aResult['header'] = Clipperz.Base.serializeJSON(header); |
diff --git a/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js b/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js index 326022c..b806cb7 100644 --- a/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js +++ b/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js | |||
@@ -281,7 +281,7 @@ Clipperz.Base.extend(Clipperz.PM.Proxy.Offline.DataStore, Object, { | |||
281 | 's': someParameters['credentials']['s'], | 281 | 's': someParameters['credentials']['s'], |
282 | 'v': someParameters['credentials']['v'], | 282 | 'v': someParameters['credentials']['v'], |
283 | 'version':someParameters['credentials']['version'], | 283 | 'version':someParameters['credentials']['version'], |
284 | 'lock': Clipperz.Crypto.Base.generateRandomSeed(), | 284 | // 'lock': Clipperz.Crypto.Base.generateRandomSeed(), |
285 | 'userDetails': someParameters['user']['header'], | 285 | 'userDetails': someParameters['user']['header'], |
286 | 'statistics': someParameters['user']['statistics'], | 286 | 'statistics': someParameters['user']['statistics'], |
287 | 'userDetailsVersion':someParameters['user']['version'], | 287 | 'userDetailsVersion':someParameters['user']['version'], |
@@ -569,7 +569,7 @@ Clipperz.Base.extend(Clipperz.PM.Proxy.Offline.DataStore, Object, { | |||
569 | 569 | ||
570 | aConnection['userData']['userDetails'] = someParameters['parameters']['user']['header']; | 570 | aConnection['userData']['userDetails'] = someParameters['parameters']['user']['header']; |
571 | aConnection['userData']['statistics'] = someParameters['parameters']['user']['statistics']; | 571 | aConnection['userData']['statistics'] = someParameters['parameters']['user']['statistics']; |
572 | aConnection['userData']['userDetailsVersions']= someParameters['parameters']['user']['version']; | 572 | aConnection['userData']['userDetailsVersion']= someParameters['parameters']['user']['version']; |
573 | 573 | ||
574 | c = someParameters['parameters']['records']['updated'].length; | 574 | c = someParameters['parameters']['records']['updated'].length; |
575 | for (i=0; i<c; i++) { | 575 | for (i=0; i<c; i++) { |
diff --git a/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Test.js b/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Test.js index d459726..1a860c5 100644 --- a/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Test.js +++ b/frontend/gamma/js/Clipperz/PM/Proxy/Proxy.Test.js | |||
@@ -143,6 +143,11 @@ Clipperz.Base.extend(Clipperz.PM.Proxy.Test, Clipperz.PM.Proxy.Offline, { | |||
143 | Clipperz.log("UNEXPECTED REQUEST " + aFunctionName /* + ": " + Clipperz.Base.serializeJSON(someParameters) */); | 143 | Clipperz.log("UNEXPECTED REQUEST " + aFunctionName /* + ": " + Clipperz.Base.serializeJSON(someParameters) */); |
144 | this.unexpectedRequests().push({'functionName':aFunctionName, 'someParameters': someParameters}); | 144 | this.unexpectedRequests().push({'functionName':aFunctionName, 'someParameters': someParameters}); |
145 | }; | 145 | }; |
146 | //if (aFunctionName == 'knock') { | ||
147 | //console.log(">>> send message - " + aFunctionName, someParameters); | ||
148 | //} else { | ||
149 | //console.log(">>> SEND MESSAGE - " + aFunctionName + " [" + someParameters['parameters']['message'] + "]", someParameters['parameters']['parameters']); | ||
150 | //} | ||
146 | this.checkRequest(aFunctionName, someParameters); | 151 | this.checkRequest(aFunctionName, someParameters); |
147 | result = Clipperz.PM.Proxy.Test.superclass.sendMessage.call(this, aFunctionName, someParameters); | 152 | result = Clipperz.PM.Proxy.Test.superclass.sendMessage.call(this, aFunctionName, someParameters); |
148 | 153 | ||