author | Giulio Cesare Solaroli <giulio.cesare@clipperz.com> | 2011-10-06 00:36:10 (UTC) |
---|---|---|
committer | Giulio Cesare Solaroli <giulio.cesare@clipperz.com> | 2011-10-06 00:36:10 (UTC) |
commit | 6ba274c79e60e417132b260bd0117c5a68121387 (patch) (unidiff) | |
tree | 57c1f95d0fbf9b80312c5c6b6f4a4f951e31c770 /frontend/gamma/js/Clipperz/Crypto/PRNG.js | |
parent | 13ebf1b1987a1566d081ff1ba89b4dca197b7d2e (diff) | |
download | clipperz-6ba274c79e60e417132b260bd0117c5a68121387.zip clipperz-6ba274c79e60e417132b260bd0117c5a68121387.tar.gz clipperz-6ba274c79e60e417132b260bd0117c5a68121387.tar.bz2 |
Fixed the copyright headers
Diffstat (limited to 'frontend/gamma/js/Clipperz/Crypto/PRNG.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/Crypto/PRNG.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/gamma/js/Clipperz/Crypto/PRNG.js b/frontend/gamma/js/Clipperz/Crypto/PRNG.js index 266b909..adfdb16 100644 --- a/frontend/gamma/js/Clipperz/Crypto/PRNG.js +++ b/frontend/gamma/js/Clipperz/Crypto/PRNG.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.PRNG depends on Clipperz.ByteArray!"; | 27 | throw "Clipperz.Crypto.PRNG depends on Clipperz.ByteArray!"; |
31 | } | 28 | } |
32 | 29 | ||
33 | try { if (typeof(Clipperz.Crypto.SHA) == 'undefined') { throw ""; }} catch (e) { | 30 | try { if (typeof(Clipperz.Crypto.SHA) == 'undefined') { throw ""; }} catch (e) { |
34 | throw "Clipperz.Crypto.PRNG depends on Clipperz.Crypto.SHA!"; | 31 | throw "Clipperz.Crypto.PRNG depends on Clipperz.Crypto.SHA!"; |
35 | } | 32 | } |
36 | 33 | ||
37 | try { if (typeof(Clipperz.Crypto.AES) == 'undefined') { throw ""; }} catch (e) { | 34 | try { if (typeof(Clipperz.Crypto.AES) == 'undefined') { throw ""; }} catch (e) { |
38 | throw "Clipperz.Crypto.PRNG depends on Clipperz.Crypto.AES!"; | 35 | throw "Clipperz.Crypto.PRNG depends on Clipperz.Crypto.AES!"; |
39 | } | 36 | } |
40 | 37 | ||
41 | if (typeof(Clipperz.Crypto.PRNG) == 'undefined') { Clipperz.Crypto.PRNG = {}; } | 38 | if (typeof(Clipperz.Crypto.PRNG) == 'undefined') { Clipperz.Crypto.PRNG = {}; } |
42 | 39 | ||
43 | //############################################################################# | 40 | //############################################################################# |
44 | 41 | ||
45 | Clipperz.Crypto.PRNG.EntropyAccumulator = function(args) { | 42 | Clipperz.Crypto.PRNG.EntropyAccumulator = function(args) { |
46 | args = args || {}; | 43 | args = args || {}; |
47 | //MochiKit.Base.bindMethods(this); | 44 | //MochiKit.Base.bindMethods(this); |
48 | 45 | ||
49 | this._stack = new Clipperz.ByteArray(); | 46 | this._stack = new Clipperz.ByteArray(); |
50 | this._maxStackLengthBeforeHashing = args.maxStackLengthBeforeHashing || 256; | 47 | this._maxStackLengthBeforeHashing = args.maxStackLengthBeforeHashing || 256; |
51 | return this; | 48 | return this; |
52 | } | 49 | } |
53 | 50 | ||
54 | Clipperz.Crypto.PRNG.EntropyAccumulator.prototype = MochiKit.Base.update(null, { | 51 | Clipperz.Crypto.PRNG.EntropyAccumulator.prototype = MochiKit.Base.update(null, { |
55 | 52 | ||
56 | 'toString': function() { | 53 | 'toString': function() { |
57 | return "Clipperz.Crypto.PRNG.EntropyAccumulator"; | 54 | return "Clipperz.Crypto.PRNG.EntropyAccumulator"; |
58 | }, | 55 | }, |
59 | 56 | ||
60 | //------------------------------------------------------------------------- | 57 | //------------------------------------------------------------------------- |
61 | 58 | ||
62 | 'stack': function() { | 59 | 'stack': function() { |
63 | return this._stack; | 60 | return this._stack; |
64 | }, | 61 | }, |
65 | 62 | ||
66 | 'setStack': function(aValue) { | 63 | 'setStack': function(aValue) { |
67 | this._stack = aValue; | 64 | this._stack = aValue; |
68 | }, | 65 | }, |
69 | 66 | ||
70 | 'resetStack': function() { | 67 | 'resetStack': function() { |
71 | this.stack().reset(); | 68 | this.stack().reset(); |
72 | }, | 69 | }, |
73 | 70 | ||
74 | 'maxStackLengthBeforeHashing': function() { | 71 | 'maxStackLengthBeforeHashing': function() { |
75 | return this._maxStackLengthBeforeHashing; | 72 | return this._maxStackLengthBeforeHashing; |
76 | }, | 73 | }, |
77 | 74 | ||
78 | //------------------------------------------------------------------------- | 75 | //------------------------------------------------------------------------- |
79 | 76 | ||
80 | 'addRandomByte': function(aValue) { | 77 | 'addRandomByte': function(aValue) { |
81 | this.stack().appendByte(aValue); | 78 | this.stack().appendByte(aValue); |
82 | 79 | ||
83 | if (this.stack().length() > this.maxStackLengthBeforeHashing()) { | 80 | if (this.stack().length() > this.maxStackLengthBeforeHashing()) { |
84 | this.setStack(Clipperz.Crypto.SHA.sha_d256(this.stack())); | 81 | this.setStack(Clipperz.Crypto.SHA.sha_d256(this.stack())); |
85 | } | 82 | } |
86 | }, | 83 | }, |
87 | 84 | ||
88 | //------------------------------------------------------------------------- | 85 | //------------------------------------------------------------------------- |
89 | __syntaxFix__: "syntax fix" | 86 | __syntaxFix__: "syntax fix" |
90 | }); | 87 | }); |
91 | 88 | ||
92 | //############################################################################# | 89 | //############################################################################# |
93 | 90 | ||
94 | Clipperz.Crypto.PRNG.RandomnessSource = function(args) { | 91 | Clipperz.Crypto.PRNG.RandomnessSource = function(args) { |
95 | args = args || {}; | 92 | args = args || {}; |
96 | MochiKit.Base.bindMethods(this); | 93 | MochiKit.Base.bindMethods(this); |
97 | 94 | ||
98 | this._generator = args.generator || null; | 95 | this._generator = args.generator || null; |
99 | this._sourceId = args.sourceId || null; | 96 | this._sourceId = args.sourceId || null; |
100 | this._boostMode = args.boostMode || false; | 97 | this._boostMode = args.boostMode || false; |
101 | 98 | ||
102 | this._nextPoolIndex = 0; | 99 | this._nextPoolIndex = 0; |
103 | 100 | ||
104 | return this; | 101 | return this; |
105 | } | 102 | } |
106 | 103 | ||
107 | Clipperz.Crypto.PRNG.RandomnessSource.prototype = MochiKit.Base.update(null, { | 104 | Clipperz.Crypto.PRNG.RandomnessSource.prototype = MochiKit.Base.update(null, { |
108 | 105 | ||
109 | 'generator': function() { | 106 | 'generator': function() { |
110 | return this._generator; | 107 | return this._generator; |
111 | }, | 108 | }, |
112 | 109 | ||
113 | 'setGenerator': function(aValue) { | 110 | 'setGenerator': function(aValue) { |
114 | this._generator = aValue; | 111 | this._generator = aValue; |
115 | }, | 112 | }, |
116 | 113 | ||
117 | //------------------------------------------------------------------------- | 114 | //------------------------------------------------------------------------- |
118 | 115 | ||
119 | 'boostMode': function() { | 116 | 'boostMode': function() { |
120 | return this._boostMode; | 117 | return this._boostMode; |