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 | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/gamma/js/Clipperz/Crypto/SRP.js b/frontend/gamma/js/Clipperz/Crypto/SRP.js index 0eef6ec..3b25275 100644 --- a/frontend/gamma/js/Clipperz/Crypto/SRP.js +++ b/frontend/gamma/js/Clipperz/Crypto/SRP.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.BigInt) == 'undefined') { throw ""; }} catch (e) { | 30 | try { if (typeof(Clipperz.Crypto.BigInt) == 'undefined') { throw ""; }} catch (e) { |
34 | throw "Clipperz.Crypto.SRP depends on Clipperz.Crypto.BigInt!"; | 31 | throw "Clipperz.Crypto.SRP depends on Clipperz.Crypto.BigInt!"; |
35 | } | 32 | } |
36 | 33 | ||
37 | try { if (typeof(Clipperz.Crypto.PRNG) == 'undefined') { throw ""; }} catch (e) { | 34 | try { if (typeof(Clipperz.Crypto.PRNG) == 'undefined') { throw ""; }} catch (e) { |
38 | throw "Clipperz.Crypto.SRP depends on Clipperz.Crypto.PRNG!"; | 35 | throw "Clipperz.Crypto.SRP depends on Clipperz.Crypto.PRNG!"; |
39 | } | 36 | } |
40 | 37 | ||
41 | if (typeof(Clipperz.Crypto.SRP) == 'undefined') { Clipperz.Crypto.SRP = {}; } | 38 | if (typeof(Clipperz.Crypto.SRP) == 'undefined') { Clipperz.Crypto.SRP = {}; } |
42 | 39 | ||
43 | Clipperz.Crypto.SRP.VERSION = "0.1"; | 40 | Clipperz.Crypto.SRP.VERSION = "0.1"; |
44 | Clipperz.Crypto.SRP.NAME = "Clipperz.Crypto.SRP"; | 41 | Clipperz.Crypto.SRP.NAME = "Clipperz.Crypto.SRP"; |
45 | 42 | ||
46 | //############################################################################# | 43 | //############################################################################# |
47 | 44 | ||
48 | MochiKit.Base.update(Clipperz.Crypto.SRP, { | 45 | MochiKit.Base.update(Clipperz.Crypto.SRP, { |
49 | 46 | ||
50 | '_n': null, | 47 | '_n': null, |
51 | '_g': null, | 48 | '_g': null, |
52 | //------------------------------------------------------------------------- | 49 | //------------------------------------------------------------------------- |
53 | 50 | ||
54 | 'n': function() { | 51 | 'n': function() { |
55 | if (Clipperz.Crypto.SRP._n == null) { | 52 | if (Clipperz.Crypto.SRP._n == null) { |
56 | Clipperz.Crypto.SRP._n = new Clipperz.Crypto.BigInt("115b8b692e0e045692cf280b436735c77a5a9e8a9e7ed56c965f87db5b2a2ece3", 16); | 53 | Clipperz.Crypto.SRP._n = new Clipperz.Crypto.BigInt("115b8b692e0e045692cf280b436735c77a5a9e8a9e7ed56c965f87db5b2a2ece3", 16); |
57 | } | 54 | } |
58 | 55 | ||
59 | return Clipperz.Crypto.SRP._n; | 56 | return Clipperz.Crypto.SRP._n; |
60 | }, | 57 | }, |
61 | 58 | ||
62 | //------------------------------------------------------------------------- | 59 | //------------------------------------------------------------------------- |
63 | 60 | ||
64 | 'g': function() { | 61 | 'g': function() { |
65 | if (Clipperz.Crypto.SRP._g == null) { | 62 | if (Clipperz.Crypto.SRP._g == null) { |
66 | Clipperz.Crypto.SRP._g = new Clipperz.Crypto.BigInt(2); //eventually 5 (as suggested on the Diffi-Helmann documentation) | 63 | Clipperz.Crypto.SRP._g = new Clipperz.Crypto.BigInt(2); //eventually 5 (as suggested on the Diffi-Helmann documentation) |
67 | } | 64 | } |
68 | 65 | ||
69 | return Clipperz.Crypto.SRP._g; | 66 | return Clipperz.Crypto.SRP._g; |
70 | }, | 67 | }, |
71 | 68 | ||
72 | //----------------------------------------------------------------------------- | 69 | //----------------------------------------------------------------------------- |
73 | 70 | ||
74 | 'exception': { | 71 | 'exception': { |
75 | 'InvalidValue': new MochiKit.Base.NamedError("Clipperz.Crypto.SRP.exception.InvalidValue") | 72 | 'InvalidValue': new MochiKit.Base.NamedError("Clipperz.Crypto.SRP.exception.InvalidValue") |
76 | }, | 73 | }, |
77 | 74 | ||
78 | //------------------------------------------------------------------------- | 75 | //------------------------------------------------------------------------- |
79 | __syntaxFix__: "syntax fix" | 76 | __syntaxFix__: "syntax fix" |
80 | 77 | ||
81 | }); | 78 | }); |
82 | 79 | ||
83 | //############################################################################# | 80 | //############################################################################# |
84 | // | 81 | // |
85 | // S R P C o n n e c t i o n version 1.0 | 82 | // S R P C o n n e c t i o n version 1.0 |
86 | // | 83 | // |
87 | //============================================================================= | 84 | //============================================================================= |
88 | Clipperz.Crypto.SRP.Connection = function (args) { | 85 | Clipperz.Crypto.SRP.Connection = function (args) { |
89 | args = args || {}; | 86 | args = args || {}; |
90 | 87 | ||
91 | this._C = args.C; | 88 | this._C = args.C; |
92 | this._P = args.P; | 89 | this._P = args.P; |
93 | this.hash = args.hash; | 90 | this.hash = args.hash; |
94 | 91 | ||
95 | this._a = null; | 92 | this._a = null; |
96 | this._A = null; | 93 | this._A = null; |
97 | 94 | ||
98 | this._s = null; | 95 | this._s = null; |
99 | this._B = null; | 96 | this._B = null; |
100 | 97 | ||
101 | this._x = null; | 98 | this._x = null; |
102 | 99 | ||
103 | this._u = null; | 100 | this._u = null; |
104 | this._K = null; | 101 | this._K = null; |
105 | this._M1 = null; | 102 | this._M1 = null; |
106 | this._M2 = null; | 103 | this._M2 = null; |
107 | 104 | ||
108 | this._sessionKey = null; | 105 | this._sessionKey = null; |
109 | 106 | ||
110 | return this; | 107 | return this; |
111 | } | 108 | } |
112 | 109 | ||
113 | Clipperz.Crypto.SRP.Connection.prototype = MochiKit.Base.update(null, { | 110 | Clipperz.Crypto.SRP.Connection.prototype = MochiKit.Base.update(null, { |
114 | 111 | ||
115 | 'toString': function () { | 112 | 'toString': function () { |
116 | return "Clipperz.Crypto.SRP.Connection (username: " + this.username() + "). Status: " + this.statusDescription(); | 113 | return "Clipperz.Crypto.SRP.Connection (username: " + this.username() + "). Status: " + this.statusDescription(); |
117 | }, | 114 | }, |
118 | 115 | ||
119 | //------------------------------------------------------------------------- | 116 | //------------------------------------------------------------------------- |
120 | 117 | ||