Diffstat (limited to 'frontend/gamma/js/Clipperz/Crypto/AES.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/Crypto/AES.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/gamma/js/Clipperz/Crypto/AES.js b/frontend/gamma/js/Clipperz/Crypto/AES.js index 36fc731..c811f1c 100644 --- a/frontend/gamma/js/Clipperz/Crypto/AES.js +++ b/frontend/gamma/js/Clipperz/Crypto/AES.js | |||
@@ -1,120 +1,117 @@ | |||
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 | try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { | 26 | try { if (typeof(Clipperz.ByteArray) == 'undefined') { throw ""; }} catch (e) { |
30 | throw "Clipperz.Crypto.AES depends on Clipperz.ByteArray!"; | 27 | throw "Clipperz.Crypto.AES depends on Clipperz.ByteArray!"; |
31 | } | 28 | } |
32 | 29 | ||
33 | //Dependency commented to avoid a circular reference | 30 | //Dependency commented to avoid a circular reference |
34 | //try { if (typeof(Clipperz.Crypto.PRNG) == 'undefined') { throw ""; }} catch (e) { | 31 | //try { if (typeof(Clipperz.Crypto.PRNG) == 'undefined') { throw ""; }} catch (e) { |
35 | //throw "Clipperz.Crypto.AES depends on Clipperz.Crypto.PRNG!"; | 32 | //throw "Clipperz.Crypto.AES depends on Clipperz.Crypto.PRNG!"; |
36 | //} | 33 | //} |
37 | 34 | ||
38 | if (typeof(Clipperz.Crypto.AES) == 'undefined') { Clipperz.Crypto.AES = {}; } | 35 | if (typeof(Clipperz.Crypto.AES) == 'undefined') { Clipperz.Crypto.AES = {}; } |
39 | 36 | ||
40 | //############################################################################# | 37 | //############################################################################# |
41 | 38 | ||
42 | Clipperz.Crypto.AES.DeferredExecutionContext = function(args) { | 39 | Clipperz.Crypto.AES.DeferredExecutionContext = function(args) { |
43 | args = args || {}; | 40 | args = args || {}; |
44 | 41 | ||
45 | this._key = args.key; | 42 | this._key = args.key; |
46 | this._message = args.message; | 43 | this._message = args.message; |
47 | this._result = args.message.clone(); | 44 | this._result = args.message.clone(); |
48 | this._nonce = args.nonce; | 45 | this._nonce = args.nonce; |
49 | this._messageLength = this._message.length(); | 46 | this._messageLength = this._message.length(); |
50 | 47 | ||
51 | this._messageArray = this._message.arrayValues(); | 48 | this._messageArray = this._message.arrayValues(); |
52 | this._resultArray = this._result.arrayValues(); | 49 | this._resultArray = this._result.arrayValues(); |
53 | this._nonceArray = this._nonce.arrayValues(); | 50 | this._nonceArray = this._nonce.arrayValues(); |
54 | 51 | ||
55 | this._executionStep = 0; | 52 | this._executionStep = 0; |
56 | 53 | ||
57 | // this._elaborationChunkSize = 1024; // 4096; // 16384; //4096; | 54 | // this._elaborationChunkSize = 1024; // 4096; // 16384; //4096; |
58 | this._elaborationChunks = 10; | 55 | this._elaborationChunks = 10; |
59 | this._pauseTime = 0.02; // 0.02 //0.2; | 56 | this._pauseTime = 0.02; // 0.02 //0.2; |
60 | 57 | ||
61 | return this; | 58 | return this; |
62 | } | 59 | } |
63 | 60 | ||
64 | Clipperz.Crypto.AES.DeferredExecutionContext.prototype = MochiKit.Base.update(null, { | 61 | Clipperz.Crypto.AES.DeferredExecutionContext.prototype = MochiKit.Base.update(null, { |
65 | 62 | ||
66 | 'key': function() { | 63 | 'key': function() { |
67 | return this._key; | 64 | return this._key; |
68 | }, | 65 | }, |
69 | 66 | ||
70 | 'message': function() { | 67 | 'message': function() { |
71 | return this._message; | 68 | return this._message; |
72 | }, | 69 | }, |
73 | 70 | ||
74 | 'messageLength': function() { | 71 | 'messageLength': function() { |
75 | return this._messageLength; | 72 | return this._messageLength; |
76 | }, | 73 | }, |
77 | 74 | ||
78 | 'result': function() { | 75 | 'result': function() { |
79 | return new Clipperz.ByteArray(this.resultArray()); | 76 | return new Clipperz.ByteArray(this.resultArray()); |
80 | }, | 77 | }, |
81 | 78 | ||
82 | 'nonce': function() { | 79 | 'nonce': function() { |
83 | return this._nonce; | 80 | return this._nonce; |
84 | }, | 81 | }, |
85 | 82 | ||
86 | 'messageArray': function() { | 83 | 'messageArray': function() { |
87 | return this._messageArray; | 84 | return this._messageArray; |
88 | }, | 85 | }, |
89 | 86 | ||
90 | 'resultArray': function() { | 87 | 'resultArray': function() { |
91 | return this._resultArray; | 88 | return this._resultArray; |
92 | }, | 89 | }, |
93 | 90 | ||
94 | 'nonceArray': function() { | 91 | 'nonceArray': function() { |
95 | return this._nonceArray; | 92 | return this._nonceArray; |
96 | }, | 93 | }, |
97 | 94 | ||
98 | 'elaborationChunkSize': function() { | 95 | 'elaborationChunkSize': function() { |
99 | // return Clipperz.Crypto.AES.DeferredExecution.chunkSize; | 96 | // return Clipperz.Crypto.AES.DeferredExecution.chunkSize; |
100 | // return this._elaborationChunkSize; | 97 | // return this._elaborationChunkSize; |
101 | return (this._elaborationChunks * 1024); | 98 | return (this._elaborationChunks * 1024); |
102 | }, | 99 | }, |
103 | 100 | ||
104 | 'executionStep': function() { | 101 | 'executionStep': function() { |
105 | return this._executionStep; | 102 | return this._executionStep; |
106 | }, | 103 | }, |
107 | 104 | ||
108 | 'setExecutionStep': function(aValue) { | 105 | 'setExecutionStep': function(aValue) { |
109 | this._executionStep = aValue; | 106 | this._executionStep = aValue; |
110 | }, | 107 | }, |
111 | 108 | ||
112 | 'tuneExecutionParameters': function (anElapsedTime) { | 109 | 'tuneExecutionParameters': function (anElapsedTime) { |
113 | //var originalChunks = this._elaborationChunks; | 110 | //var originalChunks = this._elaborationChunks; |
114 | if (anElapsedTime > 0) { | 111 | if (anElapsedTime > 0) { |
115 | this._elaborationChunks = Math.round(this._elaborationChunks * ((anElapsedTime + 1000)/(anElapsedTime * 2))); | 112 | this._elaborationChunks = Math.round(this._elaborationChunks * ((anElapsedTime + 1000)/(anElapsedTime * 2))); |
116 | } | 113 | } |
117 | //Clipperz.log("tuneExecutionParameters - elapsedTime: " + anElapsedTime + /*originalChunks,*/ " chunks # " + this._elaborationChunks + " [" + this._executionStep + " / " + this._messageLength + "]"); | 114 | //Clipperz.log("tuneExecutionParameters - elapsedTime: " + anElapsedTime + /*originalChunks,*/ " chunks # " + this._elaborationChunks + " [" + this._executionStep + " / " + this._messageLength + "]"); |
118 | }, | 115 | }, |
119 | 116 | ||
120 | 'pause': function(aValue) { | 117 | 'pause': function(aValue) { |