Diffstat (limited to 'frontend/gamma/js/Clipperz/Crypto/SRP.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/Crypto/SRP.js | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/frontend/gamma/js/Clipperz/Crypto/SRP.js b/frontend/gamma/js/Clipperz/Crypto/SRP.js index 3b25275..597e72d 100644 --- a/frontend/gamma/js/Clipperz/Crypto/SRP.js +++ b/frontend/gamma/js/Clipperz/Crypto/SRP.js | |||
@@ -1,25 +1,23 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer to http://www.clipperz.com. |
9 | 8 | ||
10 | * Clipperz Community Edition is free software: you can redistribute | 9 | * Clipperz is free software: you can redistribute it and/or modify it |
11 | it and/or modify it under the terms of the GNU Affero General Public | 10 | under the terms of the GNU Affero General Public License as published |
12 | License as published by the Free Software Foundation, either version | 11 | by the Free Software Foundation, either version 3 of the License, or |
13 | 3 of the License, or (at your option) any later version. | 12 | (at your option) any later version. |
14 | 13 | ||
15 | * Clipperz Community Edition is distributed in the hope that it will | 14 | * Clipperz is distributed in the hope that it will be useful, but |
16 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
18 | See the GNU Affero General Public License for more details. | 17 | See the GNU Affero General Public License for more details. |
19 | 18 | ||
20 | * You should have received a copy of the GNU Affero General Public | 19 | * You should have received a copy of the GNU Affero General Public |
21 | License along with Clipperz Community Edition. If not, see | 20 | License along with Clipperz. If not, see http://www.gnu.org/licenses/. |
22 | <http://www.gnu.org/licenses/>. | ||
23 | 21 | ||
24 | */ | 22 | */ |
25 | 23 | ||
@@ -131,7 +129,6 @@ Clipperz.Crypto.SRP.Connection.prototype = MochiKit.Base.update(null, { | |||
131 | if (this._a == null) { | 129 | if (this._a == null) { |
132 | this._a = new Clipperz.Crypto.BigInt(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32).toHexString().substring(2), 16); | 130 | this._a = new Clipperz.Crypto.BigInt(Clipperz.Crypto.PRNG.defaultRandomGenerator().getRandomBytes(32).toHexString().substring(2), 16); |
133 | // this._a = new Clipperz.Crypto.BigInt("37532428169486597638072888476611365392249575518156687476805936694442691012367", 10); | 131 | // this._a = new Clipperz.Crypto.BigInt("37532428169486597638072888476611365392249575518156687476805936694442691012367", 10); |
134 | //MochiKit.Logging.logDebug("SRP a: " + this._a); | ||
135 | } | 132 | } |
136 | 133 | ||
137 | return this._a; | 134 | return this._a; |
@@ -145,10 +142,9 @@ Clipperz.Crypto.SRP.Connection.prototype = MochiKit.Base.update(null, { | |||
145 | this._A = Clipperz.Crypto.SRP.g().powerModule(this.a(), Clipperz.Crypto.SRP.n()); | 142 | this._A = Clipperz.Crypto.SRP.g().powerModule(this.a(), Clipperz.Crypto.SRP.n()); |
146 | 143 | ||
147 | if (this._A.equals(0)) { | 144 | if (this._A.equals(0)) { |
148 | MochiKit.Logging.logError("Clipperz.Crypto.SRP.Connection: trying to set 'A' to 0."); | 145 | Clipperz.logError("Clipperz.Crypto.SRP.Connection: trying to set 'A' to 0."); |
149 | throw Clipperz.Crypto.SRP.exception.InvalidValue; | 146 | throw Clipperz.Crypto.SRP.exception.InvalidValue; |
150 | } | 147 | } |
151 | //MochiKit.Logging.logDebug("SRP A: " + this._A); | ||
152 | } | 148 | } |
153 | 149 | ||
154 | return this._A; | 150 | return this._A; |
@@ -158,7 +154,6 @@ MochiKit.Logging.logError("Clipperz.Crypto.SRP.Connection: trying to set 'A' to | |||
158 | 154 | ||
159 | 's': function () { | 155 | 's': function () { |
160 | return this._s; | 156 | return this._s; |
161 | //MochiKit.Logging.logDebug("SRP s: " + this._S); | ||
162 | }, | 157 | }, |
163 | 158 | ||
164 | 'set_s': function(aValue) { | 159 | 'set_s': function(aValue) { |
@@ -175,9 +170,8 @@ MochiKit.Logging.logError("Clipperz.Crypto.SRP.Connection: trying to set 'A' to | |||
175 | //Warning: this value should be strictly greater than zero: how should we perform this check? | 170 | //Warning: this value should be strictly greater than zero: how should we perform this check? |
176 | if (! aValue.equals(0)) { | 171 | if (! aValue.equals(0)) { |
177 | this._B = aValue; | 172 | this._B = aValue; |
178 | //MochiKit.Logging.logDebug("SRP B: " + this._B); | ||
179 | } else { | 173 | } else { |
180 | MochiKit.Logging.logError("Clipperz.Crypto.SRP.Connection: trying to set 'B' to 0."); | 174 | Clipperz.logError("Clipperz.Crypto.SRP.Connection: trying to set 'B' to 0."); |
181 | throw Clipperz.Crypto.SRP.exception.InvalidValue; | 175 | throw Clipperz.Crypto.SRP.exception.InvalidValue; |
182 | } | 176 | } |
183 | }, | 177 | }, |
@@ -187,7 +181,6 @@ MochiKit.Logging.logError("Clipperz.Crypto.SRP.Connection: trying to set 'B' to | |||
187 | 'x': function () { | 181 | 'x': function () { |
188 | if (this._x == null) { | 182 | if (this._x == null) { |
189 | this._x = new Clipperz.Crypto.BigInt(this.stringHash(this.s().asString(16, 64) + this.P()), 16); | 183 | this._x = new Clipperz.Crypto.BigInt(this.stringHash(this.s().asString(16, 64) + this.P()), 16); |
190 | //MochiKit.Logging.logDebug("SRP x: " + this._x); | ||
191 | } | 184 | } |
192 | 185 | ||
193 | return this._x; | 186 | return this._x; |
@@ -198,7 +191,6 @@ MochiKit.Logging.logError("Clipperz.Crypto.SRP.Connection: trying to set 'B' to | |||
198 | 'u': function () { | 191 | 'u': function () { |
199 | if (this._u == null) { | 192 | if (this._u == null) { |
200 | this._u = new Clipperz.Crypto.BigInt(this.stringHash(this.B().asString()), 16); | 193 | this._u = new Clipperz.Crypto.BigInt(this.stringHash(this.B().asString()), 16); |
201 | //MochiKit.Logging.logDebug("SRP u: " + this._u); | ||
202 | } | 194 | } |
203 | 195 | ||
204 | return this._u; | 196 | return this._u; |
@@ -219,7 +211,6 @@ MochiKit.Logging.logError("Clipperz.Crypto.SRP.Connection: trying to set 'B' to | |||
219 | bigint.add(this.a(), bigint.multiply(this.u(), this.x())), | 211 | bigint.add(this.a(), bigint.multiply(this.u(), this.x())), |
220 | srp.n() | 212 | srp.n() |
221 | ) | 213 | ) |
222 | //MochiKit.Logging.logDebug("SRP S: " + this._S); | ||
223 | } | 214 | } |
224 | 215 | ||
225 | return this._S; | 216 | return this._S; |
@@ -230,7 +221,6 @@ MochiKit.Logging.logError("Clipperz.Crypto.SRP.Connection: trying to set 'B' to | |||
230 | 'K': function () { | 221 | 'K': function () { |
231 | if (this._K == null) { | 222 | if (this._K == null) { |
232 | this._K = this.stringHash(this.S().asString()); | 223 | this._K = this.stringHash(this.S().asString()); |
233 | //MochiKit.Logging.logDebug("SRP K: " + this._K); | ||
234 | } | 224 | } |
235 | 225 | ||
236 | return this._K; | 226 | return this._K; |
@@ -241,7 +231,6 @@ MochiKit.Logging.logError("Clipperz.Crypto.SRP.Connection: trying to set 'B' to | |||
241 | 'M1': function () { | 231 | 'M1': function () { |
242 | if (this._M1 == null) { | 232 | if (this._M1 == null) { |
243 | this._M1 = this.stringHash(this.A().asString(10) + this.B().asString(10) + this.K()); | 233 | this._M1 = this.stringHash(this.A().asString(10) + this.B().asString(10) + this.K()); |
244 | //MochiKit.Logging.logDebug("SRP M1: " + this._M1); | ||
245 | } | 234 | } |
246 | 235 | ||
247 | return this._M1; | 236 | return this._M1; |
@@ -252,7 +241,6 @@ MochiKit.Logging.logError("Clipperz.Crypto.SRP.Connection: trying to set 'B' to | |||
252 | 'M2': function () { | 241 | 'M2': function () { |
253 | if (this._M2 == null) { | 242 | if (this._M2 == null) { |
254 | this._M2 = this.stringHash(this.A().asString(10) + this.M1() + this.K()); | 243 | this._M2 = this.stringHash(this.A().asString(10) + this.M1() + this.K()); |
255 | //MochiKit.Logging.logDebug("SRP M2: " + this._M2); | ||
256 | } | 244 | } |
257 | 245 | ||
258 | return this._M2; | 246 | return this._M2; |